Purpose
Performs a matrix multiplication.
Class
Transformational function
Argument Type and Attributes
- MATRIX_A
- is an array with a rank of one or two and a numeric or logical data
type.
- MATRIX_B
- is an array with a rank of one or two and a numeric or logical data
type. It can be a different numeric type than MATRIX_A, but
you cannot use one numeric matrix and one logical
matrix.
+-------------------------------IBM Extension--------------------------------+
- MINDIM (optional)
- is an integer that determines whether to do the matrix
multiplication using the Winograd variation of the Strassen algorithm, which
may be faster for large matrices. The algorithm recursively splits the
operand matrices into four roughly equal parts, until any submatrix extent is
less than MINDIM.
- Note:
- Strassen's method is not stable for certain row or column scalings of
the input matrices. Therefore, for MATRIX_A and
MATRIX_B with divergent exponent values, Strassen's method may
give inaccurate results.
The significance of the value of MINDIM is:
- <=0
- does not use the Strassen algorithm at all. This is the
default.
- 1
- is reserved for future use.
- >1
- recursively applies the Strassen algorithm as long as the smallest extent
of all dimensions in the argument arrays is greater than or equal to this
value. To achieve optimal performance you should experiment with the
value of MINDIM as the optimal value depends on your machine
configuration, available memory, and the size, type, and kind type of the
arrays.
By default, MATMUL employs the conventional O(N**3) method
of matrix multiplication.
If you link the libpthreads.a library, the Winograd variation of the O(N**2.81) Strassen
method is employed under these conditions:
- MATRIX_A and MATRIX_B are both integer, real, or
complex and have the same kind.
- The program can allocate the needed temporary storage, enough to
hold approximately (2/3)*(N**2) elements for square matrices of extent
N.
- The MINDIM argument is less than or equal to the smallest
of all extents of MATRIX_A and MATRIX_B.
+----------------------------End of IBM Extension----------------------------+
At least one of the arguments must be of rank two. The size of the
first or only dimension of MATRIX_B must be equal to the last or only
dimension of MATRIX_A.
Result Value
The result is an array. If one of the arguments is of rank one, the
result has a rank of one. If both arguments are of rank two, the result
has a rank of two.
The data type of the result depends on the data type of the arguments,
according to the rules in Table 7 and Table 8.
If MATRIX_A and MATRIX_B have a numeric data type, the
array elements of the result are:
- Value of Element (i,j) = SUM( (row i of MATRIX_A) *
(column j of MATRIX_B) )
If MATRIX_A and MATRIX_B are of type logical, the array
elements of the result are:
- Value of Element (i,j) = ANY( (row i of MATRIX_A)
.AND. (column j of MATRIX_B) )
Examples
! A is the array | 1 2 3 |, B is the array | 7 10 |
! | 4 5 6 | | 8 11 |
! | 9 12 |
RES = MATMUL(A, B)
! The result is | 50 68 |
! | 122 167 |
+-------------------------------IBM Extension--------------------------------+
! HUGE_ARRAY and GIGANTIC_ARRAY in this example are
! large arrays of real or complex type, so the operation
! might be faster with the Strassen algorithm.
RES = MATMUL(HUGE_ARRAY, GIGANTIC_ARRAY, MINDIM=196)
+----------------------------End of IBM Extension----------------------------+
+-------------------------------IBM Extension--------------------------------+
Related Information
The numerical stability of Strassen's method for matrix multiplication
is discussed in:
- "Exploiting Fast Matrix Multiplication Within the Level 3 BLAS",
Nicholas J. Higham, ACM Transactions on
Mathematical Software, Vol. 16, No. 4, December
1990.
- "GEMMW: A portable level 3 BLAS Winograd variant of
Strassen's matrix-matrix multiply algorithm", Douglas, C.
C., Heroux, M., Slishman, G., and Smith, R.
M., Journal of Computational Physics,
Vol. 110, No. 1, January 1994, pages 1-10.
+----------------------------End of IBM Extension----------------------------+
