Matrices (Maxima 5.44.0 Manual)

Next: Vectors, Previous: Dot, Up: Introduction to Matrices and Linear Algebra [Contents][Index]

#### 23.1.2 Matrices

Matrices are handled with speed and memory-efficiency in mind. This means that assigning a matrix to a variable will create a reference to, not a copy of the matrix. If the matrix is modified all references to the matrix point to the modified object (See `copymatrix` for a way of avoiding this):

    (%i1) M1:matrix([0,0],[0,0]);
                                [ 0  0 ]
    (%o1)                       [      ]
                                [ 0  0 ]

    (%i2) M2:M1;
                                [ 0  0 ]
    (%o2)                       [      ]
                                [ 0  0 ]

    (%i3) M1[1][1]:2;
    (%o3)                           2

    (%i4) M2;
                                [ 2  0 ]
    (%o4)                       [      ]
                                [ 0  0 ]

Converting a matrix to nested lists and vice versa works the following way:

    (%i1) l:[[1,2],[3,4]];
    (%o1)                   [[1, 2], [3, 4]]

    (%i2) M1:apply('matrix,l);
                                [ 1  2 ]
    (%o2)                       [      ]
                                [ 3  4 ]

    (%i3) M2:transpose(M1);
                                [ 1  3 ]
    (%o3)                       [      ]
                                [ 2  4 ]

    (%i4) args(M2);
    (%o4)                   [[1, 3], [2, 4]]

Next: Vectors, Previous: Dot, Up: Introduction to Matrices and Linear Algebra [Contents][Index]