Matrix implementation



Dan,

I'm not sure what you are trying to do, but I wonder
if you can do what you want without appending size
info to the car of a matrix.

(%i1) m1 : matrix([],[]);   <--- matrix with 2 rows and 0 cols
(%o1) matrix([ ],[ ])

(%i2) m2 : matrix([1],[2]);
(%o2) matrix([1],[2])
(%i3) addcol(m1,m2);
(%o3) matrix([1],[2])      <--- this is OK


(%i4) addcol(m2,m1);       <--- I think this should work, but it doesn't

Incompatible structure - ADDROW//ADDCOL

(%i5) load(linalg)$       <--- my linalg code

(%i6) matrix([m1,m2]);    <--- a block matrix
(%o6) matrix([matrix([ ],[ ]),matrix([1],[2])])
(%i7) unblockmatrix(%);
(%o7) matrix([1],[2])     <--- OK

(%i8) matrix([m2,m1]);    <--- try again

(%o8) matrix([matrix([1],[2]),matrix([ ],[ ])])
(%i9) unblockmatrix(%);
Incompatible structure - ADDROW//ADDCOL  <--- isn't this a addcol bug?


And maybe we've been through this before, but why can't you
find the matrix size without storing it?

(%i12) length(m1);
(%o12) 2
(%i13) length(first(m1));
(%o13) 0

Barton