1 *> \brief \b DSFRK performs a symmetric 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 DSFRK + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsfrk.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsfrk.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsfrk.f">
21 * SUBROUTINE DSFRK( 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 * DOUBLE PRECISION A( LDA, * ), C( * )
39 *> Level 3 BLAS like routine for C in RFP Format.
41 *> DSFRK performs one of the symmetric rank--k operations
43 *> C := alpha*A*A**T + beta*C,
47 *> C := alpha*A**T*A + beta*C,
49 *> where alpha and beta are real scalars, C is an n--by--n symmetric
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 *> = 'T': The 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**T + beta*C.
88 *> TRANS = 'T' or 't' C := alpha*A**T*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 TRANS = 'T'
106 *> or 't', K specifies the number of rows of the matrix A. K
107 *> 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 DOUBLE PRECISION 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.
141 *> BETA is DOUBLE PRECISION
142 *> On entry, BETA specifies the scalar beta.
143 *> Unchanged on exit.
148 *> C is DOUBLE PRECISION array, dimension (NT)
149 *> NT = N*(N+1)/2. On entry, the symmetric matrix C in RFP
150 *> Format. RFP Format is described by TRANSR, UPLO and N.
156 *> \author Univ. of Tennessee
157 *> \author Univ. of California Berkeley
158 *> \author Univ. of Colorado Denver
161 *> \date September 2012
163 *> \ingroup doubleOTHERcomputational
165 * =====================================================================
166 SUBROUTINE DSFRK( TRANSR, UPLO, TRANS, N, K, ALPHA, A, LDA, BETA,
169 * -- LAPACK computational routine (version 3.4.2) --
170 * -- LAPACK is a software package provided by Univ. of Tennessee, --
171 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
174 * .. Scalar Arguments ..
175 DOUBLE PRECISION ALPHA, BETA
177 CHARACTER TRANS, TRANSR, UPLO
179 * .. Array Arguments ..
180 DOUBLE PRECISION A( LDA, * ), C( * )
183 * =====================================================================
187 DOUBLE PRECISION ONE, ZERO
188 PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
190 * .. Local Scalars ..
191 LOGICAL LOWER, NORMALTRANSR, NISODD, NOTRANS
192 INTEGER INFO, NROWA, J, NK, N1, N2
194 * .. External Functions ..
198 * .. External Subroutines ..
199 EXTERNAL XERBLA, DGEMM, DSYRK
201 * .. Intrinsic Functions ..
204 * .. Executable Statements ..
206 * Test the input parameters.
209 NORMALTRANSR = LSAME( TRANSR, 'N' )
210 LOWER = LSAME( UPLO, 'L' )
211 NOTRANS = LSAME( TRANS, 'N' )
219 IF( .NOT.NORMALTRANSR .AND. .NOT.LSAME( TRANSR, 'T' ) ) THEN
221 ELSE IF( .NOT.LOWER .AND. .NOT.LSAME( UPLO, 'U' ) ) THEN
223 ELSE IF( .NOT.NOTRANS .AND. .NOT.LSAME( TRANS, 'T' ) ) THEN
225 ELSE IF( N.LT.0 ) THEN
227 ELSE IF( K.LT.0 ) THEN
229 ELSE IF( LDA.LT.MAX( 1, NROWA ) ) THEN
233 CALL XERBLA( 'DSFRK ', -INFO )
237 * Quick return if possible.
239 * The quick return case: ((ALPHA.EQ.0).AND.(BETA.NE.ZERO)) is not
240 * done (it is in DSYRK for example) and left in the general case.
242 IF( ( N.EQ.0 ) .OR. ( ( ( ALPHA.EQ.ZERO ) .OR. ( K.EQ.0 ) ) .AND.
243 $ ( BETA.EQ.ONE ) ) )RETURN
245 IF( ( ALPHA.EQ.ZERO ) .AND. ( BETA.EQ.ZERO ) ) THEN
246 DO J = 1, ( ( N*( N+1 ) ) / 2 )
253 * If N is odd, set NISODD = .TRUE., and N1 and N2.
254 * If N is even, NISODD = .FALSE., and NK.
256 IF( MOD( N, 2 ).EQ.0 ) THEN
274 IF( NORMALTRANSR ) THEN
276 * N is odd and TRANSR = 'N'
280 * N is odd, TRANSR = 'N', and UPLO = 'L'
284 * N is odd, TRANSR = 'N', UPLO = 'L', and TRANS = 'N'
286 CALL DSYRK( 'L', 'N', N1, K, ALPHA, A( 1, 1 ), LDA,
288 CALL DSYRK( 'U', 'N', N2, K, ALPHA, A( N1+1, 1 ), LDA,
289 $ BETA, C( N+1 ), N )
290 CALL DGEMM( 'N', 'T', N2, N1, K, ALPHA, A( N1+1, 1 ),
291 $ LDA, A( 1, 1 ), LDA, BETA, C( N1+1 ), N )
295 * N is odd, TRANSR = 'N', UPLO = 'L', and TRANS = 'T'
297 CALL DSYRK( 'L', 'T', N1, K, ALPHA, A( 1, 1 ), LDA,
299 CALL DSYRK( 'U', 'T', N2, K, ALPHA, A( 1, N1+1 ), LDA,
300 $ BETA, C( N+1 ), N )
301 CALL DGEMM( 'T', 'N', N2, N1, K, ALPHA, A( 1, N1+1 ),
302 $ LDA, A( 1, 1 ), LDA, BETA, C( N1+1 ), N )
308 * N is odd, TRANSR = 'N', and UPLO = 'U'
312 * N is odd, TRANSR = 'N', UPLO = 'U', and TRANS = 'N'
314 CALL DSYRK( 'L', 'N', N1, K, ALPHA, A( 1, 1 ), LDA,
315 $ BETA, C( N2+1 ), N )
316 CALL DSYRK( 'U', 'N', N2, K, ALPHA, A( N2, 1 ), LDA,
317 $ BETA, C( N1+1 ), N )
318 CALL DGEMM( 'N', 'T', N1, N2, K, ALPHA, A( 1, 1 ),
319 $ LDA, A( N2, 1 ), LDA, BETA, C( 1 ), N )
323 * N is odd, TRANSR = 'N', UPLO = 'U', and TRANS = 'T'
325 CALL DSYRK( 'L', 'T', N1, K, ALPHA, A( 1, 1 ), LDA,
326 $ BETA, C( N2+1 ), N )
327 CALL DSYRK( 'U', 'T', N2, K, ALPHA, A( 1, N2 ), LDA,
328 $ BETA, C( N1+1 ), N )
329 CALL DGEMM( 'T', 'N', N1, N2, K, ALPHA, A( 1, 1 ),
330 $ LDA, A( 1, N2 ), LDA, BETA, C( 1 ), N )
338 * N is odd, and TRANSR = 'T'
342 * N is odd, TRANSR = 'T', and UPLO = 'L'
346 * N is odd, TRANSR = 'T', UPLO = 'L', and TRANS = 'N'
348 CALL DSYRK( 'U', 'N', N1, K, ALPHA, A( 1, 1 ), LDA,
350 CALL DSYRK( 'L', 'N', N2, K, ALPHA, A( N1+1, 1 ), LDA,
352 CALL DGEMM( 'N', 'T', N1, N2, K, ALPHA, A( 1, 1 ),
353 $ LDA, A( N1+1, 1 ), LDA, BETA,
358 * N is odd, TRANSR = 'T', UPLO = 'L', and TRANS = 'T'
360 CALL DSYRK( 'U', 'T', N1, K, ALPHA, A( 1, 1 ), LDA,
362 CALL DSYRK( 'L', 'T', N2, K, ALPHA, A( 1, N1+1 ), LDA,
364 CALL DGEMM( 'T', 'N', N1, N2, K, ALPHA, A( 1, 1 ),
365 $ LDA, A( 1, N1+1 ), LDA, BETA,
372 * N is odd, TRANSR = 'T', and UPLO = 'U'
376 * N is odd, TRANSR = 'T', UPLO = 'U', and TRANS = 'N'
378 CALL DSYRK( 'U', 'N', N1, K, ALPHA, A( 1, 1 ), LDA,
379 $ BETA, C( N2*N2+1 ), N2 )
380 CALL DSYRK( 'L', 'N', N2, K, ALPHA, A( N1+1, 1 ), LDA,
381 $ BETA, C( N1*N2+1 ), N2 )
382 CALL DGEMM( 'N', 'T', N2, N1, K, ALPHA, A( N1+1, 1 ),
383 $ LDA, A( 1, 1 ), LDA, BETA, C( 1 ), N2 )
387 * N is odd, TRANSR = 'T', UPLO = 'U', and TRANS = 'T'
389 CALL DSYRK( 'U', 'T', N1, K, ALPHA, A( 1, 1 ), LDA,
390 $ BETA, C( N2*N2+1 ), N2 )
391 CALL DSYRK( 'L', 'T', N2, K, ALPHA, A( 1, N1+1 ), LDA,
392 $ BETA, C( N1*N2+1 ), N2 )
393 CALL DGEMM( 'T', 'N', N2, N1, K, ALPHA, A( 1, N1+1 ),
394 $ LDA, A( 1, 1 ), LDA, BETA, C( 1 ), N2 )
406 IF( NORMALTRANSR ) THEN
408 * N is even and TRANSR = 'N'
412 * N is even, TRANSR = 'N', and UPLO = 'L'
416 * N is even, TRANSR = 'N', UPLO = 'L', and TRANS = 'N'
418 CALL DSYRK( 'L', 'N', NK, K, ALPHA, A( 1, 1 ), LDA,
419 $ BETA, C( 2 ), N+1 )
420 CALL DSYRK( 'U', 'N', NK, K, ALPHA, A( NK+1, 1 ), LDA,
421 $ BETA, C( 1 ), N+1 )
422 CALL DGEMM( 'N', 'T', NK, NK, K, ALPHA, A( NK+1, 1 ),
423 $ LDA, A( 1, 1 ), LDA, BETA, C( NK+2 ),
428 * N is even, TRANSR = 'N', UPLO = 'L', and TRANS = 'T'
430 CALL DSYRK( 'L', 'T', NK, K, ALPHA, A( 1, 1 ), LDA,
431 $ BETA, C( 2 ), N+1 )
432 CALL DSYRK( 'U', 'T', NK, K, ALPHA, A( 1, NK+1 ), LDA,
433 $ BETA, C( 1 ), N+1 )
434 CALL DGEMM( 'T', 'N', NK, NK, K, ALPHA, A( 1, NK+1 ),
435 $ LDA, A( 1, 1 ), LDA, BETA, C( NK+2 ),
442 * N is even, TRANSR = 'N', and UPLO = 'U'
446 * N is even, TRANSR = 'N', UPLO = 'U', and TRANS = 'N'
448 CALL DSYRK( 'L', 'N', NK, K, ALPHA, A( 1, 1 ), LDA,
449 $ BETA, C( NK+2 ), N+1 )
450 CALL DSYRK( 'U', 'N', NK, K, ALPHA, A( NK+1, 1 ), LDA,
451 $ BETA, C( NK+1 ), N+1 )
452 CALL DGEMM( 'N', 'T', NK, NK, K, ALPHA, A( 1, 1 ),
453 $ LDA, A( NK+1, 1 ), LDA, BETA, C( 1 ),
458 * N is even, TRANSR = 'N', UPLO = 'U', and TRANS = 'T'
460 CALL DSYRK( 'L', 'T', NK, K, ALPHA, A( 1, 1 ), LDA,
461 $ BETA, C( NK+2 ), N+1 )
462 CALL DSYRK( 'U', 'T', NK, K, ALPHA, A( 1, NK+1 ), LDA,
463 $ BETA, C( NK+1 ), N+1 )
464 CALL DGEMM( 'T', 'N', NK, NK, K, ALPHA, A( 1, 1 ),
465 $ LDA, A( 1, NK+1 ), LDA, BETA, C( 1 ),
474 * N is even, and TRANSR = 'T'
478 * N is even, TRANSR = 'T', and UPLO = 'L'
482 * N is even, TRANSR = 'T', UPLO = 'L', and TRANS = 'N'
484 CALL DSYRK( 'U', 'N', NK, K, ALPHA, A( 1, 1 ), LDA,
485 $ BETA, C( NK+1 ), NK )
486 CALL DSYRK( 'L', 'N', NK, K, ALPHA, A( NK+1, 1 ), LDA,
488 CALL DGEMM( 'N', 'T', NK, NK, K, ALPHA, A( 1, 1 ),
489 $ LDA, A( NK+1, 1 ), LDA, BETA,
490 $ C( ( ( NK+1 )*NK )+1 ), NK )
494 * N is even, TRANSR = 'T', UPLO = 'L', and TRANS = 'T'
496 CALL DSYRK( 'U', 'T', NK, K, ALPHA, A( 1, 1 ), LDA,
497 $ BETA, C( NK+1 ), NK )
498 CALL DSYRK( 'L', 'T', NK, K, ALPHA, A( 1, NK+1 ), LDA,
500 CALL DGEMM( 'T', 'N', NK, NK, K, ALPHA, A( 1, 1 ),
501 $ LDA, A( 1, NK+1 ), LDA, BETA,
502 $ C( ( ( NK+1 )*NK )+1 ), NK )
508 * N is even, TRANSR = 'T', and UPLO = 'U'
512 * N is even, TRANSR = 'T', UPLO = 'U', and TRANS = 'N'
514 CALL DSYRK( 'U', 'N', NK, K, ALPHA, A( 1, 1 ), LDA,
515 $ BETA, C( NK*( NK+1 )+1 ), NK )
516 CALL DSYRK( 'L', 'N', NK, K, ALPHA, A( NK+1, 1 ), LDA,
517 $ BETA, C( NK*NK+1 ), NK )
518 CALL DGEMM( 'N', 'T', NK, NK, K, ALPHA, A( NK+1, 1 ),
519 $ LDA, A( 1, 1 ), LDA, BETA, C( 1 ), NK )
523 * N is even, TRANSR = 'T', UPLO = 'U', and TRANS = 'T'
525 CALL DSYRK( 'U', 'T', NK, K, ALPHA, A( 1, 1 ), LDA,
526 $ BETA, C( NK*( NK+1 )+1 ), NK )
527 CALL DSYRK( 'L', 'T', NK, K, ALPHA, A( 1, NK+1 ), LDA,
528 $ BETA, C( NK*NK+1 ), NK )
529 CALL DGEMM( 'T', 'N', NK, NK, K, ALPHA, A( 1, NK+1 ),
530 $ LDA, A( 1, 1 ), LDA, BETA, C( 1 ), NK )