1 *> \brief \b CHFRK 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 CHFRK + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/chfrk.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/chfrk.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/chfrk.f">
21 * SUBROUTINE CHFRK( TRANSR, UPLO, TRANS, N, K, ALPHA, A, LDA, BETA,
24 * .. Scalar Arguments ..
27 * CHARACTER TRANS, TRANSR, UPLO
29 * .. Array Arguments ..
30 * COMPLEX A( LDA, * ), C( * )
39 *> Level 3 BLAS like routine for C in RFP Format.
41 *> CHFRK 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.
114 *> On entry, ALPHA specifies the scalar alpha.
115 *> Unchanged on exit.
120 *> A is COMPLEX array, 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.
142 *> On entry, BETA specifies the scalar beta.
143 *> Unchanged on exit.
148 *> C is COMPLEX 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 complexOTHERcomputational
167 * =====================================================================
168 SUBROUTINE CHFRK( 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 ..
179 CHARACTER TRANS, TRANSR, UPLO
181 * .. Array Arguments ..
182 COMPLEX A( LDA, * ), C( * )
185 * =====================================================================
191 PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
192 PARAMETER ( CZERO = ( 0.0E+0, 0.0E+0 ) )
194 * .. Local Scalars ..
195 LOGICAL LOWER, NORMALTRANSR, NISODD, NOTRANS
196 INTEGER INFO, NROWA, J, NK, N1, N2
197 COMPLEX CALPHA, CBETA
199 * .. External Functions ..
203 * .. External Subroutines ..
204 EXTERNAL CGEMM, CHERK, XERBLA
206 * .. Intrinsic Functions ..
209 * .. Executable Statements ..
212 * Test the input parameters.
215 NORMALTRANSR = LSAME( TRANSR, 'N' )
216 LOWER = LSAME( UPLO, 'L' )
217 NOTRANS = LSAME( TRANS, 'N' )
225 IF( .NOT.NORMALTRANSR .AND. .NOT.LSAME( TRANSR, 'C' ) ) THEN
227 ELSE IF( .NOT.LOWER .AND. .NOT.LSAME( UPLO, 'U' ) ) THEN
229 ELSE IF( .NOT.NOTRANS .AND. .NOT.LSAME( TRANS, 'C' ) ) THEN
231 ELSE IF( N.LT.0 ) THEN
233 ELSE IF( K.LT.0 ) THEN
235 ELSE IF( LDA.LT.MAX( 1, NROWA ) ) THEN
239 CALL XERBLA( 'CHFRK ', -INFO )
243 * Quick return if possible.
245 * The quick return case: ((ALPHA.EQ.0).AND.(BETA.NE.ZERO)) is not
246 * done (it is in CHERK for example) and left in the general case.
248 IF( ( N.EQ.0 ) .OR. ( ( ( ALPHA.EQ.ZERO ) .OR. ( K.EQ.0 ) ) .AND.
249 $ ( BETA.EQ.ONE ) ) )RETURN
251 IF( ( ALPHA.EQ.ZERO ) .AND. ( BETA.EQ.ZERO ) ) THEN
252 DO J = 1, ( ( N*( N+1 ) ) / 2 )
258 CALPHA = CMPLX( ALPHA, ZERO )
259 CBETA = CMPLX( BETA, ZERO )
262 * If N is odd, set NISODD = .TRUE., and N1 and N2.
263 * If N is even, NISODD = .FALSE., and NK.
265 IF( MOD( N, 2 ).EQ.0 ) THEN
283 IF( NORMALTRANSR ) THEN
285 * N is odd and TRANSR = 'N'
289 * N is odd, TRANSR = 'N', and UPLO = 'L'
293 * N is odd, TRANSR = 'N', UPLO = 'L', and TRANS = 'N'
295 CALL CHERK( 'L', 'N', N1, K, ALPHA, A( 1, 1 ), LDA,
297 CALL CHERK( 'U', 'N', N2, K, ALPHA, A( N1+1, 1 ), LDA,
298 $ BETA, C( N+1 ), N )
299 CALL CGEMM( 'N', 'C', N2, N1, K, CALPHA, A( N1+1, 1 ),
300 $ LDA, A( 1, 1 ), LDA, CBETA, C( N1+1 ), N )
304 * N is odd, TRANSR = 'N', UPLO = 'L', and TRANS = 'C'
306 CALL CHERK( 'L', 'C', N1, K, ALPHA, A( 1, 1 ), LDA,
308 CALL CHERK( 'U', 'C', N2, K, ALPHA, A( 1, N1+1 ), LDA,
309 $ BETA, C( N+1 ), N )
310 CALL CGEMM( 'C', 'N', N2, N1, K, CALPHA, A( 1, N1+1 ),
311 $ LDA, A( 1, 1 ), LDA, CBETA, C( N1+1 ), N )
317 * N is odd, TRANSR = 'N', and UPLO = 'U'
321 * N is odd, TRANSR = 'N', UPLO = 'U', and TRANS = 'N'
323 CALL CHERK( 'L', 'N', N1, K, ALPHA, A( 1, 1 ), LDA,
324 $ BETA, C( N2+1 ), N )
325 CALL CHERK( 'U', 'N', N2, K, ALPHA, A( N2, 1 ), LDA,
326 $ BETA, C( N1+1 ), N )
327 CALL CGEMM( 'N', 'C', N1, N2, K, CALPHA, A( 1, 1 ),
328 $ LDA, A( N2, 1 ), LDA, CBETA, C( 1 ), N )
332 * N is odd, TRANSR = 'N', UPLO = 'U', and TRANS = 'C'
334 CALL CHERK( 'L', 'C', N1, K, ALPHA, A( 1, 1 ), LDA,
335 $ BETA, C( N2+1 ), N )
336 CALL CHERK( 'U', 'C', N2, K, ALPHA, A( 1, N2 ), LDA,
337 $ BETA, C( N1+1 ), N )
338 CALL CGEMM( 'C', 'N', N1, N2, K, CALPHA, A( 1, 1 ),
339 $ LDA, A( 1, N2 ), LDA, CBETA, C( 1 ), N )
347 * N is odd, and TRANSR = 'C'
351 * N is odd, TRANSR = 'C', and UPLO = 'L'
355 * N is odd, TRANSR = 'C', UPLO = 'L', and TRANS = 'N'
357 CALL CHERK( 'U', 'N', N1, K, ALPHA, A( 1, 1 ), LDA,
359 CALL CHERK( 'L', 'N', N2, K, ALPHA, A( N1+1, 1 ), LDA,
361 CALL CGEMM( 'N', 'C', N1, N2, K, CALPHA, A( 1, 1 ),
362 $ LDA, A( N1+1, 1 ), LDA, CBETA,
367 * N is odd, TRANSR = 'C', UPLO = 'L', and TRANS = 'C'
369 CALL CHERK( 'U', 'C', N1, K, ALPHA, A( 1, 1 ), LDA,
371 CALL CHERK( 'L', 'C', N2, K, ALPHA, A( 1, N1+1 ), LDA,
373 CALL CGEMM( 'C', 'N', N1, N2, K, CALPHA, A( 1, 1 ),
374 $ LDA, A( 1, N1+1 ), LDA, CBETA,
381 * N is odd, TRANSR = 'C', and UPLO = 'U'
385 * N is odd, TRANSR = 'C', UPLO = 'U', and TRANS = 'N'
387 CALL CHERK( 'U', 'N', N1, K, ALPHA, A( 1, 1 ), LDA,
388 $ BETA, C( N2*N2+1 ), N2 )
389 CALL CHERK( 'L', 'N', N2, K, ALPHA, A( N1+1, 1 ), LDA,
390 $ BETA, C( N1*N2+1 ), N2 )
391 CALL CGEMM( 'N', 'C', N2, N1, K, CALPHA, A( N1+1, 1 ),
392 $ LDA, A( 1, 1 ), LDA, CBETA, C( 1 ), N2 )
396 * N is odd, TRANSR = 'C', UPLO = 'U', and TRANS = 'C'
398 CALL CHERK( 'U', 'C', N1, K, ALPHA, A( 1, 1 ), LDA,
399 $ BETA, C( N2*N2+1 ), N2 )
400 CALL CHERK( 'L', 'C', N2, K, ALPHA, A( 1, N1+1 ), LDA,
401 $ BETA, C( N1*N2+1 ), N2 )
402 CALL CGEMM( 'C', 'N', N2, N1, K, CALPHA, A( 1, N1+1 ),
403 $ LDA, A( 1, 1 ), LDA, CBETA, C( 1 ), N2 )
415 IF( NORMALTRANSR ) THEN
417 * N is even and TRANSR = 'N'
421 * N is even, TRANSR = 'N', and UPLO = 'L'
425 * N is even, TRANSR = 'N', UPLO = 'L', and TRANS = 'N'
427 CALL CHERK( 'L', 'N', NK, K, ALPHA, A( 1, 1 ), LDA,
428 $ BETA, C( 2 ), N+1 )
429 CALL CHERK( 'U', 'N', NK, K, ALPHA, A( NK+1, 1 ), LDA,
430 $ BETA, C( 1 ), N+1 )
431 CALL CGEMM( 'N', 'C', NK, NK, K, CALPHA, A( NK+1, 1 ),
432 $ LDA, A( 1, 1 ), LDA, CBETA, C( NK+2 ),
437 * N is even, TRANSR = 'N', UPLO = 'L', and TRANS = 'C'
439 CALL CHERK( 'L', 'C', NK, K, ALPHA, A( 1, 1 ), LDA,
440 $ BETA, C( 2 ), N+1 )
441 CALL CHERK( 'U', 'C', NK, K, ALPHA, A( 1, NK+1 ), LDA,
442 $ BETA, C( 1 ), N+1 )
443 CALL CGEMM( 'C', 'N', NK, NK, K, CALPHA, A( 1, NK+1 ),
444 $ LDA, A( 1, 1 ), LDA, CBETA, C( NK+2 ),
451 * N is even, TRANSR = 'N', and UPLO = 'U'
455 * N is even, TRANSR = 'N', UPLO = 'U', and TRANS = 'N'
457 CALL CHERK( 'L', 'N', NK, K, ALPHA, A( 1, 1 ), LDA,
458 $ BETA, C( NK+2 ), N+1 )
459 CALL CHERK( 'U', 'N', NK, K, ALPHA, A( NK+1, 1 ), LDA,
460 $ BETA, C( NK+1 ), N+1 )
461 CALL CGEMM( 'N', 'C', NK, NK, K, CALPHA, A( 1, 1 ),
462 $ LDA, A( NK+1, 1 ), LDA, CBETA, C( 1 ),
467 * N is even, TRANSR = 'N', UPLO = 'U', and TRANS = 'C'
469 CALL CHERK( 'L', 'C', NK, K, ALPHA, A( 1, 1 ), LDA,
470 $ BETA, C( NK+2 ), N+1 )
471 CALL CHERK( 'U', 'C', NK, K, ALPHA, A( 1, NK+1 ), LDA,
472 $ BETA, C( NK+1 ), N+1 )
473 CALL CGEMM( 'C', 'N', NK, NK, K, CALPHA, A( 1, 1 ),
474 $ LDA, A( 1, NK+1 ), LDA, CBETA, C( 1 ),
483 * N is even, and TRANSR = 'C'
487 * N is even, TRANSR = 'C', and UPLO = 'L'
491 * N is even, TRANSR = 'C', UPLO = 'L', and TRANS = 'N'
493 CALL CHERK( 'U', 'N', NK, K, ALPHA, A( 1, 1 ), LDA,
494 $ BETA, C( NK+1 ), NK )
495 CALL CHERK( 'L', 'N', NK, K, ALPHA, A( NK+1, 1 ), LDA,
497 CALL CGEMM( 'N', 'C', NK, NK, K, CALPHA, A( 1, 1 ),
498 $ LDA, A( NK+1, 1 ), LDA, CBETA,
499 $ C( ( ( NK+1 )*NK )+1 ), NK )
503 * N is even, TRANSR = 'C', UPLO = 'L', and TRANS = 'C'
505 CALL CHERK( 'U', 'C', NK, K, ALPHA, A( 1, 1 ), LDA,
506 $ BETA, C( NK+1 ), NK )
507 CALL CHERK( 'L', 'C', NK, K, ALPHA, A( 1, NK+1 ), LDA,
509 CALL CGEMM( 'C', 'N', NK, NK, K, CALPHA, A( 1, 1 ),
510 $ LDA, A( 1, NK+1 ), LDA, CBETA,
511 $ C( ( ( NK+1 )*NK )+1 ), NK )
517 * N is even, TRANSR = 'C', and UPLO = 'U'
521 * N is even, TRANSR = 'C', UPLO = 'U', and TRANS = 'N'
523 CALL CHERK( 'U', 'N', NK, K, ALPHA, A( 1, 1 ), LDA,
524 $ BETA, C( NK*( NK+1 )+1 ), NK )
525 CALL CHERK( 'L', 'N', NK, K, ALPHA, A( NK+1, 1 ), LDA,
526 $ BETA, C( NK*NK+1 ), NK )
527 CALL CGEMM( 'N', 'C', NK, NK, K, CALPHA, A( NK+1, 1 ),
528 $ LDA, A( 1, 1 ), LDA, CBETA, C( 1 ), NK )
532 * N is even, TRANSR = 'C', UPLO = 'U', and TRANS = 'C'
534 CALL CHERK( 'U', 'C', NK, K, ALPHA, A( 1, 1 ), LDA,
535 $ BETA, C( NK*( NK+1 )+1 ), NK )
536 CALL CHERK( 'L', 'C', NK, K, ALPHA, A( 1, NK+1 ), LDA,
537 $ BETA, C( NK*NK+1 ), NK )
538 CALL CGEMM( 'C', 'N', NK, NK, K, CALPHA, A( 1, NK+1 ),
539 $ LDA, A( 1, 1 ), LDA, CBETA, C( 1 ), NK )