Changes http://wiki.axiom-developer.org/261StrangeMatrixAddition/diff
--
Adding two square matrices of different dimension should result in an error.
Axiom returns something that looks more like a tensor product.
The implementation of + for SquareMatrix is inherited from Matrix
(src/algebra/matrix.spad.pamphlet). Matrix inherits + from the default
implementation in MatrixCategory (src/algebra/matcat.spad.pamphlet).
There it says
"+": (%,%) -> %
++ \spad{x + y} is the sum of the matrices x and y.
++ Error: if the dimensions are incompatible.
and is implemented by default through:
x + y ==
((r := nrows x) ^= nrows y) or ((c := ncols x) ^= ncols y) =>
error "can't add matrices of different dimensions"
ans := new(r,c,0)
for i in minr(x)..maxr(x) repeat
for j in minc(x)..maxc(x) repeat
qsetelt_!(ans,i,j,qelt(x,i,j) + qelt(y,i,j))
ans
I have no idea why the following code returns something of type
SquareMatrix(2,SquareMatrix(3,Integer)).
\begin{axiom}
S d ==> SquareMatrix(d,Integer)
a2: S(2) := 1
a3: S(3) := 1
a2 + a3
\end{axiom}
--
forwarded from http://wiki.axiom-developer.org/[EMAIL PROTECTED]
_______________________________________________
Axiom-developer mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/axiom-developer