1 SUBROUTINE ZHERK
( UPLO
, TRANS
, N
, K
, ALPHA
, A
, LDA
, BETA
, C
, LDC
)
2 * .. Scalar Arguments
..
5 DOUBLE PRECISION ALPHA
, BETA
7 * .. Array Arguments
..
8 COMPLEX*16 A
( LDA
, * ), C
( LDC
, * )
14 * ZHERK performs one of the hermitian rank k operations
16 * C
:= alpha*A*conjg
( A
' ) + beta*C,
20 * C := alpha*conjg( A' )*A
+ beta*C
,
22 * where alpha and beta are
real scalars
, C is an n by n hermitian
23 * matrix and A is an n by k matrix in the first case and a k by n
24 * matrix in the second case
.
30 * On entry
, UPLO specifies whether the upper or lower
31 * triangular part of the array C is
to be referenced as
34 * UPLO
= 'U' or
'u' Only the upper triangular part of C
35 * is
to be referenced
.
37 * UPLO
= 'L' or
'l' Only the lower triangular part of C
38 * is
to be referenced
.
42 * TRANS
- CHARACTER*1
.
43 * On entry
, TRANS specifies the operation
to be performed as
46 * TRANS
= 'N' or
'n' C
:= alpha*A*conjg
( A
' ) + beta*C.
48 * TRANS = 'C
' or 'c
' C := alpha*conjg( A' )*A
+ beta*C
.
53 * On entry
, N specifies the order of the matrix C
. N must be
58 * On entry with TRANS
= 'N' or
'n', K specifies the number
59 * of columns of the matrix A
, and on entry with
60 * TRANS
= 'C' or
'c', K specifies the number of rows of the
61 * matrix A
. K must be at least zero
.
64 * ALPHA
- DOUBLE PRECISION .
65 * On entry
, ALPHA specifies the scalar alpha
.
68 * A
- COMPLEX*16 array of
DIMENSION ( LDA
, ka
), where ka is
69 * k when TRANS
= 'N' or
'n', and is n otherwise
.
70 * Before entry with TRANS
= 'N' or
'n', the leading n by k
71 * part of the array A must contain the matrix A
, otherwise
72 * the leading k by n part of the array A must contain the
77 * On entry
, LDA specifies the first
dimension of A as declared
78 * in the calling
(sub
) program. When TRANS
= 'N' or
'n'
79 * then LDA must be at least max
( 1, n
), otherwise LDA must
80 * be at least max
( 1, k
).
83 * BETA
- DOUBLE PRECISION.
84 * On entry
, BETA specifies the scalar beta
.
87 * C
- COMPLEX*16 array of
DIMENSION ( LDC
, n
).
88 * Before entry with UPLO
= 'U' or
'u', the leading n by n
89 * upper triangular part of the array C must contain the upper
90 * triangular part of the hermitian matrix and the strictly
91 * lower triangular part of C is not referenced
. On exit
, the
92 * upper triangular part of the array C is overwritten by the
93 * upper triangular part of the updated matrix
.
94 * Before entry with UPLO
= 'L' or
'l', the leading n by n
95 * lower triangular part of the array C must contain the lower
96 * triangular part of the hermitian matrix and the strictly
97 * upper triangular part of C is not referenced
. On exit
, the
98 * lower triangular part of the array C is overwritten by the
99 * lower triangular part of the updated matrix
.
100 * Note that the imaginary parts of the diagonal elements need
101 * not be set
, they are assumed
to be zero
, and on exit they
105 * On entry
, LDC specifies the first
dimension of C as declared
106 * in the calling
(sub
) program. LDC must be at least
111 * Level
3 Blas routine
.
113 * -- Written on
8-February
-1989.
114 * Jack Dongarra
, Argonne National Laboratory
.
115 * Iain Duff
, AERE Harwell
.
116 * Jeremy Du Croz
, Numerical Algorithms Group Ltd
.
117 * Sven Hammarling
, Numerical Algorithms Group Ltd
.
119 * -- Modified
8-Nov
-93 to set C
(J
,J
) to DBLE
( C
(J
,J
) ) when BETA
= 1.
120 * Ed Anderson
, Cray Research Inc
.
123 * .. External Functions
..
127 * .. External Subroutines
..
130 * .. Intrinsic Functions
..
131 INTRINSIC DBLE
, DCMPLX
, DCONJG
, MAX
133 * .. Local Scalars
..
135 INTEGER I
, INFO
, J
, L
, NROWA
136 DOUBLE PRECISION RTEMP
140 DOUBLE PRECISION ONE
, ZERO
141 PARAMETER ( ONE
= 1.0D
+0, ZERO
= 0.0D
+0 )
143 * .. Executable Statements
..
145 * Test the input parameters
.
147 IF( LSAME
( TRANS
, 'N' ) ) THEN
152 UPPER
= LSAME
( UPLO
, 'U' )
155 IF( ( .NOT
.UPPER
) .AND
. ( .NOT
.LSAME
( UPLO
, 'L' ) ) ) THEN
157 ELSE IF( ( .NOT
.LSAME
( TRANS
, 'N' ) ) .AND
.
158 $
( .NOT
.LSAME
( TRANS
, 'C' ) ) ) THEN
160 ELSE IF( N
.LT
.0 ) THEN
162 ELSE IF( K
.LT
.0 ) THEN
164 ELSE IF( LDA
.LT
.MAX
( 1, NROWA
) ) THEN
166 ELSE IF( LDC
.LT
.MAX
( 1, N
) ) THEN
170 CALL XERBLA
( 'ZHERK ', INFO
)
174 * Quick
return if possible
.
176 IF( ( N
.EQ
.0 ) .OR
. ( ( ( ALPHA
.EQ
.ZERO
) .OR
. ( K
.EQ
.0 ) ) .AND
.
177 $
( BETA
.EQ
.ONE
) ) )RETURN
179 * And when alpha
.eq
.zero
.
181 IF( ALPHA
.EQ
.ZERO
) THEN
183 IF( BETA
.EQ
.ZERO
) THEN
192 C
( I
, J
) = BETA*C
( I
, J
)
194 C
( J
, J
) = BETA*DBLE
( C
( J
, J
) )
198 IF( BETA
.EQ
.ZERO
) THEN
206 C
( J
, J
) = BETA*DBLE
( C
( J
, J
) )
208 C
( I
, J
) = BETA*C
( I
, J
)
216 * Start the operations
.
218 IF( LSAME
( TRANS
, 'N' ) ) THEN
220 * Form C
:= alpha*A*conjg
( A
' ) + beta*C.
224 IF( BETA.EQ.ZERO ) THEN
228 ELSE IF( BETA.NE.ONE ) THEN
230 C( I, J ) = BETA*C( I, J )
232 C( J, J ) = BETA*DBLE( C( J, J ) )
234 C( J, J ) = DBLE( C( J, J ) )
237 IF( A( J, L ).NE.DCMPLX( ZERO ) ) THEN
238 TEMP = ALPHA*DCONJG( A( J, L ) )
240 C( I, J ) = C( I, J ) + TEMP*A( I, L )
242 C( J, J ) = DBLE( C( J, J ) ) +
243 $ DBLE( TEMP*A( I, L ) )
249 IF( BETA.EQ.ZERO ) THEN
253 ELSE IF( BETA.NE.ONE ) THEN
254 C( J, J ) = BETA*DBLE( C( J, J ) )
256 C( I, J ) = BETA*C( I, J )
259 C( J, J ) = DBLE( C( J, J ) )
262 IF( A( J, L ).NE.DCMPLX( ZERO ) ) THEN
263 TEMP = ALPHA*DCONJG( A( J, L ) )
264 C( J, J ) = DBLE( C( J, J ) ) +
265 $ DBLE( TEMP*A( J, L ) )
267 C( I, J ) = C( I, J ) + TEMP*A( I, L )
275 * Form C := alpha*conjg( A' )*A
+ beta*C
.
282 TEMP
= TEMP
+ DCONJG
( A
( L
, I
) )*A
( L
, J
)
284 IF( BETA
.EQ
.ZERO
) THEN
285 C
( I
, J
) = ALPHA*TEMP
287 C
( I
, J
) = ALPHA*TEMP
+ BETA*C
( I
, J
)
292 RTEMP
= RTEMP
+ DCONJG
( A
( L
, J
) )*A
( L
, J
)
294 IF( BETA
.EQ
.ZERO
) THEN
295 C
( J
, J
) = ALPHA*RTEMP
297 C
( J
, J
) = ALPHA*RTEMP
+ BETA*DBLE
( C
( J
, J
) )
304 RTEMP
= RTEMP
+ DCONJG
( A
( L
, J
) )*A
( L
, J
)
306 IF( BETA
.EQ
.ZERO
) THEN
307 C
( J
, J
) = ALPHA*RTEMP
309 C
( J
, J
) = ALPHA*RTEMP
+ BETA*DBLE
( C
( J
, J
) )
314 TEMP
= TEMP
+ DCONJG
( A
( L
, I
) )*A
( L
, J
)
316 IF( BETA
.EQ
.ZERO
) THEN
317 C
( I
, J
) = ALPHA*TEMP
319 C
( I
, J
) = ALPHA*TEMP
+ BETA*C
( I
, J
)