3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
11 * SUBROUTINE ZHER2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
13 * .. Scalar Arguments ..
15 * DOUBLE PRECISION BETA
16 * INTEGER K,LDA,LDB,LDC,N
17 * CHARACTER TRANS,UPLO
19 * .. Array Arguments ..
20 * COMPLEX*16 A(LDA,*),B(LDB,*),C(LDC,*)
29 *> ZHER2K performs one of the hermitian rank 2k operations
31 *> C := alpha*A*B**H + conjg( alpha )*B*A**H + beta*C,
35 *> C := alpha*A**H*B + conjg( alpha )*B**H*A + beta*C,
37 *> where alpha and beta are scalars with beta real, C is an n by n
38 *> hermitian matrix and A and B are n by k matrices in the first case
39 *> and k by n matrices in the second case.
47 *> UPLO is CHARACTER*1
48 *> On entry, UPLO specifies whether the upper or lower
49 *> triangular part of the array C is to be referenced as
52 *> UPLO = 'U' or 'u' Only the upper triangular part of C
53 *> is to be referenced.
55 *> UPLO = 'L' or 'l' Only the lower triangular part of C
56 *> is to be referenced.
61 *> TRANS is CHARACTER*1
62 *> On entry, TRANS specifies the operation to be performed as
65 *> TRANS = 'N' or 'n' C := alpha*A*B**H +
66 *> conjg( alpha )*B*A**H +
69 *> TRANS = 'C' or 'c' C := alpha*A**H*B +
70 *> conjg( alpha )*B**H*A +
77 *> On entry, N specifies the order of the matrix C. N must be
84 *> On entry with TRANS = 'N' or 'n', K specifies the number
85 *> of columns of the matrices A and B, and on entry with
86 *> TRANS = 'C' or 'c', K specifies the number of rows of the
87 *> matrices A and B. K must be at least zero.
92 *> ALPHA is COMPLEX*16 .
93 *> On entry, ALPHA specifies the scalar alpha.
98 *> A is COMPLEX*16 array of DIMENSION ( LDA, ka ), where ka is
99 *> k when TRANS = 'N' or 'n', and is n otherwise.
100 *> Before entry with TRANS = 'N' or 'n', the leading n by k
101 *> part of the array A must contain the matrix A, otherwise
102 *> the leading k by n part of the array A must contain the
109 *> On entry, LDA specifies the first dimension of A as declared
110 *> in the calling (sub) program. When TRANS = 'N' or 'n'
111 *> then LDA must be at least max( 1, n ), otherwise LDA must
112 *> be at least max( 1, k ).
117 *> B is COMPLEX*16 array of DIMENSION ( LDB, kb ), where kb is
118 *> k when TRANS = 'N' or 'n', and is n otherwise.
119 *> Before entry with TRANS = 'N' or 'n', the leading n by k
120 *> part of the array B must contain the matrix B, otherwise
121 *> the leading k by n part of the array B must contain the
128 *> On entry, LDB specifies the first dimension of B as declared
129 *> in the calling (sub) program. When TRANS = 'N' or 'n'
130 *> then LDB must be at least max( 1, n ), otherwise LDB must
131 *> be at least max( 1, k ).
132 *> Unchanged on exit.
137 *> BETA is DOUBLE PRECISION .
138 *> On entry, BETA specifies the scalar beta.
143 *> C is COMPLEX*16 array of DIMENSION ( LDC, n ).
144 *> Before entry with UPLO = 'U' or 'u', the leading n by n
145 *> upper triangular part of the array C must contain the upper
146 *> triangular part of the hermitian matrix and the strictly
147 *> lower triangular part of C is not referenced. On exit, the
148 *> upper triangular part of the array C is overwritten by the
149 *> upper triangular part of the updated matrix.
150 *> Before entry with UPLO = 'L' or 'l', the leading n by n
151 *> lower triangular part of the array C must contain the lower
152 *> triangular part of the hermitian matrix and the strictly
153 *> upper triangular part of C is not referenced. On exit, the
154 *> lower triangular part of the array C is overwritten by the
155 *> lower triangular part of the updated matrix.
156 *> Note that the imaginary parts of the diagonal elements need
157 *> not be set, they are assumed to be zero, and on exit they
164 *> On entry, LDC specifies the first dimension of C as declared
165 *> in the calling (sub) program. LDC must be at least
172 *> \author Univ. of Tennessee
173 *> \author Univ. of California Berkeley
174 *> \author Univ. of Colorado Denver
177 *> \date November 2011
179 *> \ingroup complex16_blas_level3
181 *> \par Further Details:
182 * =====================
186 *> Level 3 Blas routine.
188 *> -- Written on 8-February-1989.
189 *> Jack Dongarra, Argonne National Laboratory.
190 *> Iain Duff, AERE Harwell.
191 *> Jeremy Du Croz, Numerical Algorithms Group Ltd.
192 *> Sven Hammarling, Numerical Algorithms Group Ltd.
194 *> -- Modified 8-Nov-93 to set C(J,J) to DBLE( C(J,J) ) when BETA = 1.
195 *> Ed Anderson, Cray Research Inc.
198 * =====================================================================
199 SUBROUTINE ZHER2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
201 * -- Reference BLAS level3 routine (version 3.4.0) --
202 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
203 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
206 * .. Scalar Arguments ..
208 DOUBLE PRECISION BETA
209 INTEGER K,LDA,LDB,LDC,N
212 * .. Array Arguments ..
213 COMPLEX*16 A(LDA,*),B(LDB,*),C(LDC,*)
216 * =====================================================================
218 * .. External Functions ..
222 * .. External Subroutines ..
225 * .. Intrinsic Functions ..
226 INTRINSIC DBLE,DCONJG,MAX
228 * .. Local Scalars ..
229 COMPLEX*16 TEMP1,TEMP2
230 INTEGER I,INFO,J,L,NROWA
235 PARAMETER (ONE=1.0D+0)
237 PARAMETER (ZERO= (0.0D+0,0.0D+0))
240 * Test the input parameters.
242 IF (LSAME(TRANS,'N')) THEN
247 UPPER = LSAME(UPLO,'U')
250 IF ((.NOT.UPPER) .AND. (.NOT.LSAME(UPLO,'L'))) THEN
252 ELSE IF ((.NOT.LSAME(TRANS,'N')) .AND.
253 + (.NOT.LSAME(TRANS,'C'))) THEN
255 ELSE IF (N.LT.0) THEN
257 ELSE IF (K.LT.0) THEN
259 ELSE IF (LDA.LT.MAX(1,NROWA)) THEN
261 ELSE IF (LDB.LT.MAX(1,NROWA)) THEN
263 ELSE IF (LDC.LT.MAX(1,N)) THEN
267 CALL XERBLA('ZHER2K',INFO)
271 * Quick return if possible.
273 IF ((N.EQ.0) .OR. (((ALPHA.EQ.ZERO).OR.
274 + (K.EQ.0)).AND. (BETA.EQ.ONE))) RETURN
276 * And when alpha.eq.zero.
278 IF (ALPHA.EQ.ZERO) THEN
280 IF (BETA.EQ.DBLE(ZERO)) THEN
291 C(J,J) = BETA*DBLE(C(J,J))
295 IF (BETA.EQ.DBLE(ZERO)) THEN
303 C(J,J) = BETA*DBLE(C(J,J))
313 * Start the operations.
315 IF (LSAME(TRANS,'N')) THEN
317 * Form C := alpha*A*B**H + conjg( alpha )*B*A**H +
322 IF (BETA.EQ.DBLE(ZERO)) THEN
326 ELSE IF (BETA.NE.ONE) THEN
330 C(J,J) = BETA*DBLE(C(J,J))
332 C(J,J) = DBLE(C(J,J))
335 IF ((A(J,L).NE.ZERO) .OR. (B(J,L).NE.ZERO)) THEN
336 TEMP1 = ALPHA*DCONJG(B(J,L))
337 TEMP2 = DCONJG(ALPHA*A(J,L))
339 C(I,J) = C(I,J) + A(I,L)*TEMP1 +
342 C(J,J) = DBLE(C(J,J)) +
343 + DBLE(A(J,L)*TEMP1+B(J,L)*TEMP2)
349 IF (BETA.EQ.DBLE(ZERO)) THEN
353 ELSE IF (BETA.NE.ONE) THEN
357 C(J,J) = BETA*DBLE(C(J,J))
359 C(J,J) = DBLE(C(J,J))
362 IF ((A(J,L).NE.ZERO) .OR. (B(J,L).NE.ZERO)) THEN
363 TEMP1 = ALPHA*DCONJG(B(J,L))
364 TEMP2 = DCONJG(ALPHA*A(J,L))
366 C(I,J) = C(I,J) + A(I,L)*TEMP1 +
369 C(J,J) = DBLE(C(J,J)) +
370 + DBLE(A(J,L)*TEMP1+B(J,L)*TEMP2)
377 * Form C := alpha*A**H*B + conjg( alpha )*B**H*A +
386 TEMP1 = TEMP1 + DCONJG(A(L,I))*B(L,J)
387 TEMP2 = TEMP2 + DCONJG(B(L,I))*A(L,J)
390 IF (BETA.EQ.DBLE(ZERO)) THEN
391 C(J,J) = DBLE(ALPHA*TEMP1+
392 + DCONJG(ALPHA)*TEMP2)
394 C(J,J) = BETA*DBLE(C(J,J)) +
396 + DCONJG(ALPHA)*TEMP2)
399 IF (BETA.EQ.DBLE(ZERO)) THEN
400 C(I,J) = ALPHA*TEMP1 + DCONJG(ALPHA)*TEMP2
402 C(I,J) = BETA*C(I,J) + ALPHA*TEMP1 +
403 + DCONJG(ALPHA)*TEMP2
414 TEMP1 = TEMP1 + DCONJG(A(L,I))*B(L,J)
415 TEMP2 = TEMP2 + DCONJG(B(L,I))*A(L,J)
418 IF (BETA.EQ.DBLE(ZERO)) THEN
419 C(J,J) = DBLE(ALPHA*TEMP1+
420 + DCONJG(ALPHA)*TEMP2)
422 C(J,J) = BETA*DBLE(C(J,J)) +
424 + DCONJG(ALPHA)*TEMP2)
427 IF (BETA.EQ.DBLE(ZERO)) THEN
428 C(I,J) = ALPHA*TEMP1 + DCONJG(ALPHA)*TEMP2
430 C(I,J) = BETA*C(I,J) + ALPHA*TEMP1 +
431 + DCONJG(ALPHA)*TEMP2