Menu

#3396 Problem with matrix assignment

None
closed
nobody
matrix (9)
7
2018-02-11
2018-02-06
No

Not sure if it is a known bug or not. But, When I define a matrix, then assign it to another matrix and change the new matrix, the original (initial) matrix also changes! So, it shows some kind of pointer-like behavior.
For example:

(%i1) a : matrix([1,1],[1,1]);

                                   [ 1  1 ]
(%o1)                              [      ]
                                   [ 1  1 ]

(%i2) b : a;

                                   [ 1  1 ]
(%o2)                              [      ]
                                   [ 1  1 ]

(%i3) b[1,1] : 4;

(%o3)                                  4

(%i4) b;

                                   [ 4  1 ]
(%o4)                              [      ]
                                   [ 1  1 ]

(%i5) a;

                                   [ 4  1 ]
(%o5)                              [      ]
                                   [ 1  1 ]

Discussion

  • Gunter Königsmann

    I don't think this is a bug. Even if it definitively is odd: See the output of

    ? copymatrix;

     
  • Gunter Königsmann

    • status: open --> closed
     
  • Gunter Königsmann

    The manual of the next maxima release will contain a short section describing this phenomenon.

     
  • Resam Makvandi

    Resam Makvandi - 2018-02-11

    thanks a lot for the follow-up. I think it will be very helpful.

     

Log in to post a comment.