[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## [Axiom-developer] [#261 Strange matrix addition] (new)

**From**: |
Ralf Hemmecke |

**Subject**: |
[Axiom-developer] [#261 Strange matrix addition] (new) |

**Date**: |
Wed, 01 Feb 2006 03:42:45 -0600 |

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/address@hidden

[Prev in Thread] |
**Current Thread** |
[Next in Thread] |

**[Axiom-developer] [#261 Strange matrix addition] (new)**,
*Ralf Hemmecke* **<=**