1 SUBROUTINE ZHERK
(UPLO
,TRANS
,N
,K
,ALPHA
,A
,LDA
,BETA
,C
,LDC
)
2 * .. Scalar Arguments
..
3 DOUBLE PRECISION ALPHA
,BETA
7 * .. Array Arguments
..
8 DOUBLE COMPLEX 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 DOUBLE PRECISION RTEMP
136 INTEGER I
,INFO
,J
,L
,NROWA
140 DOUBLE PRECISION ONE
,ZERO
141 PARAMETER (ONE
=1.0D
+0,ZERO
=0.0D
+0)
144 * Test the input parameters
.
146 IF (LSAME
(TRANS
,'N')) THEN
151 UPPER
= LSAME
(UPLO
,'U')
154 IF ((.NOT
.UPPER
) .AND
. (.NOT
.LSAME
(UPLO
,'L'))) THEN
156 ELSE IF ((.NOT
.LSAME
(TRANS
,'N')) .AND
.
157 + (.NOT
.LSAME
(TRANS
,'C'))) THEN
159 ELSE IF (N
.LT
.0) THEN
161 ELSE IF (K
.LT
.0) THEN
163 ELSE IF (LDA
.LT
.MAX
(1,NROWA
)) THEN
165 ELSE IF (LDC
.LT
.MAX
(1,N
)) THEN
169 CALL XERBLA
('ZHERK ',INFO
)
173 * Quick
return if possible
.
175 IF ((N
.EQ
.0) .OR
. (((ALPHA
.EQ
.ZERO
).OR
.
176 + (K
.EQ
.0)).AND
. (BETA
.EQ
.ONE
))) RETURN
178 * And when alpha
.eq
.zero
.
180 IF (ALPHA
.EQ
.ZERO
) THEN
182 IF (BETA
.EQ
.ZERO
) THEN
193 C
(J
,J
) = BETA*DBLE
(C
(J
,J
))
197 IF (BETA
.EQ
.ZERO
) THEN
205 C
(J
,J
) = BETA*DBLE
(C
(J
,J
))
215 * Start the operations
.
217 IF (LSAME
(TRANS
,'N')) THEN
219 * Form C
:= alpha*A*conjg
( A
' ) + beta*C.
223 IF (BETA.EQ.ZERO) THEN
227 ELSE IF (BETA.NE.ONE) THEN
231 C(J,J) = BETA*DBLE(C(J,J))
233 C(J,J) = DBLE(C(J,J))
236 IF (A(J,L).NE.DCMPLX(ZERO)) THEN
237 TEMP = ALPHA*DCONJG(A(J,L))
239 C(I,J) = C(I,J) + TEMP*A(I,L)
241 C(J,J) = DBLE(C(J,J)) + DBLE(TEMP*A(I,L))
247 IF (BETA.EQ.ZERO) THEN
251 ELSE IF (BETA.NE.ONE) THEN
252 C(J,J) = BETA*DBLE(C(J,J))
257 C(J,J) = DBLE(C(J,J))
260 IF (A(J,L).NE.DCMPLX(ZERO)) THEN
261 TEMP = ALPHA*DCONJG(A(J,L))
262 C(J,J) = DBLE(C(J,J)) + DBLE(TEMP*A(J,L))
264 C(I,J) = C(I,J) + TEMP*A(I,L)
272 * Form C := alpha*conjg( A' )*A
+ beta*C
.
279 TEMP
= TEMP
+ DCONJG
(A
(L
,I
))*A
(L
,J
)
281 IF (BETA
.EQ
.ZERO
) THEN
284 C
(I
,J
) = ALPHA*TEMP
+ BETA*C
(I
,J
)
289 RTEMP
= RTEMP
+ DCONJG
(A
(L
,J
))*A
(L
,J
)
291 IF (BETA
.EQ
.ZERO
) THEN
294 C
(J
,J
) = ALPHA*RTEMP
+ BETA*DBLE
(C
(J
,J
))
301 RTEMP
= RTEMP
+ DCONJG
(A
(L
,J
))*A
(L
,J
)
303 IF (BETA
.EQ
.ZERO
) THEN
306 C
(J
,J
) = ALPHA*RTEMP
+ BETA*DBLE
(C
(J
,J
))
311 TEMP
= TEMP
+ DCONJG
(A
(L
,I
))*A
(L
,J
)
313 IF (BETA
.EQ
.ZERO
) THEN
316 C
(I
,J
) = ALPHA*TEMP
+ BETA*C
(I
,J
)