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
:

a
is a scalar,b
is an arbitraryn
dimensional numerical array, in which case the output is the elementwise product ofb
with the scalara
. 
b
is a scalar,a
is an arbitraryn
dimensional numerical array, in which case the output is the elementwise product ofa
with the scalarb
. 
a,b
are conformant matrices, i.e.,a
is of sizeM x K
, andb
is of sizeK x N
, in which case the output is of sizeM x N
and is the matrix product ofa
, andb
.
double
and single
.
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
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
Note that the output is double precision.