If one of A and B is a scalar and the other is a matrix, the result is a matrix of the same size, whose entries are the products of the value of the scalar and the entries of the matrix. For example
>> x = 2; >> y = -9; >> x * y -18 >> A = [3, 5; 2, -8]; >> 3 * A 9 15 6 -24 >> A * 7 21 35 14 -56
If A and B are non-scalar matrices, then A * B is the matrix multiplication of A and B. This is defined only when the sizes of A and B match, i.e., the number of columns of A equals the number of rows of B. For example
>> A = [3, 5; 2, -8; 1, 9]; 3 5 2 -8 1 9 >> B = [2, 1, 7; -2, 0, 8] 2 1 7 -2 0 8 >> A * B -4 3 61 20 2 -50 -16 1 79 >> B * A 15 65 2 62Attempt to multiply matrices whose sizes do not match will cause an error.
If A and B are two lists with the same length , then A * B is the dot product (A#1) * (B#1) + (A#2) * (B#2) + ... + (A#n) * (B#n).
If B is a list with length , and A is a list whose length is and whose each element is again a list with the same length , then A * B is the list of length : ((A#1)*B, (A#2)*B, ..., (A#n)*B).
oz 2009-12-22