
A6.8 Expressions 145
A6.8.5 Multiplicative expressions
The operators .*., *, .*, * , /,and./ group left-to-right and require operands of
arithmetic type. A scalar consists of: int, double or 1 × 1 matrix. These operators
conform to Table A6.3, except for:
left a operator right b result computes
matrix m × n * matrix n × p matrix m × pa
i.
b
.k
matrix m × n .*. matrix p × q matrix mp × nq a
ij
b
scalar * matrix n × p matrix n × pab
ij
matrix m × n * scalar matrix m × na
ij
b
matrix m × n *~ matrix m × p matrix m × np a
1.
b...a
m.
b
matrix m × n / matrix m × p ≥ m matrix p × n solve bx = a
scalar / matrix m × n matrix m × na/b
ij
matrix m × n / scalar matrix m × na
ij
/b
scalar *.* scalar double a ∗ b
scalar /./ scalar double a/b
This implies that * .*. *~ are the same as .* when one or both arguments are scalar,
and similarly for / and verb./ when the right-hand operand is not a matrix.
Kronecker product is denoted by .*.. If neither operand is a matrix, this is identical
to normal multiplication. Direct (horizontal) multiplication is denoted by * .The
operands must have the same number of rows.
The binary * operator denotes multiplication. If both operands are a matrix and
neither is scalar, this is matrix multiplication and the number of columns of the first
operand has to be identical to the number of rows of the second operand.
The .* operator defines element by element multiplication. It is only different from
* if both operands are a matrix (these must have identical dimensions, however, if one
or both of the arguments is a 1 × 1 matrix, * is equal to .*).
The binary / operator denotes division. If either operand is a scalar, this is identical
to the element-by-element division performed by the ./ operator. If both operands are
matrices, then the result of a/b is x,wherex solves the linear system bx = a; a must
have the same number of rows as a. (Note the potential for confusion: more logical
would be to solve xb = a by a/b.) If b has the same number of columns as a,the
system is solved by a LU decomposition with pivoting; if b has more columns, it is
equivalent to a least squares problem (b
0
bx = b
0
a which is solved by the Choleski
decomposition of b
0
b (rather than the QR decomposition of b).
The ./ operator defines element by element division. If either argument is not a
matrix, this is identical to normal division. It is only different from / if both operands
are a non-scalar matrix, then both matrices must have identical dimensions.
Note that the result of dividing two integers is a double (3 / 2 gives 1.5). Multipli-
cation of two integers also returns a double.
Notice the difference between 2./ m2 and 2./m2. In the first case, the dot is
interpreted as part of the real number 2., whereas in the second case it is part of the
Commentaires sur ces manuels