SGEMUL and DGEMUL can perform any one of the following matrix multiplications, using matrices A and B or their transposes, and matrix C:
C<--AB | C<--ABT |
|
C<--ATB | C<--ATBT |
|
CGEMUL and ZGEMUL can perform any one of the following matrix
multiplications, using matrices A and B, their
transposes or their conjugate transposes, and matrix C:
C<--AB | C<--ABT | C<--ABH |
C<--ATB | C<--ATBT | C<--ATBH |
C<--AHB | C<--AHBT | C<--AHBH |
A, B, C | Subroutine |
Short-precision real | SGEMUL |
Long-precision real | DGEMUL |
Short-precision complex | CGEMUL |
Long-precision complex | ZGEMUL |
Fortran | CALL SGEMUL | DGEMUL | CGEMUL | ZGEMUL (a, lda, transa, b, ldb, transb, c, ldc, l, m, n) |
C and C++ | sgemul | dgemul | cgemul | zgemul (a, lda, transa, b, ldb, transb, c, ldc, l, m, n); |
PL/I | CALL SGEMUL | DGEMUL | CGEMUL | ZGEMUL (a, lda, transa, b, ldb, transb, c, ldc, l, m, n); |
APL2 | SGEMUL | DGEMUL | CGEMUL | ZGEMUL a lda transa b ldb transb 'c' ldc l m n |
If transa = 'N', A is used in the computation, and A has l rows and m columns.
If transa = 'T', AT is used in the computation, and A has m rows and l columns.
If transa = 'C', AH is used in the computation, and A has m rows and l columns.
Specified as: a two-dimensional array, containing numbers of the data type indicated in Table 74, where:
If transa = 'N', its size must be lda by (at least) m.
If transa = 'T' or 'C', its size must be lda by (at least) l.
If transa = 'N', lda >= l.
If transa = 'T' or 'C', lda >= m.
If transa = 'N', A is used in the computation.
If transa = 'T', AT is used in the computation.
If transa = 'C', AH is used in the computation.
Specified as: a single character; transa = 'N' or 'T' for SGEMUL and DGEMUL; transa = 'N', 'T', or 'C' for CGEMUL and ZGEMUL.
If transb = 'N', B is used in the computation, and B has m rows and n columns.
If transb = 'T', BT is used in the computation, and B has n rows and m columns.
If transb = 'C', BH is used in the computation, and B has n rows and m columns.
Specified as: a two-dimensional array, containing numbers of the data type indicated in Table 74, where:
If transb = 'N', its size must be ldb by (at least) n.
If transb = 'T' or 'C', its size must be ldb by (at least) m.
If transb = 'N', ldb >= m.
If transb = 'T' or 'C', ldb >= n.
If transb = 'N', B is used in the computation.
If transb = 'T', BT is used in the computation.
If transb = 'C', BH is used in the computation.
Specified as: a single character; transb = 'N' or 'T' for SGEMUL and DGEMUL; transb = 'N', 'T', or 'C' for CGEMUL and ZGEMUL.
If transa = 'N', it is the number of columns in matrix A.
If transa = 'T' or 'C', it is the number of rows in matrix A.
In addition:
If transb = 'N', it is the number of rows in matrix B.
If transb = 'T' or 'C', it is the number of columns in matrix B.
Specified as: a fullword integer; m >= 0.
The matrix multiplication is expressed as follows, where aik, bkj, and cij are elements of matrices A, B, and C, respectively:
See reference [38]. If l or n is 0, no computation is performed. If l and n are greater than 0, and m is 0, an l by n matrix of zeros is returned.
By using the following equivalence rules, you can compute the transpose
CT or the conjugate transpose CH
of some of the computations performed by these subroutines:
Transpose | Conjugate Transpose |
---|---|
(AB)T = BTAT | (AB)H = BHAH |
(ATB)T = BTA | (AHB)H = BHA |
(ABT)T = BAT | (ABH)H = BAH |
(ATBT)T = BA | (AHBH)H = BA |
When coding the calling sequences for these cases, be careful to code your matrix arguments and dimension arguments in the order indicated by the rule. Also, be careful that your output array, receiving CT or CH, has dimensions large enough to hold the resulting transposed or conjugate transposed matrix. See Example 2 and Example 4.
Unable to allocate internal work area (CGEMUL and ZGEMUL only).
None
This example shows the computation C<--AB, where A, B, and C are contained in larger arrays A, B, and C, respectively.
A LDA TRANSA B LDB TRANSB C LDC L M N | | | | | | | | | | | CALL SGEMUL( A , 8 , 'N' , B , 6 , 'N' , C , 7 , 6 , 5 , 4 )
* * | 1.0 2.0 -1.0 -1.0 4.0 | | 2.0 0.0 1.0 1.0 -1.0 | | 1.0 -1.0 -1.0 1.0 2.0 | A = | -3.0 2.0 2.0 2.0 0.0 | | 4.0 0.0 -2.0 1.0 -1.0 | | -1.0 -1.0 1.0 -3.0 2.0 | | . . . . . | | . . . . . | * *
* * | 1.0 -1.0 0.0 2.0 | | 2.0 2.0 -1.0 -2.0 | B = | 1.0 0.0 -1.0 1.0 | | -3.0 -1.0 1.0 -1.0 | | 4.0 2.0 -1.0 1.0 | | . . . . | * *
* * | 23.0 12.0 -6.0 2.0 | | -4.0 -5.0 1.0 3.0 | | 3.0 0.0 1.0 4.0 | C = | -3.0 5.0 -2.0 -10.0 | | -5.0 -7.0 4.0 4.0 | | 15.0 6.0 -5.0 6.0 | | . . . . | * *
This example shows how to produce the transpose of the result of the computation performed in Example 1, C<--AB, which uses the calling sequence:
CALL SGEMUL (A,8,'N',B,6,'N',C,7,6,5,4)
You instead code a calling sequence for CT<--BTAT, as shown below, where the resulting matrix CT in the output array CT is the transpose of the matrix in the output array C in Example 1. Note that the array CT has dimensions large enough to receive the transposed matrix. For a description of all the matrix identities, see Special Usage.
A LDA TRANSA B LDB TRANSB C LDC L M N | | | | | | | | | | | CALL SGEMUL( B , 6 , 'T' , A , 8 , 'T' , CT , 5 , 4 , 5 , 6 )
* * | 1.0 -1.0 0.0 2.0 | | 2.0 2.0 -1.0 -2.0 | B = | 1.0 0.0 -1.0 1.0 | | -3.0 -1.0 1.0 -1.0 | | 4.0 2.0 -1.0 1.0 | | . . . . | * *
* * | 1.0 2.0 -1.0 -1.0 4.0 | | 2.0 0.0 1.0 1.0 -1.0 | | 1.0 -1.0 -1.0 1.0 2.0 | A = | -3.0 2.0 2.0 2.0 0.0 | | 4.0 0.0 -2.0 1.0 -1.0 | | -1.0 -1.0 1.0 -3.0 2.0 | | . . . . . | | . . . . . | * *
* * | 23.0 -4.0 3.0 -3.0 -5.0 15.0 | | 12.0 -5.0 0.0 5.0 -7.0 6.0 | CT = | -6.0 1.0 1.0 -2.0 4.0 -5.0 | | 2.0 3.0 4.0 -10.0 4.0 6.0 | | . . . . . . | * *
This example shows the computation C<--ATB, where A and C are contained in larger arrays A and C, respectively, and B is the same size as the
A LDA TRANSA B LDB TRANSB C LDC L M N | | | | | | | | | | | CALL SGEMUL( A , 4 , 'T' , B , 3 , 'N' , C , 5 , 3 , 3 , 6 )
* * | 1.0 -3.0 2.0 | A = | 2.0 4.0 0.0 | | 1.0 -1.0 -1.0 | | . . . | * *
* * | 1.0 -3.0 2.0 2.0 -1.0 2.0 | B = | 2.0 4.0 0.0 0.0 1.0 -2.0 | | 1.0 -1.0 -1.0 -1.0 -1.0 1.0 | * *
* * | 6.0 4.0 1.0 1.0 0.0 -1.0 | | 4.0 26.0 -5.0 -5.0 8.0 -15.0 | C = | 1.0 -5.0 5.0 5.0 -1.0 3.0 | | . . . . . . | | . . . . . . | * *
This example shows how to produce the transpose of the result of the computation performed in Example 3, C<--ATB, which uses the calling sequence:
CALL SGEMUL (A,4,'T',B,3,'N',C,5,3,3,6)
You instead code the calling sequence for CT<--BTA, as shown below, where the resulting matrix CT in the output array CT is the transpose of the matrix in the output array C in Example 3. Note that the array CT has dimensions large enough to receive the transposed matrix. For a description of all the matrix identities, see Special Usage.
A LDA TRANSA B LDB TRANSB C LDC L M N | | | | | | | | | | | CALL SGEMUL( B , 3 , 'T' , A , 4 , 'N' , CT , 8 , 6 , 3 , 3 )
* * | 1.0 -3.0 2.0 2.0 -1.0 2.0 | B = | 2.0 4.0 0.0 0.0 1.0 -2.0 | | 1.0 -1.0 -1.0 -1.0 -1.0 1.0 | * *
* * | 1.0 -3.0 2.0 | A = | 2.0 4.0 0.0 | | 1.0 -1.0 -1.0 | | . . . | * *
* * | 6.0 4.0 1.0 | | 4.0 26.0 -5.0 | | 1.0 -5.0 5.0 | CT = | 1.0 -5.0 5.0 | | 0.0 8.0 -1.0 | | -1.0 -15.0 3.0 | | . . . | | . . . | * *
This example shows the computation C<--ABT, where A and C are contained in larger arrays A and C, respectively, and B is the same size as the array B in which it is contained.
A LDA TRANSA B LDB TRANSB C LDC L M N | | | | | | | | | | | CALL SGEMUL( A , 4 , 'N' , B , 3 , 'T' , C , 5 , 3 , 2 , 3 )
* * | 1.0 -3.0 | A = | 2.0 4.0 | | 1.0 -1.0 | | . . | * *
* * | 1.0 -3.0 | B = | 2.0 4.0 | | 1.0 -1.0 | * *
* * | 10.0 -10.0 4.0 | | -10.0 20.0 -2.0 | C = | 4.0 -2.0 2.0 | | . . . | | . . . | * *
This example shows the computation C<--ATBT, where A, B, and C are the same size as the arrays A, B, and C in which they are contained. (Based on the dimensions of the matrices, A is actually a column vector, and C is actually a row vector.)
A LDA TRANSA B LDB TRANSB C LDC L M N | | | | | | | | | | | CALL SGEMUL( A , 3 , 'T' , B , 3 , 'T' , C , 1 , 1 , 3 , 3 )
* * | 1.0 | A = | 2.0 | | 1.0 | * *
* * | 1.0 -3.0 2.0 | B = | 2.0 4.0 0.0 | | 1.0 -1.0 -1.0 | * *
* * B = | -3.0 10.0 -2.0 | * *
This example shows the computation C<--ATB using complex data, where A, B, and C are contained in larger arrays A, B, and C, respectively.
A LDA TRANSA B LDB TRANSB C LDC L M N | | | | | | | | | | | CALL CGEMUL( A , 6 , 'T' , B , 7 , 'N' , C , 3 , 2 , 3 , 3 )
* * | (1.0, 2.0) (3.0, 4.0) | | (4.0, 6.0) (7.0, 1.0) | A = | (6.0, 3.0) (2.0, 5.0) | | . . | | . . | | . . | * *
* * | (1.0, 9.0) (2.0, 6.0) (5.0, 6.0) | | (2.0, 5.0) (6.0, 2.0) (6.0, 4.0) | | (2.0, 6.0) (5.0, 4.0) (2.0, 6.0) | B = | . . . | | . . . | | . . . | | . . . | * *
* * | (-45.0, 85.0) (20.0, 93.0) (-13.0, 110.0) | C = | (-50.0, 90.0) (12.0, 79.0) (3.0, 94.0) | | . . . | * *
This example shows the computation C<--ABH using complex data, where A and C are contained in larger arrays A and C, respectively, and B is the same size as the array B in which it is contained.
A LDA TRANSA B LDB TRANSB C LDC L M N | | | | | | | | | | | CALL CGEMUL( A , 4 , 'N' , B , 3 , 'C' , C , 4 , 3 , 2 , 3 )
* * | (1.0, 2.0) (-3.0, 2.0) | A = | (2.0, 6.0) (4.0, 5.0) | | (1.0, 2.0) (-1.0, 8.0) | | . . | * *
* * | (1.0, 3.0) (-3.0, 2.0) | B = | (2.0, 5.0) (4.0, 6.0) | | (1.0, 1.0) (-1.0, 9.0) | * *
* * | (20.0, -1.0) (12.0, 25.0) (24.0, 26.0) | C = | (18.0, -23.0) (80.0, -2.0) (49.0, -37.0) | | (26.0, -23.0) (56.0, 37.0) (76.0, 2.0) | | . . . | * *