Matrix objects (2)

For matrix objects, the * operator means matrix-matrix or matrix-vector multiplication (not elementwise multiplication)
>>> A = eye(3)                    # identity matrix
>>> A = mat(A)                    # turn array to matrix
>>> A
matrix([[ 1.,  0.,  0.],
        [ 0.,  1.,  0.],
        [ 0.,  0.,  1.]])
>>> y2 = x2*A                     # vector-matrix product
>>> y2
matrix([[ 1.,  2.,  3.]])
>>> y3 = A*x3                     # matrix-vector product
>>> y3
matrix([[ 1.],
        [ 2.],
        [ 3.]])

previousnexttable of contents