Contents Previous Next Subchapters

Matrix Multiplication
Syntax left value * right value
See Also division addition subtraction , and element-by-element multiplication ,

Description
Matrix multiplication of two values that are integer, real, double-precision, or complex. (One, but not both, of the values may be logical.)

Tutorial

Multiplying Scalars
If you enter
     6 * 2
O-Matrix will respond
     12

Multiplying Matrices
If you enter
     x = {[1, 2, 3], [4, 5, 6]}
     y = {[2, 4], [2, 4], [2, 4]}
     x * y
O-Matrix will print
     {
     [ 12 , 24 ]
     [ 30 , 60 ]
     }

Multiplying Scalars by Matrices
If one value is a scalar and the other is a matrix, O-Matrix will multiply the scalar by each element of the matrix. Entering
     x = {[1, 2, 3], [4, 5, 6]}
     x * 2
will result in
     {
     [ 2 , 4 , 6 ]
     [ 8 , 10 , 12 ]
     }

Reference
If the value types do not agree, O-Matrix will coerce the values as detailed in the coercion table.

If one value is a scalar, the result has the same dimension as the other value. If neither value is a scalar, the column dimension of the left value must match the row dimension of the right value. In this case, the result has the same number of rows as the left value and the same number of columns as the right value.

If the column dimension of the left value is zero, the resulting matrix has all of its elements equal to zero. If you enter
     x = fill(1, 2, 0)
     y = fill(1, 0, 3)
     x * y
O-Matrix will respond
     {
     [ 0 , 0 , 0 ]
     [ 0 , 0 , 0 ]
     [ 0 , 0 , 0 ]
     }