1 *> \brief \b ZHFRK performs a Hermitian rank-k operation for matrix in RFP format.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download ZHFRK + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhfrk.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhfrk.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhfrk.f">
21 * SUBROUTINE ZHFRK( TRANSR, UPLO, TRANS, N, K, ALPHA, A, LDA, BETA,
24 * .. Scalar Arguments ..
25 * DOUBLE PRECISION ALPHA, BETA
27 * CHARACTER TRANS, TRANSR, UPLO
29 * .. Array Arguments ..
30 * COMPLEX*16 A( LDA, * ), C( * )
39 *> Level 3 BLAS like routine for C in RFP Format.
41 *> ZHFRK performs one of the Hermitian rank--k operations
43 *> C := alpha*A*A**H + beta*C,
47 *> C := alpha*A**H*A + beta*C,
49 *> where alpha and beta are real scalars, C is an n--by--n Hermitian
50 *> matrix and A is an n--by--k matrix in the first case and a k--by--n
51 *> matrix in the second case.
59 *> TRANSR is CHARACTER*1
60 *> = 'N': The Normal Form of RFP A is stored;
61 *> = 'C': The Conjugate-transpose Form of RFP A is stored.
66 *> UPLO is CHARACTER*1
67 *> On entry, UPLO specifies whether the upper or lower
68 *> triangular part of the array C is to be referenced as
71 *> UPLO = 'U' or 'u' Only the upper triangular part of C
72 *> is to be referenced.
74 *> UPLO = 'L' or 'l' Only the lower triangular part of C
75 *> is to be referenced.
82 *> TRANS is CHARACTER*1
83 *> On entry, TRANS specifies the operation to be performed as
86 *> TRANS = 'N' or 'n' C := alpha*A*A**H + beta*C.
88 *> TRANS = 'C' or 'c' C := alpha*A**H*A + beta*C.
96 *> On entry, N specifies the order of the matrix C. N must be
104 *> On entry with TRANS = 'N' or 'n', K specifies the number
105 *> of columns of the matrix A, and on entry with
106 *> TRANS = 'C' or 'c', K specifies the number of rows of the
107 *> matrix A. K must be at least zero.
108 *> Unchanged on exit.
113 *> ALPHA is DOUBLE PRECISION
114 *> On entry, ALPHA specifies the scalar alpha.
115 *> Unchanged on exit.
120 *> A is COMPLEX*16 array of DIMENSION (LDA,ka)
122 *> is K when TRANS = 'N' or 'n', and is N otherwise. Before
123 *> entry with TRANS = 'N' or 'n', the leading N--by--K part of
124 *> the array A must contain the matrix A, otherwise the leading
125 *> K--by--N part of the array A must contain the matrix A.
126 *> Unchanged on exit.
132 *> On entry, LDA specifies the first dimension of A as declared
133 *> in the calling (sub) program. When TRANS = 'N' or 'n'
134 *> then LDA must be at least max( 1, n ), otherwise LDA must
135 *> be at least max( 1, k ).
136 *> Unchanged on exit.
141 *> BETA is DOUBLE PRECISION
142 *> On entry, BETA specifies the scalar beta.
143 *> Unchanged on exit.
148 *> C is COMPLEX*16 array, dimension (N*(N+1)/2)
149 *> On entry, the matrix A in RFP Format. RFP Format is
150 *> described by TRANSR, UPLO and N. Note that the imaginary
151 *> parts of the diagonal elements need not be set, they are
152 *> assumed to be zero, and on exit they are set to zero.
158 *> \author Univ. of Tennessee
159 *> \author Univ. of California Berkeley
160 *> \author Univ. of Colorado Denver
163 *> \date September 2012
165 *> \ingroup complex16OTHERcomputational
167 * =====================================================================
168 SUBROUTINE ZHFRK( TRANSR, UPLO, TRANS, N, K, ALPHA, A, LDA, BETA,
171 * -- LAPACK computational routine (version 3.4.2) --
172 * -- LAPACK is a software package provided by Univ. of Tennessee, --
173 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
176 * .. Scalar Arguments ..
177 DOUBLE PRECISION ALPHA, BETA
179 CHARACTER TRANS, TRANSR, UPLO
181 * .. Array Arguments ..
182 COMPLEX*16 A( LDA, * ), C( * )
185 * =====================================================================
188 DOUBLE PRECISION ONE, ZERO
190 PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
191 PARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ) )
193 * .. Local Scalars ..
194 LOGICAL LOWER, NORMALTRANSR, NISODD, NOTRANS
195 INTEGER INFO, NROWA, J, NK, N1, N2
196 COMPLEX*16 CALPHA, CBETA
198 * .. External Functions ..
202 * .. External Subroutines ..
203 EXTERNAL XERBLA, ZGEMM, ZHERK
205 * .. Intrinsic Functions ..
206 INTRINSIC MAX, DCMPLX
208 * .. Executable Statements ..
211 * Test the input parameters.
214 NORMALTRANSR = LSAME( TRANSR, 'N' )
215 LOWER = LSAME( UPLO, 'L' )
216 NOTRANS = LSAME( TRANS, 'N' )
224 IF( .NOT.NORMALTRANSR .AND. .NOT.LSAME( TRANSR, 'C' ) ) THEN
226 ELSE IF( .NOT.LOWER .AND. .NOT.LSAME( UPLO, 'U' ) ) THEN
228 ELSE IF( .NOT.NOTRANS .AND. .NOT.LSAME( TRANS, 'C' ) ) THEN
230 ELSE IF( N.LT.0 ) THEN
232 ELSE IF( K.LT.0 ) THEN
234 ELSE IF( LDA.LT.MAX( 1, NROWA ) ) THEN
238 CALL XERBLA( 'ZHFRK ', -INFO )
242 * Quick return if possible.
244 * The quick return case: ((ALPHA.EQ.0).AND.(BETA.NE.ZERO)) is not
245 * done (it is in ZHERK for example) and left in the general case.
247 IF( ( N.EQ.0 ) .OR. ( ( ( ALPHA.EQ.ZERO ) .OR. ( K.EQ.0 ) ) .AND.
248 $ ( BETA.EQ.ONE ) ) )RETURN
250 IF( ( ALPHA.EQ.ZERO ) .AND. ( BETA.EQ.ZERO ) ) THEN
251 DO J = 1, ( ( N*( N+1 ) ) / 2 )
257 CALPHA = DCMPLX( ALPHA, ZERO )
258 CBETA = DCMPLX( BETA, ZERO )
261 * If N is odd, set NISODD = .TRUE., and N1 and N2.
262 * If N is even, NISODD = .FALSE., and NK.
264 IF( MOD( N, 2 ).EQ.0 ) THEN
282 IF( NORMALTRANSR ) THEN
284 * N is odd and TRANSR = 'N'
288 * N is odd, TRANSR = 'N', and UPLO = 'L'
292 * N is odd, TRANSR = 'N', UPLO = 'L', and TRANS = 'N'
294 CALL ZHERK( 'L', 'N', N1, K, ALPHA, A( 1, 1 ), LDA,
296 CALL ZHERK( 'U', 'N', N2, K, ALPHA, A( N1+1, 1 ), LDA,
297 $ BETA, C( N+1 ), N )
298 CALL ZGEMM( 'N', 'C', N2, N1, K, CALPHA, A( N1+1, 1 ),
299 $ LDA, A( 1, 1 ), LDA, CBETA, C( N1+1 ), N )
303 * N is odd, TRANSR = 'N', UPLO = 'L', and TRANS = 'C'
305 CALL ZHERK( 'L', 'C', N1, K, ALPHA, A( 1, 1 ), LDA,
307 CALL ZHERK( 'U', 'C', N2, K, ALPHA, A( 1, N1+1 ), LDA,
308 $ BETA, C( N+1 ), N )
309 CALL ZGEMM( 'C', 'N', N2, N1, K, CALPHA, A( 1, N1+1 ),
310 $ LDA, A( 1, 1 ), LDA, CBETA, C( N1+1 ), N )
316 * N is odd, TRANSR = 'N', and UPLO = 'U'
320 * N is odd, TRANSR = 'N', UPLO = 'U', and TRANS = 'N'
322 CALL ZHERK( 'L', 'N', N1, K, ALPHA, A( 1, 1 ), LDA,
323 $ BETA, C( N2+1 ), N )
324 CALL ZHERK( 'U', 'N', N2, K, ALPHA, A( N2, 1 ), LDA,
325 $ BETA, C( N1+1 ), N )
326 CALL ZGEMM( 'N', 'C', N1, N2, K, CALPHA, A( 1, 1 ),
327 $ LDA, A( N2, 1 ), LDA, CBETA, C( 1 ), N )
331 * N is odd, TRANSR = 'N', UPLO = 'U', and TRANS = 'C'
333 CALL ZHERK( 'L', 'C', N1, K, ALPHA, A( 1, 1 ), LDA,
334 $ BETA, C( N2+1 ), N )
335 CALL ZHERK( 'U', 'C', N2, K, ALPHA, A( 1, N2 ), LDA,
336 $ BETA, C( N1+1 ), N )
337 CALL ZGEMM( 'C', 'N', N1, N2, K, CALPHA, A( 1, 1 ),
338 $ LDA, A( 1, N2 ), LDA, CBETA, C( 1 ), N )
346 * N is odd, and TRANSR = 'C'
350 * N is odd, TRANSR = 'C', and UPLO = 'L'
354 * N is odd, TRANSR = 'C', UPLO = 'L', and TRANS = 'N'
356 CALL ZHERK( 'U', 'N', N1, K, ALPHA, A( 1, 1 ), LDA,
358 CALL ZHERK( 'L', 'N', N2, K, ALPHA, A( N1+1, 1 ), LDA,
360 CALL ZGEMM( 'N', 'C', N1, N2, K, CALPHA, A( 1, 1 ),
361 $ LDA, A( N1+1, 1 ), LDA, CBETA,
366 * N is odd, TRANSR = 'C', UPLO = 'L', and TRANS = 'C'
368 CALL ZHERK( 'U', 'C', N1, K, ALPHA, A( 1, 1 ), LDA,
370 CALL ZHERK( 'L', 'C', N2, K, ALPHA, A( 1, N1+1 ), LDA,
372 CALL ZGEMM( 'C', 'N', N1, N2, K, CALPHA, A( 1, 1 ),
373 $ LDA, A( 1, N1+1 ), LDA, CBETA,
380 * N is odd, TRANSR = 'C', and UPLO = 'U'
384 * N is odd, TRANSR = 'C', UPLO = 'U', and TRANS = 'N'
386 CALL ZHERK( 'U', 'N', N1, K, ALPHA, A( 1, 1 ), LDA,
387 $ BETA, C( N2*N2+1 ), N2 )
388 CALL ZHERK( 'L', 'N', N2, K, ALPHA, A( N1+1, 1 ), LDA,
389 $ BETA, C( N1*N2+1 ), N2 )
390 CALL ZGEMM( 'N', 'C', N2, N1, K, CALPHA, A( N1+1, 1 ),
391 $ LDA, A( 1, 1 ), LDA, CBETA, C( 1 ), N2 )
395 * N is odd, TRANSR = 'C', UPLO = 'U', and TRANS = 'C'
397 CALL ZHERK( 'U', 'C', N1, K, ALPHA, A( 1, 1 ), LDA,
398 $ BETA, C( N2*N2+1 ), N2 )
399 CALL ZHERK( 'L', 'C', N2, K, ALPHA, A( 1, N1+1 ), LDA,
400 $ BETA, C( N1*N2+1 ), N2 )
401 CALL ZGEMM( 'C', 'N', N2, N1, K, CALPHA, A( 1, N1+1 ),
402 $ LDA, A( 1, 1 ), LDA, CBETA, C( 1 ), N2 )
414 IF( NORMALTRANSR ) THEN
416 * N is even and TRANSR = 'N'
420 * N is even, TRANSR = 'N', and UPLO = 'L'
424 * N is even, TRANSR = 'N', UPLO = 'L', and TRANS = 'N'
426 CALL ZHERK( 'L', 'N', NK, K, ALPHA, A( 1, 1 ), LDA,
427 $ BETA, C( 2 ), N+1 )
428 CALL ZHERK( 'U', 'N', NK, K, ALPHA, A( NK+1, 1 ), LDA,
429 $ BETA, C( 1 ), N+1 )
430 CALL ZGEMM( 'N', 'C', NK, NK, K, CALPHA, A( NK+1, 1 ),
431 $ LDA, A( 1, 1 ), LDA, CBETA, C( NK+2 ),
436 * N is even, TRANSR = 'N', UPLO = 'L', and TRANS = 'C'
438 CALL ZHERK( 'L', 'C', NK, K, ALPHA, A( 1, 1 ), LDA,
439 $ BETA, C( 2 ), N+1 )
440 CALL ZHERK( 'U', 'C', NK, K, ALPHA, A( 1, NK+1 ), LDA,
441 $ BETA, C( 1 ), N+1 )
442 CALL ZGEMM( 'C', 'N', NK, NK, K, CALPHA, A( 1, NK+1 ),
443 $ LDA, A( 1, 1 ), LDA, CBETA, C( NK+2 ),
450 * N is even, TRANSR = 'N', and UPLO = 'U'
454 * N is even, TRANSR = 'N', UPLO = 'U', and TRANS = 'N'
456 CALL ZHERK( 'L', 'N', NK, K, ALPHA, A( 1, 1 ), LDA,
457 $ BETA, C( NK+2 ), N+1 )
458 CALL ZHERK( 'U', 'N', NK, K, ALPHA, A( NK+1, 1 ), LDA,
459 $ BETA, C( NK+1 ), N+1 )
460 CALL ZGEMM( 'N', 'C', NK, NK, K, CALPHA, A( 1, 1 ),
461 $ LDA, A( NK+1, 1 ), LDA, CBETA, C( 1 ),
466 * N is even, TRANSR = 'N', UPLO = 'U', and TRANS = 'C'
468 CALL ZHERK( 'L', 'C', NK, K, ALPHA, A( 1, 1 ), LDA,
469 $ BETA, C( NK+2 ), N+1 )
470 CALL ZHERK( 'U', 'C', NK, K, ALPHA, A( 1, NK+1 ), LDA,
471 $ BETA, C( NK+1 ), N+1 )
472 CALL ZGEMM( 'C', 'N', NK, NK, K, CALPHA, A( 1, 1 ),
473 $ LDA, A( 1, NK+1 ), LDA, CBETA, C( 1 ),
482 * N is even, and TRANSR = 'C'
486 * N is even, TRANSR = 'C', and UPLO = 'L'
490 * N is even, TRANSR = 'C', UPLO = 'L', and TRANS = 'N'
492 CALL ZHERK( 'U', 'N', NK, K, ALPHA, A( 1, 1 ), LDA,
493 $ BETA, C( NK+1 ), NK )
494 CALL ZHERK( 'L', 'N', NK, K, ALPHA, A( NK+1, 1 ), LDA,
496 CALL ZGEMM( 'N', 'C', NK, NK, K, CALPHA, A( 1, 1 ),
497 $ LDA, A( NK+1, 1 ), LDA, CBETA,
498 $ C( ( ( NK+1 )*NK )+1 ), NK )
502 * N is even, TRANSR = 'C', UPLO = 'L', and TRANS = 'C'
504 CALL ZHERK( 'U', 'C', NK, K, ALPHA, A( 1, 1 ), LDA,
505 $ BETA, C( NK+1 ), NK )
506 CALL ZHERK( 'L', 'C', NK, K, ALPHA, A( 1, NK+1 ), LDA,
508 CALL ZGEMM( 'C', 'N', NK, NK, K, CALPHA, A( 1, 1 ),
509 $ LDA, A( 1, NK+1 ), LDA, CBETA,
510 $ C( ( ( NK+1 )*NK )+1 ), NK )
516 * N is even, TRANSR = 'C', and UPLO = 'U'
520 * N is even, TRANSR = 'C', UPLO = 'U', and TRANS = 'N'
522 CALL ZHERK( 'U', 'N', NK, K, ALPHA, A( 1, 1 ), LDA,
523 $ BETA, C( NK*( NK+1 )+1 ), NK )
524 CALL ZHERK( 'L', 'N', NK, K, ALPHA, A( NK+1, 1 ), LDA,
525 $ BETA, C( NK*NK+1 ), NK )
526 CALL ZGEMM( 'N', 'C', NK, NK, K, CALPHA, A( NK+1, 1 ),
527 $ LDA, A( 1, 1 ), LDA, CBETA, C( 1 ), NK )
531 * N is even, TRANSR = 'C', UPLO = 'U', and TRANS = 'C'
533 CALL ZHERK( 'U', 'C', NK, K, ALPHA, A( 1, 1 ), LDA,
534 $ BETA, C( NK*( NK+1 )+1 ), NK )
535 CALL ZHERK( 'L', 'C', NK, K, ALPHA, A( 1, NK+1 ), LDA,
536 $ BETA, C( NK*NK+1 ), NK )
537 CALL ZGEMM( 'C', 'N', NK, NK, K, CALPHA, A( 1, NK+1 ),
538 $ LDA, A( 1, 1 ), LDA, CBETA, C( 1 ), NK )