#657 addrow creates strange matrix

closed
nobody
Lisp Core (471)
5
2010-05-13
2004-12-22
Anonymous
No

The following commands show problems with addrow:

(%i260) m : matrix([0, 0]);

(%o260) [ 0 0 ]
(%i261) m : addrow(m, m);

                             \[ 0  0 \]

(%o261) [ ]
[ 0 0 ]
(%i262) m[1, 1] : 10;

(%o262) 10
(%i263) m;
[ 10 0 ]
(%o263) [ ]
[ 10 0 ]

i.e. two elements, instead of one are modified!

Maxima information:

Maxima version: 5.9.1
Maxima build date: 7:34 9/24/2004
host type: i686-pc-mingw32
lisp-implementation-type: Kyoto Common Lisp
lisp-implementation-version: GCL 2.6.5

----

Ola Dahl
ola.dahl@ts.mah.se

Discussion

  • Robert Dodier

    Robert Dodier - 2004-12-31

    Logged In: YES
    user_id=501686

    It appears that addrow copies a reference to the new rows,
    instead of copying the rows. I would suggest that copying
    the rows is more generally useful, but at present addrow
    appears to function as intended.

    Another example which shows that a change to a row changes
    the matrix returned by addrow:

    (%i8) m1:[0,0];
    (%o8) [0, 0]
    (%i9) m2:[0,0];
    (%o9) [0, 0]
    (%i10) m: matrix([0,0]);
    (%o10) [ 0 0 ]
    (%i11) n: addrow(m,m1,m2);
    [ 0 0 ]
    [ ]
    (%o11) [ 0 0 ]
    [ ]
    [ 0 0 ]
    (%i12) m1[2]:12;
    (%o12) 12
    (%i13) m2[1]:21;
    (%o13) 21
    (%i14) m;
    (%o14) [ 0 0 ]
    (%i15) n;
    [ 0 0 ]
    [ ]
    (%o15) [ 0 12 ]
    [ ]
    [ 21 0 ]
    (%i16) m[1,1]:11;
    (%o16) 11
    (%i17) n;
    [ 11 0 ]
    [ ]
    (%o17) [ 0 12 ]
    [ ]
    [ 21 0 ]

     
  • Robert Dodier

    Robert Dodier - 2004-12-31
    • labels: --> Lisp Core
     
  • Robert Dodier

    Robert Dodier - 2006-08-02

    Logged In: YES
    user_id=501686

    The stuff I wrote before, "at present addrow appears to
    function as intended" is just wishful thinking. This is a
    bug. Should be easy to fix.

     
  • Dieter Kaiser

    Dieter Kaiser - 2010-05-13

    Fixed in comm2.lisp revision 1.35.
    Closing this bug report as fixed.
    Dieter Kaiser

     
  • Dieter Kaiser

    Dieter Kaiser - 2010-05-13
    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks