>> Why I would be against this extension is that TwoDimensionaArray
>> is a data structure domain, i.e., no algebraic operations.
>>
>> Your operations should live in an "algebraic" domain. But even
>> then I see problems, because + and * will be partial functions
>> (much as in Matrix(Matrix Integer) if it were possible).
> that is very subtle distinction, what should be an arithmetic
> domain, if it has a + and/or a *. Is /\ etc. also an arithmetic
> operation? Do you propagate a meta classification of domains, which -
> right now - only can be in the peoples mind, not in a valid FriCAS
> definition?
You are completely right. There is no definition of a "data structure
domain" in FriCAS. Still, I have the feeling that it's a good idea to
separate data structures with creation and accessor functions from
domains that use them as representation and do operations on these
structures.
> Is the domain Matrix an algebraic domain with all its partial
> functions + and *? Your argument would had been valid against the
> creation of a domain Matrix as well.
Sure. But somehow a mathematician is used to the fact that + and * for
matrices only works for compatible ones. In that sense I would rather
aim at allowing more general argument types for Matrix so that
Matrix(Matrix Integer) would be possible. However, I guess nobody has
thought of this before and it would break things in other places as
Bill's experiments seem to indicate.
>> What application do you have in mind?
>
> block matrices as in the example I gave. I am really using them,
> when I have to split a matrix in subblocks according to orbits of
> group operations.
I'm not saying that we shouldn't have block matrices.
What I see from you example is that your matrices A and B could also be
matrices of type Matrix(INT) and the computations would be exactly the
same except that one doesn't see the block structure of the matrix.
This is where I would ask you to provide a list of operations that you
have in mind should work for "blocked matrices". Currently, I have the
impression, that it would be an option to create a domain
BlockMatrix(R: Ring)
that behaves exactly like Matrix(Integer). However, the internal data
structure would be a record, something like this
Record(mat: Matrix(R), hsplit: List Z, vsplit: List Z)
with the meaning that when you create
m: Matrix(INT) := matrix [[2, 1, 2, 3], [1, 3, 1, 0], [7,5,5,3]]
b: BlockMatrix(INT) := block(m, [1],[1])
it would exactly print as
+[2] [1 2 3] +
| |
|+1+ +- 3 1 0+|
|| | | ||
++7+ + 5 5 3++
or maybe as
+ 2 | 1 2 3 +
|---+-----------|
| 1 | - 3 1 0 |
| | |
+ 7 | 5 5 3 +
i.e., the matrix splits after the first row and the first column.
So in total it would still be a matrix over the integers (or rather can
be coerced into Matrix(INT)), but with additional information of where
the blocks are.
Of course, one must work out how the split points can be carried over
in a multiplication of such "blocked matrices" and whether for example
one should be allowed to add/multiply b with block(m, [2], [1]).
I think, introducing such a BlockMatrix domain might be the way to go?
Would that satisfy your needs?
Ralf