*
Multiplication operator.
Syntax
expr_1 * expr_2
Operands
- expr_1, expr_2
- A pair of valid scalar, vector, or matrix expressions.
Example
Expression | Result |
---|---|
2 * 3 |
6 |
3 * {2, 3, 4} |
{6, 9, 12} |
3 * {{-5, -3, -1}, {1, 3, 5}} |
{ {-15, -9, -3}, {3, 9, 15} } |
{-5, -3, -1} * {1, 3, 5} |
{-5, -9, -5} |
{2, 3, 4} * {{-5, -3}{-1, 1}, {3,
5}} |
{-1, 17} |
{ {-5, -3, -1}, {1, 3, 5} } * { {-5, -3}, {-1, 1},
{3, 5} } |
{ {25, 7}, {7, 25} } |
Comments
The multiplication operator multiplies expr_1 and expr_2.
If expr_1 and expr_2 are scalars, the result is the product of expr_1 and expr_2.
If one of the expressions is a scalar and the other is a vector, each element in the vector is multiplied by the scalar. The result is a vector with the same number of elements as the original vector.
If one of the expressions is a scalar and the other is a matrix, each element in the matrix is multiplied by the scalar. The result is a matrix with the same dimensions as the original matrix.
If expr_1 and expr_2 are vectors, there are several possible results:
If expr_1 and expr_2 are row vectors with the same number of elements, each element of one vector is multiplied by the corresponding element of the other vector to produce an element of the resulting vector. The same holds true for two column vectors.
The product of a row and column vector with the same number of elements is a scalar. Each element of the row vector is multiplied by the corresponding column element, then all of the products are summed.
The product of a column and row vector with the same number of elements is a matrix. The first element of the column vector is multiplied by each element of the row vector to produce all of the elements of the first row of the resulting matrix. The second element of the column vector is multiplied by each element of the row vector, and so on.
If expr_1 and expr_2 are matrices, the result is a matrix containing the sum of the products of each row element in the first matrix and each column element of the second matrix. Multiplying an m x n matrix by an n x p matrix produces an m x p matrix. For example: a 7 x 2 matrix multiplied by a 2 x 4 matrix produces a 7 x 4 matrix. The number of columns of expr_1 must be the same as the number of rows of expr_2.