TIMES Matrix Multiply Operator
Section: Mathematical Operators
Usage
Multiplies two numerical arrays. This operator is really a combination of three operators, all of which have the same general syntax:y = a * b
where a and b are arrays of numerical type. The result y depends
on which of the following three situations applies to the arguments
a and b:
-
ais a scalar,bis an arbitraryn-dimensional numerical array, in which case the output is the element-wise product ofbwith the scalara. -
bis a scalar,ais an arbitraryn-dimensional numerical array, in which case the output is the element-wise product ofawith the scalarb. -
a,bare conformant matrices, i.e.,ais of sizeM x K, andbis of sizeK x N, in which case the output is of sizeM x Nand is the matrix product ofa, andb.
a and b are integers, the output is an integer also, while in the third case if a and b are integers, ,the output is of type double.
Function Internals
There are three formulae for the times operator. For the first form
and the second form
In the third form, the output is the matrix product of the arguments
Examples
Here are some examples of using the matrix multiplication operator. First, the scalar examples (types 1 and 2 from the list above):--> a = [1,3,4;0,2,1] a = 1 3 4 0 2 1 --> b = a * 2 b = 2 6 8 0 4 2 --> quit
The matrix form, where the first argument is 2 x 3, and the
second argument is 3 x 1, so that the product is size
2 x 1.
--> a = [1,2,0;4,2,3] a = 1 2 0 4 2 3 --> b = [5;3;1] b = 5 3 1 --> c = a*b c = 11 29 --> quit
Note that the output is double precision.
