|
kusano |
2b45e8 |
SUBROUTINE CHEMMF ( SIDE, UPLO, M, N, ALPHA, A, LDA, B, LDB,
|
|
kusano |
2b45e8 |
$ BETA, C, LDC )
|
|
kusano |
2b45e8 |
* .. Scalar Arguments ..
|
|
kusano |
2b45e8 |
CHARACTER*1 SIDE, UPLO
|
|
kusano |
2b45e8 |
INTEGER M, N, LDA, LDB, LDC
|
|
kusano |
2b45e8 |
COMPLEX ALPHA, BETA
|
|
kusano |
2b45e8 |
* .. Array Arguments ..
|
|
kusano |
2b45e8 |
COMPLEX A( LDA, * ), B( LDB, * ), C( LDC, * )
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Purpose
|
|
kusano |
2b45e8 |
* =======
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* CHEMM performs one of the matrix-matrix operations
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* C := alpha*A*B + beta*C,
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* or
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* C := alpha*B*A + beta*C,
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* where alpha and beta are scalars, A is an hermitian matrix and B and
|
|
kusano |
2b45e8 |
* C are m by n matrices.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Parameters
|
|
kusano |
2b45e8 |
* ==========
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* SIDE - CHARACTER*1.
|
|
kusano |
2b45e8 |
* On entry, SIDE specifies whether the hermitian matrix A
|
|
kusano |
2b45e8 |
* appears on the left or right in the operation as follows:
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* SIDE = 'L' or 'l' C := alpha*A*B + beta*C,
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* SIDE = 'R' or 'r' C := alpha*B*A + beta*C,
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* UPLO - CHARACTER*1.
|
|
kusano |
2b45e8 |
* On entry, UPLO specifies whether the upper or lower
|
|
kusano |
2b45e8 |
* triangular part of the hermitian matrix A is to be
|
|
kusano |
2b45e8 |
* referenced as follows:
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* UPLO = 'U' or 'u' Only the upper triangular part of the
|
|
kusano |
2b45e8 |
* hermitian matrix is to be referenced.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* UPLO = 'L' or 'l' Only the lower triangular part of the
|
|
kusano |
2b45e8 |
* hermitian matrix is to be referenced.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* M - INTEGER.
|
|
kusano |
2b45e8 |
* On entry, M specifies the number of rows of the matrix C.
|
|
kusano |
2b45e8 |
* M must be at least zero.
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* N - INTEGER.
|
|
kusano |
2b45e8 |
* On entry, N specifies the number of columns of the matrix C.
|
|
kusano |
2b45e8 |
* N must be at least zero.
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* ALPHA - COMPLEX .
|
|
kusano |
2b45e8 |
* On entry, ALPHA specifies the scalar alpha.
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* A - COMPLEX array of DIMENSION ( LDA, ka ), where ka is
|
|
kusano |
2b45e8 |
* m when SIDE = 'L' or 'l' and is n otherwise.
|
|
kusano |
2b45e8 |
* Before entry with SIDE = 'L' or 'l', the m by m part of
|
|
kusano |
2b45e8 |
* the array A must contain the hermitian matrix, such that
|
|
kusano |
2b45e8 |
* when UPLO = 'U' or 'u', the leading m by m upper triangular
|
|
kusano |
2b45e8 |
* part of the array A must contain the upper triangular part
|
|
kusano |
2b45e8 |
* of the hermitian matrix and the strictly lower triangular
|
|
kusano |
2b45e8 |
* part of A is not referenced, and when UPLO = 'L' or 'l',
|
|
kusano |
2b45e8 |
* the leading m by m lower triangular part of the array A
|
|
kusano |
2b45e8 |
* must contain the lower triangular part of the hermitian
|
|
kusano |
2b45e8 |
* matrix and the strictly upper triangular part of A is not
|
|
kusano |
2b45e8 |
* referenced.
|
|
kusano |
2b45e8 |
* Before entry with SIDE = 'R' or 'r', the n by n part of
|
|
kusano |
2b45e8 |
* the array A must contain the hermitian matrix, such that
|
|
kusano |
2b45e8 |
* when UPLO = 'U' or 'u', the leading n by n upper triangular
|
|
kusano |
2b45e8 |
* part of the array A must contain the upper triangular part
|
|
kusano |
2b45e8 |
* of the hermitian matrix and the strictly lower triangular
|
|
kusano |
2b45e8 |
* part of A is not referenced, and when UPLO = 'L' or 'l',
|
|
kusano |
2b45e8 |
* the leading n by n lower triangular part of the array A
|
|
kusano |
2b45e8 |
* must contain the lower triangular part of the hermitian
|
|
kusano |
2b45e8 |
* matrix and the strictly upper triangular part of A is not
|
|
kusano |
2b45e8 |
* referenced.
|
|
kusano |
2b45e8 |
* Note that the imaginary parts of the diagonal elements need
|
|
kusano |
2b45e8 |
* not be set, they are assumed to be zero.
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* LDA - INTEGER.
|
|
kusano |
2b45e8 |
* On entry, LDA specifies the first dimension of A as declared
|
|
kusano |
2b45e8 |
* in the calling (sub) program. When SIDE = 'L' or 'l' then
|
|
kusano |
2b45e8 |
* LDA must be at least max( 1, m ), otherwise LDA must be at
|
|
kusano |
2b45e8 |
* least max( 1, n ).
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* B - COMPLEX array of DIMENSION ( LDB, n ).
|
|
kusano |
2b45e8 |
* Before entry, the leading m by n part of the array B must
|
|
kusano |
2b45e8 |
* contain the matrix B.
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* LDB - INTEGER.
|
|
kusano |
2b45e8 |
* On entry, LDB specifies the first dimension of B as declared
|
|
kusano |
2b45e8 |
* in the calling (sub) program. LDB must be at least
|
|
kusano |
2b45e8 |
* max( 1, m ).
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* BETA - COMPLEX .
|
|
kusano |
2b45e8 |
* On entry, BETA specifies the scalar beta. When BETA is
|
|
kusano |
2b45e8 |
* supplied as zero then C need not be set on input.
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* C - COMPLEX array of DIMENSION ( LDC, n ).
|
|
kusano |
2b45e8 |
* Before entry, the leading m by n part of the array C must
|
|
kusano |
2b45e8 |
* contain the matrix C, except when beta is zero, in which
|
|
kusano |
2b45e8 |
* case C need not be set on entry.
|
|
kusano |
2b45e8 |
* On exit, the array C is overwritten by the m by n updated
|
|
kusano |
2b45e8 |
* matrix.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* LDC - INTEGER.
|
|
kusano |
2b45e8 |
* On entry, LDC specifies the first dimension of C as declared
|
|
kusano |
2b45e8 |
* in the calling (sub) program. LDC must be at least
|
|
kusano |
2b45e8 |
* max( 1, m ).
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Level 3 Blas routine.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* -- Written on 8-February-1989.
|
|
kusano |
2b45e8 |
* Jack Dongarra, Argonne National Laboratory.
|
|
kusano |
2b45e8 |
* Iain Duff, AERE Harwell.
|
|
kusano |
2b45e8 |
* Jeremy Du Croz, Numerical Algorithms Group Ltd.
|
|
kusano |
2b45e8 |
* Sven Hammarling, Numerical Algorithms Group Ltd.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* .. External Functions ..
|
|
kusano |
2b45e8 |
LOGICAL LSAME
|
|
kusano |
2b45e8 |
EXTERNAL LSAME
|
|
kusano |
2b45e8 |
* .. External Subroutines ..
|
|
kusano |
2b45e8 |
EXTERNAL XERBLA
|
|
kusano |
2b45e8 |
* .. Intrinsic Functions ..
|
|
kusano |
2b45e8 |
INTRINSIC CONJG, MAX, REAL
|
|
kusano |
2b45e8 |
* .. Local Scalars ..
|
|
kusano |
2b45e8 |
LOGICAL UPPER
|
|
kusano |
2b45e8 |
INTEGER I, INFO, J, K, NROWA
|
|
kusano |
2b45e8 |
COMPLEX TEMP1, TEMP2
|
|
kusano |
2b45e8 |
* .. Parameters ..
|
|
kusano |
2b45e8 |
COMPLEX ONE
|
|
kusano |
2b45e8 |
PARAMETER ( ONE = ( 1.0E+0, 0.0E+0 ) )
|
|
kusano |
2b45e8 |
COMPLEX ZERO
|
|
kusano |
2b45e8 |
PARAMETER ( ZERO = ( 0.0E+0, 0.0E+0 ) )
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Executable Statements ..
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Set NROWA as the number of rows of A.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF( LSAME( SIDE, 'L' ) )THEN
|
|
kusano |
2b45e8 |
NROWA = M
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
NROWA = N
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
UPPER = LSAME( UPLO, 'U' )
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Test the input parameters.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
INFO = 0
|
|
kusano |
2b45e8 |
IF( ( .NOT.LSAME( SIDE, 'L' ) ).AND.
|
|
kusano |
2b45e8 |
$ ( .NOT.LSAME( SIDE, 'R' ) ) )THEN
|
|
kusano |
2b45e8 |
INFO = 1
|
|
kusano |
2b45e8 |
ELSE IF( ( .NOT.UPPER ).AND.
|
|
kusano |
2b45e8 |
$ ( .NOT.LSAME( UPLO, 'L' ) ) )THEN
|
|
kusano |
2b45e8 |
INFO = 2
|
|
kusano |
2b45e8 |
ELSE IF( M .LT.0 )THEN
|
|
kusano |
2b45e8 |
INFO = 3
|
|
kusano |
2b45e8 |
ELSE IF( N .LT.0 )THEN
|
|
kusano |
2b45e8 |
INFO = 4
|
|
kusano |
2b45e8 |
ELSE IF( LDA.LT.MAX( 1, NROWA ) )THEN
|
|
kusano |
2b45e8 |
INFO = 7
|
|
kusano |
2b45e8 |
ELSE IF( LDB.LT.MAX( 1, M ) )THEN
|
|
kusano |
2b45e8 |
INFO = 9
|
|
kusano |
2b45e8 |
ELSE IF( LDC.LT.MAX( 1, M ) )THEN
|
|
kusano |
2b45e8 |
INFO = 12
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
IF( INFO.NE.0 )THEN
|
|
kusano |
2b45e8 |
CALL XERBLA( 'CHEMM3M', INFO )
|
|
kusano |
2b45e8 |
RETURN
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Quick return if possible.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF( ( M.EQ.0 ).OR.( N.EQ.0 ).OR.
|
|
kusano |
2b45e8 |
$ ( ( ALPHA.EQ.ZERO ).AND.( BETA.EQ.ONE ) ) )
|
|
kusano |
2b45e8 |
$ RETURN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* And when alpha.eq.zero.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF( ALPHA.EQ.ZERO )THEN
|
|
kusano |
2b45e8 |
IF( BETA.EQ.ZERO )THEN
|
|
kusano |
2b45e8 |
DO 20, J = 1, N
|
|
kusano |
2b45e8 |
DO 10, I = 1, M
|
|
kusano |
2b45e8 |
C( I, J ) = ZERO
|
|
kusano |
2b45e8 |
10 CONTINUE
|
|
kusano |
2b45e8 |
20 CONTINUE
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
DO 40, J = 1, N
|
|
kusano |
2b45e8 |
DO 30, I = 1, M
|
|
kusano |
2b45e8 |
C( I, J ) = BETA*C( I, J )
|
|
kusano |
2b45e8 |
30 CONTINUE
|
|
kusano |
2b45e8 |
40 CONTINUE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
RETURN
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Start the operations.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF( LSAME( SIDE, 'L' ) )THEN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Form C := alpha*A*B + beta*C.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF( UPPER )THEN
|
|
kusano |
2b45e8 |
DO 70, J = 1, N
|
|
kusano |
2b45e8 |
DO 60, I = 1, M
|
|
kusano |
2b45e8 |
TEMP1 = ALPHA*B( I, J )
|
|
kusano |
2b45e8 |
TEMP2 = ZERO
|
|
kusano |
2b45e8 |
DO 50, K = 1, I - 1
|
|
kusano |
2b45e8 |
C( K, J ) = C( K, J ) + TEMP1*A( K, I )
|
|
kusano |
2b45e8 |
TEMP2 = TEMP2 +
|
|
kusano |
2b45e8 |
$ B( K, J )*CONJG( A( K, I ) )
|
|
kusano |
2b45e8 |
50 CONTINUE
|
|
kusano |
2b45e8 |
IF( BETA.EQ.ZERO )THEN
|
|
kusano |
2b45e8 |
C( I, J ) = TEMP1*REAL( A( I, I ) ) +
|
|
kusano |
2b45e8 |
$ ALPHA*TEMP2
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
C( I, J ) = BETA *C( I, J ) +
|
|
kusano |
2b45e8 |
$ TEMP1*REAL( A( I, I ) ) +
|
|
kusano |
2b45e8 |
$ ALPHA*TEMP2
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
60 CONTINUE
|
|
kusano |
2b45e8 |
70 CONTINUE
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
DO 100, J = 1, N
|
|
kusano |
2b45e8 |
DO 90, I = M, 1, -1
|
|
kusano |
2b45e8 |
TEMP1 = ALPHA*B( I, J )
|
|
kusano |
2b45e8 |
TEMP2 = ZERO
|
|
kusano |
2b45e8 |
DO 80, K = I + 1, M
|
|
kusano |
2b45e8 |
C( K, J ) = C( K, J ) + TEMP1*A( K, I )
|
|
kusano |
2b45e8 |
TEMP2 = TEMP2 +
|
|
kusano |
2b45e8 |
$ B( K, J )*CONJG( A( K, I ) )
|
|
kusano |
2b45e8 |
80 CONTINUE
|
|
kusano |
2b45e8 |
IF( BETA.EQ.ZERO )THEN
|
|
kusano |
2b45e8 |
C( I, J ) = TEMP1*REAL( A( I, I ) ) +
|
|
kusano |
2b45e8 |
$ ALPHA*TEMP2
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
C( I, J ) = BETA *C( I, J ) +
|
|
kusano |
2b45e8 |
$ TEMP1*REAL( A( I, I ) ) +
|
|
kusano |
2b45e8 |
$ ALPHA*TEMP2
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
90 CONTINUE
|
|
kusano |
2b45e8 |
100 CONTINUE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Form C := alpha*B*A + beta*C.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
DO 170, J = 1, N
|
|
kusano |
2b45e8 |
TEMP1 = ALPHA*REAL( A( J, J ) )
|
|
kusano |
2b45e8 |
IF( BETA.EQ.ZERO )THEN
|
|
kusano |
2b45e8 |
DO 110, I = 1, M
|
|
kusano |
2b45e8 |
C( I, J ) = TEMP1*B( I, J )
|
|
kusano |
2b45e8 |
110 CONTINUE
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
DO 120, I = 1, M
|
|
kusano |
2b45e8 |
C( I, J ) = BETA*C( I, J ) + TEMP1*B( I, J )
|
|
kusano |
2b45e8 |
120 CONTINUE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
DO 140, K = 1, J - 1
|
|
kusano |
2b45e8 |
IF( UPPER )THEN
|
|
kusano |
2b45e8 |
TEMP1 = ALPHA*A( K, J )
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
TEMP1 = ALPHA*CONJG( A( J, K ) )
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
DO 130, I = 1, M
|
|
kusano |
2b45e8 |
C( I, J ) = C( I, J ) + TEMP1*B( I, K )
|
|
kusano |
2b45e8 |
130 CONTINUE
|
|
kusano |
2b45e8 |
140 CONTINUE
|
|
kusano |
2b45e8 |
DO 160, K = J + 1, N
|
|
kusano |
2b45e8 |
IF( UPPER )THEN
|
|
kusano |
2b45e8 |
TEMP1 = ALPHA*CONJG( A( J, K ) )
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
TEMP1 = ALPHA*A( K, J )
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
DO 150, I = 1, M
|
|
kusano |
2b45e8 |
C( I, J ) = C( I, J ) + TEMP1*B( I, K )
|
|
kusano |
2b45e8 |
150 CONTINUE
|
|
kusano |
2b45e8 |
160 CONTINUE
|
|
kusano |
2b45e8 |
170 CONTINUE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
RETURN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* End of CHEMM .
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
END
|