Hello,
I'm quite used to maxima but now I stumble on more subtle things with macros&co.
1/ minor concern: let's look at this
(%i3) genmatrix(A,3,5);
[ A A A A A ]
[ 1, 1 1, 2 1, 3 1, 4 1, 5 ]
[ ]
(%o3) [ A A A A A ]
[ 2, 1 2, 2 2, 3 2, 4 2, 5 ]
[ ]
[ A A A A A ]
[ 3, 1 3, 2 3, 3 3, 4 3, 5 ]
is there a manner to tell maxima to subscript starting at value zero A[0,0] etc?
2/ I want to do the same for vectors. genmatrix(A,1,5) or
genmatrix(A,5,1) will still use double subscript.
So the only way seems to use declared arrays (this time, array indices
start from zero... (*)).
array(W,5);
W:makelist(W[i-1],i,5);
(%o8) [W , W , W , W , W ]
0 1 2 3 4
2a: is there an issue with having the token W used for, successively,
the array name W, the array bits W[3] etc, and then, a list named W
that is the only suitable things to evaluate A.W ?
2b: I'm unable to macro-ify the previous thing to make it generic.
That would be something like
genvector(W,n) ::= block(array(''W,n), W:makelist(W[i-1],i,n) );
genvector(A,5);
genvector(B,7);
but W isn't replaced as should.
3/ I also miss the magic thing that would transform [x,y,z] in to
x,y,z arguments like
(%i4) [a,b,c];
(%o4) [a, b, c]
(%i3) diag_matrix(a,b,c);
[ a 0 0 ]
[ ]
(%o3) [ 0 b 0 ]
[ ]
[ 0 0 c ]
...
Thanks for any useful advise,
Sincerely yours,
e.m.
(*) I'm eventually exporting long maxima formulae to C code. So it's
important to me to expand vectors and matrices with a syntax
consistent with C indexing, and easily mapped (double m[][], v[];).