1 *> \brief \b SSFRK 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 SSFRK + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ssfrk.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ssfrk.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ssfrk.f">
21 * SUBROUTINE SSFRK( TRANSR, UPLO, TRANS, N, K, ALPHA, A, LDA, BETA,
24 * .. Scalar Arguments ..
27 * CHARACTER TRANS, TRANSR, UPLO
29 * .. Array Arguments ..
30 * REAL A( LDA, * ), C( * )
39 *> Level 3 BLAS like routine for C in RFP Format.
41 *> SSFRK 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.
114 *> On entry, ALPHA specifies the scalar alpha.
115 *> Unchanged on exit.
120 *> A is REAL 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.
142 *> On entry, BETA specifies the scalar beta.
143 *> Unchanged on exit.
148 *> C is REAL 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 realOTHERcomputational
165 * =====================================================================
166 SUBROUTINE SSFRK( 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 ..
177 CHARACTER TRANS, TRANSR, UPLO
179 * .. Array Arguments ..
180 REAL A( LDA, * ), C( * )
183 * =====================================================================
187 PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
189 * .. Local Scalars ..
190 LOGICAL LOWER, NORMALTRANSR, NISODD, NOTRANS
191 INTEGER INFO, NROWA, J, NK, N1, N2
193 * .. External Functions ..
197 * .. External Subroutines ..
198 EXTERNAL SGEMM, SSYRK, XERBLA
200 * .. Intrinsic Functions ..
203 * .. Executable Statements ..
205 * Test the input parameters.
208 NORMALTRANSR = LSAME( TRANSR, 'N' )
209 LOWER = LSAME( UPLO, 'L' )
210 NOTRANS = LSAME( TRANS, 'N' )
218 IF( .NOT.NORMALTRANSR .AND. .NOT.LSAME( TRANSR, 'T' ) ) THEN
220 ELSE IF( .NOT.LOWER .AND. .NOT.LSAME( UPLO, 'U' ) ) THEN
222 ELSE IF( .NOT.NOTRANS .AND. .NOT.LSAME( TRANS, 'T' ) ) THEN
224 ELSE IF( N.LT.0 ) THEN
226 ELSE IF( K.LT.0 ) THEN
228 ELSE IF( LDA.LT.MAX( 1, NROWA ) ) THEN
232 CALL XERBLA( 'SSFRK ', -INFO )
236 * Quick return if possible.
238 * The quick return case: ((ALPHA.EQ.0).AND.(BETA.NE.ZERO)) is not
239 * done (it is in SSYRK for example) and left in the general case.
241 IF( ( N.EQ.0 ) .OR. ( ( ( ALPHA.EQ.ZERO ) .OR. ( K.EQ.0 ) ) .AND.
242 $ ( BETA.EQ.ONE ) ) )RETURN
244 IF( ( ALPHA.EQ.ZERO ) .AND. ( BETA.EQ.ZERO ) ) THEN
245 DO J = 1, ( ( N*( N+1 ) ) / 2 )
252 * If N is odd, set NISODD = .TRUE., and N1 and N2.
253 * If N is even, NISODD = .FALSE., and NK.
255 IF( MOD( N, 2 ).EQ.0 ) THEN
273 IF( NORMALTRANSR ) THEN
275 * N is odd and TRANSR = 'N'
279 * N is odd, TRANSR = 'N', and UPLO = 'L'
283 * N is odd, TRANSR = 'N', UPLO = 'L', and TRANS = 'N'
285 CALL SSYRK( 'L', 'N', N1, K, ALPHA, A( 1, 1 ), LDA,
287 CALL SSYRK( 'U', 'N', N2, K, ALPHA, A( N1+1, 1 ), LDA,
288 $ BETA, C( N+1 ), N )
289 CALL SGEMM( 'N', 'T', N2, N1, K, ALPHA, A( N1+1, 1 ),
290 $ LDA, A( 1, 1 ), LDA, BETA, C( N1+1 ), N )
294 * N is odd, TRANSR = 'N', UPLO = 'L', and TRANS = 'T'
296 CALL SSYRK( 'L', 'T', N1, K, ALPHA, A( 1, 1 ), LDA,
298 CALL SSYRK( 'U', 'T', N2, K, ALPHA, A( 1, N1+1 ), LDA,
299 $ BETA, C( N+1 ), N )
300 CALL SGEMM( 'T', 'N', N2, N1, K, ALPHA, A( 1, N1+1 ),
301 $ LDA, A( 1, 1 ), LDA, BETA, C( N1+1 ), N )
307 * N is odd, TRANSR = 'N', and UPLO = 'U'
311 * N is odd, TRANSR = 'N', UPLO = 'U', and TRANS = 'N'
313 CALL SSYRK( 'L', 'N', N1, K, ALPHA, A( 1, 1 ), LDA,
314 $ BETA, C( N2+1 ), N )
315 CALL SSYRK( 'U', 'N', N2, K, ALPHA, A( N2, 1 ), LDA,
316 $ BETA, C( N1+1 ), N )
317 CALL SGEMM( 'N', 'T', N1, N2, K, ALPHA, A( 1, 1 ),
318 $ LDA, A( N2, 1 ), LDA, BETA, C( 1 ), N )
322 * N is odd, TRANSR = 'N', UPLO = 'U', and TRANS = 'T'
324 CALL SSYRK( 'L', 'T', N1, K, ALPHA, A( 1, 1 ), LDA,
325 $ BETA, C( N2+1 ), N )
326 CALL SSYRK( 'U', 'T', N2, K, ALPHA, A( 1, N2 ), LDA,
327 $ BETA, C( N1+1 ), N )
328 CALL SGEMM( 'T', 'N', N1, N2, K, ALPHA, A( 1, 1 ),
329 $ LDA, A( 1, N2 ), LDA, BETA, C( 1 ), N )
337 * N is odd, and TRANSR = 'T'
341 * N is odd, TRANSR = 'T', and UPLO = 'L'
345 * N is odd, TRANSR = 'T', UPLO = 'L', and TRANS = 'N'
347 CALL SSYRK( 'U', 'N', N1, K, ALPHA, A( 1, 1 ), LDA,
349 CALL SSYRK( 'L', 'N', N2, K, ALPHA, A( N1+1, 1 ), LDA,
351 CALL SGEMM( 'N', 'T', N1, N2, K, ALPHA, A( 1, 1 ),
352 $ LDA, A( N1+1, 1 ), LDA, BETA,
357 * N is odd, TRANSR = 'T', UPLO = 'L', and TRANS = 'T'
359 CALL SSYRK( 'U', 'T', N1, K, ALPHA, A( 1, 1 ), LDA,
361 CALL SSYRK( 'L', 'T', N2, K, ALPHA, A( 1, N1+1 ), LDA,
363 CALL SGEMM( 'T', 'N', N1, N2, K, ALPHA, A( 1, 1 ),
364 $ LDA, A( 1, N1+1 ), LDA, BETA,
371 * N is odd, TRANSR = 'T', and UPLO = 'U'
375 * N is odd, TRANSR = 'T', UPLO = 'U', and TRANS = 'N'
377 CALL SSYRK( 'U', 'N', N1, K, ALPHA, A( 1, 1 ), LDA,
378 $ BETA, C( N2*N2+1 ), N2 )
379 CALL SSYRK( 'L', 'N', N2, K, ALPHA, A( N1+1, 1 ), LDA,
380 $ BETA, C( N1*N2+1 ), N2 )
381 CALL SGEMM( 'N', 'T', N2, N1, K, ALPHA, A( N1+1, 1 ),
382 $ LDA, A( 1, 1 ), LDA, BETA, C( 1 ), N2 )
386 * N is odd, TRANSR = 'T', UPLO = 'U', and TRANS = 'T'
388 CALL SSYRK( 'U', 'T', N1, K, ALPHA, A( 1, 1 ), LDA,
389 $ BETA, C( N2*N2+1 ), N2 )
390 CALL SSYRK( 'L', 'T', N2, K, ALPHA, A( 1, N1+1 ), LDA,
391 $ BETA, C( N1*N2+1 ), N2 )
392 CALL SGEMM( 'T', 'N', N2, N1, K, ALPHA, A( 1, N1+1 ),
393 $ LDA, A( 1, 1 ), LDA, BETA, C( 1 ), N2 )
405 IF( NORMALTRANSR ) THEN
407 * N is even and TRANSR = 'N'
411 * N is even, TRANSR = 'N', and UPLO = 'L'
415 * N is even, TRANSR = 'N', UPLO = 'L', and TRANS = 'N'
417 CALL SSYRK( 'L', 'N', NK, K, ALPHA, A( 1, 1 ), LDA,
418 $ BETA, C( 2 ), N+1 )
419 CALL SSYRK( 'U', 'N', NK, K, ALPHA, A( NK+1, 1 ), LDA,
420 $ BETA, C( 1 ), N+1 )
421 CALL SGEMM( 'N', 'T', NK, NK, K, ALPHA, A( NK+1, 1 ),
422 $ LDA, A( 1, 1 ), LDA, BETA, C( NK+2 ),
427 * N is even, TRANSR = 'N', UPLO = 'L', and TRANS = 'T'
429 CALL SSYRK( 'L', 'T', NK, K, ALPHA, A( 1, 1 ), LDA,
430 $ BETA, C( 2 ), N+1 )
431 CALL SSYRK( 'U', 'T', NK, K, ALPHA, A( 1, NK+1 ), LDA,
432 $ BETA, C( 1 ), N+1 )
433 CALL SGEMM( 'T', 'N', NK, NK, K, ALPHA, A( 1, NK+1 ),
434 $ LDA, A( 1, 1 ), LDA, BETA, C( NK+2 ),
441 * N is even, TRANSR = 'N', and UPLO = 'U'
445 * N is even, TRANSR = 'N', UPLO = 'U', and TRANS = 'N'
447 CALL SSYRK( 'L', 'N', NK, K, ALPHA, A( 1, 1 ), LDA,
448 $ BETA, C( NK+2 ), N+1 )
449 CALL SSYRK( 'U', 'N', NK, K, ALPHA, A( NK+1, 1 ), LDA,
450 $ BETA, C( NK+1 ), N+1 )
451 CALL SGEMM( 'N', 'T', NK, NK, K, ALPHA, A( 1, 1 ),
452 $ LDA, A( NK+1, 1 ), LDA, BETA, C( 1 ),
457 * N is even, TRANSR = 'N', UPLO = 'U', and TRANS = 'T'
459 CALL SSYRK( 'L', 'T', NK, K, ALPHA, A( 1, 1 ), LDA,
460 $ BETA, C( NK+2 ), N+1 )
461 CALL SSYRK( 'U', 'T', NK, K, ALPHA, A( 1, NK+1 ), LDA,
462 $ BETA, C( NK+1 ), N+1 )
463 CALL SGEMM( 'T', 'N', NK, NK, K, ALPHA, A( 1, 1 ),
464 $ LDA, A( 1, NK+1 ), LDA, BETA, C( 1 ),
473 * N is even, and TRANSR = 'T'
477 * N is even, TRANSR = 'T', and UPLO = 'L'
481 * N is even, TRANSR = 'T', UPLO = 'L', and TRANS = 'N'
483 CALL SSYRK( 'U', 'N', NK, K, ALPHA, A( 1, 1 ), LDA,
484 $ BETA, C( NK+1 ), NK )
485 CALL SSYRK( 'L', 'N', NK, K, ALPHA, A( NK+1, 1 ), LDA,
487 CALL SGEMM( 'N', 'T', NK, NK, K, ALPHA, A( 1, 1 ),
488 $ LDA, A( NK+1, 1 ), LDA, BETA,
489 $ C( ( ( NK+1 )*NK )+1 ), NK )
493 * N is even, TRANSR = 'T', UPLO = 'L', and TRANS = 'T'
495 CALL SSYRK( 'U', 'T', NK, K, ALPHA, A( 1, 1 ), LDA,
496 $ BETA, C( NK+1 ), NK )
497 CALL SSYRK( 'L', 'T', NK, K, ALPHA, A( 1, NK+1 ), LDA,
499 CALL SGEMM( 'T', 'N', NK, NK, K, ALPHA, A( 1, 1 ),
500 $ LDA, A( 1, NK+1 ), LDA, BETA,
501 $ C( ( ( NK+1 )*NK )+1 ), NK )
507 * N is even, TRANSR = 'T', and UPLO = 'U'
511 * N is even, TRANSR = 'T', UPLO = 'U', and TRANS = 'N'
513 CALL SSYRK( 'U', 'N', NK, K, ALPHA, A( 1, 1 ), LDA,
514 $ BETA, C( NK*( NK+1 )+1 ), NK )
515 CALL SSYRK( 'L', 'N', NK, K, ALPHA, A( NK+1, 1 ), LDA,
516 $ BETA, C( NK*NK+1 ), NK )
517 CALL SGEMM( 'N', 'T', NK, NK, K, ALPHA, A( NK+1, 1 ),
518 $ LDA, A( 1, 1 ), LDA, BETA, C( 1 ), NK )
522 * N is even, TRANSR = 'T', UPLO = 'U', and TRANS = 'T'
524 CALL SSYRK( 'U', 'T', NK, K, ALPHA, A( 1, 1 ), LDA,
525 $ BETA, C( NK*( NK+1 )+1 ), NK )
526 CALL SSYRK( 'L', 'T', NK, K, ALPHA, A( 1, NK+1 ), LDA,
527 $ BETA, C( NK*NK+1 ), NK )
528 CALL SGEMM( 'T', 'N', NK, NK, K, ALPHA, A( 1, NK+1 ),
529 $ LDA, A( 1, 1 ), LDA, BETA, C( 1 ), NK )