## #14 strange values in matrix calc within user's function

closed
nobody
None
5
2009-04-18
2009-03-19
Anonymous
No

from jardakau@internode.on.net (Jaroslav Kautsky)

Having migrated from maple to maxima I am learning how to
do matrix calculations. I encountered an error I can not
explain. The statement does what I expect from the
maxima prompt but not in the function.

Details in the enclosed file.

I apologize in advance if it is my ignorance.

- - - - - - - - - - - - -
Dr. Jaroslav Kautsky Phone : +61-8-8201 2360
School of Comp. Sc., Eng. and Math.Mobile: 0414 190 109
Flinders University FAX : +61-8-8201 2904
GPO Box 2100
ADELAIDE SA 5001, Australia email: jarka@ist.flinders.edu.au
WWW: http://csem.flinders.edu.au/people/pages/kautsky_jerry/

## Discussion

• Nobody/Anonymous - 2009-03-19

contains output with the problem and info on system

• Robert Dodier - 2009-03-20

Well, the only possible problem I see is this:

(%i3) mL2mJ(lL) := block([ll,ln:length(lL),len,lS,lJ],
ll:row(lL,ln), lL:submatrix(ln,lL).
ln:ln-1,lS:mkS(ln),len:ematrix(ln,1,1,ln,1),
lJ:(lL.lS-len.ll).(lL^^-1),lL)\$

Did you mean to put a comma instead of a period after submatrix(ln,lL) ??
As it stands, the effect is to multiply the submatrix result by ln - 1.

In this case it doesn't appear to be a problem but bear in mind that the functions submatrix and row return objects which share memory with the original matrix, not new objects. So if an assignment is made to some element of the matrix returned by submatrix or row, it changes the original matrix. You can work around this bug/feature by the copy function, e.g. my_new_submatrix : copy (submatrix (...)) which creates a new object.

Most of the traffic for Maxima problems is carried by the Maxima mailing list. If you have further questions you can post them there. See: http://maxima.sourceforge.net/maximalist.html

Hope this helps!

Robert Dodier

• Robert Dodier - 2009-04-18
• status: open --> closed