## 9.3.93 MATMUL (MATRIX_A, MATRIX_B)

 Description: Performs matrix multiplication of numeric or logical matrices. Class: Transformational function; Generic Arguments: MATRIX_A Must be an array of rank one or two. It must be of numeric (integer, real, or complex) or logical type. MATRIX_B Must be an array of rank one or two. It must be of numeric type if MATRIX_A is of numeric type or logical type if MATRIX_A is logical type. At least one argument must be of rank two. The size of the first (or only) dimension of MATRIX_B must equal the size of the last (or only) dimension of MATRIX_A. Results: The result is an array whose type depends on the data type of the arguments, according to the rules shown in Table 4-2. The rank and shape of the result depends on the rank and shapes of the arguments, as follows: If MATRIX_A has shape (n, m) and MATRIX_B has shape (m, k), the result is a rank-two array with shape (n, k). If MATRIX_A has shape (m) and MATRIX_B has shape (m, k), the result is a rank-one array with shape (k). If MATRIX_A has shape (n, m) and MATRIX_B has shape (m), the result is a rank-one array with shape (n). If the arguments are of numeric type, element (i, j) of the result has the value SUM ((row i of MATRIX_A) * (column j of MATRIX_B)). If the arguments are of logical type, element (i, j) of the result has the value ANY ((row i of MATRIX_A) .AND. (column j of MATRIX_B)).

Examples

A is matrix

``````  [ 2  3  4 ]
[ 3  4  5 ],
``````
B is matrix
``````  [ 2  3 ]
[ 3  4 ]
[ 4  5 ],
``````
X is vector (1, 2), and Y is vector (1, 2, 3).

The result of MATMUL (A, B) is the matrix-matrix product AB with the value

``````  [ 29  38 ]
[ 38  50 ].
``````

The result of MATMUL (X, A) is the vector-matrix product XA with the value (8, 11, 14).

The result of MATMUL (A, Y) is the matrix-vector product AY with the value (20, 26).