3
* =========== DOCUMENTATION ===========
5
* Online html documentation available at
6
* http://www.netlib.org/lapack/explore-html/
11
* SUBROUTINE DSYR2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
13
* .. Scalar Arguments ..
14
* DOUBLE PRECISION ALPHA,BETA
15
* INTEGER K,LDA,LDB,LDC,N
16
* CHARACTER TRANS,UPLO
18
* .. Array Arguments ..
19
* DOUBLE PRECISION A(LDA,*),B(LDB,*),C(LDC,*)
28
*> DSYR2K performs one of the symmetric rank 2k operations
30
*> C := alpha*A*B**T + alpha*B*A**T + beta*C,
34
*> C := alpha*A**T*B + alpha*B**T*A + beta*C,
36
*> where alpha and beta are scalars, C is an n by n symmetric matrix
37
*> and A and B are n by k matrices in the first case and k by n
38
*> matrices in the second case.
46
*> UPLO is CHARACTER*1
47
*> On entry, UPLO specifies whether the upper or lower
48
*> triangular part of the array C is to be referenced as
51
*> UPLO = 'U' or 'u' Only the upper triangular part of C
52
*> is to be referenced.
54
*> UPLO = 'L' or 'l' Only the lower triangular part of C
55
*> is to be referenced.
60
*> TRANS is CHARACTER*1
61
*> On entry, TRANS specifies the operation to be performed as
64
*> TRANS = 'N' or 'n' C := alpha*A*B**T + alpha*B*A**T +
67
*> TRANS = 'T' or 't' C := alpha*A**T*B + alpha*B**T*A +
70
*> TRANS = 'C' or 'c' C := alpha*A**T*B + alpha*B**T*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 = 'T' or 't' or 'C' or 'c', K specifies the number
87
*> of rows of the matrices A and B. K must be at least zero.
92
*> ALPHA is DOUBLE PRECISION.
93
*> On entry, ALPHA specifies the scalar alpha.
98
*> A is DOUBLE PRECISION 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 DOUBLE PRECISION 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 ).
136
*> BETA is DOUBLE PRECISION.
137
*> On entry, BETA specifies the scalar beta.
142
*> C is DOUBLE PRECISION array of DIMENSION ( LDC, n ).
143
*> Before entry with UPLO = 'U' or 'u', the leading n by n
144
*> upper triangular part of the array C must contain the upper
145
*> triangular part of the symmetric matrix and the strictly
146
*> lower triangular part of C is not referenced. On exit, the
147
*> upper triangular part of the array C is overwritten by the
148
*> upper triangular part of the updated matrix.
149
*> Before entry with UPLO = 'L' or 'l', the leading n by n
150
*> lower triangular part of the array C must contain the lower
151
*> triangular part of the symmetric matrix and the strictly
152
*> upper triangular part of C is not referenced. On exit, the
153
*> lower triangular part of the array C is overwritten by the
154
*> lower triangular part of the updated matrix.
160
*> On entry, LDC specifies the first dimension of C as declared
161
*> in the calling (sub) program. LDC must be at least
168
*> \author Univ. of Tennessee
169
*> \author Univ. of California Berkeley
170
*> \author Univ. of Colorado Denver
173
*> \date November 2011
175
*> \ingroup double_blas_level3
177
*> \par Further Details:
178
* =====================
182
*> Level 3 Blas routine.
185
*> -- Written on 8-February-1989.
186
*> Jack Dongarra, Argonne National Laboratory.
187
*> Iain Duff, AERE Harwell.
188
*> Jeremy Du Croz, Numerical Algorithms Group Ltd.
189
*> Sven Hammarling, Numerical Algorithms Group Ltd.
192
* =====================================================================
193
SUBROUTINE DSYR2K(UPLO,TRANS,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
195
* -- Reference BLAS level3 routine (version 3.4.0) --
196
* -- Reference BLAS is a software package provided by Univ. of Tennessee, --
197
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
200
* .. Scalar Arguments ..
201
DOUBLE PRECISION ALPHA,BETA
202
INTEGER K,LDA,LDB,LDC,N
205
* .. Array Arguments ..
206
DOUBLE PRECISION A(LDA,*),B(LDB,*),C(LDC,*)
209
* =====================================================================
211
* .. External Functions ..
215
* .. External Subroutines ..
218
* .. Intrinsic Functions ..
221
* .. Local Scalars ..
222
DOUBLE PRECISION TEMP1,TEMP2
223
INTEGER I,INFO,J,L,NROWA
227
DOUBLE PRECISION ONE,ZERO
228
PARAMETER (ONE=1.0D+0,ZERO=0.0D+0)
231
* Test the input parameters.
233
IF (LSAME(TRANS,'N')) THEN
238
UPPER = LSAME(UPLO,'U')
241
IF ((.NOT.UPPER) .AND. (.NOT.LSAME(UPLO,'L'))) THEN
243
ELSE IF ((.NOT.LSAME(TRANS,'N')) .AND.
244
+ (.NOT.LSAME(TRANS,'T')) .AND.
245
+ (.NOT.LSAME(TRANS,'C'))) THEN
247
ELSE IF (N.LT.0) THEN
249
ELSE IF (K.LT.0) THEN
251
ELSE IF (LDA.LT.MAX(1,NROWA)) THEN
253
ELSE IF (LDB.LT.MAX(1,NROWA)) THEN
255
ELSE IF (LDC.LT.MAX(1,N)) THEN
259
CALL XERBLA('DSYR2K',INFO)
263
* Quick return if possible.
265
IF ((N.EQ.0) .OR. (((ALPHA.EQ.ZERO).OR.
266
+ (K.EQ.0)).AND. (BETA.EQ.ONE))) RETURN
268
* And when alpha.eq.zero.
270
IF (ALPHA.EQ.ZERO) THEN
272
IF (BETA.EQ.ZERO) THEN
286
IF (BETA.EQ.ZERO) THEN
303
* Start the operations.
305
IF (LSAME(TRANS,'N')) THEN
307
* Form C := alpha*A*B**T + alpha*B*A**T + C.
311
IF (BETA.EQ.ZERO) THEN
315
ELSE IF (BETA.NE.ONE) THEN
321
IF ((A(J,L).NE.ZERO) .OR. (B(J,L).NE.ZERO)) THEN
325
C(I,J) = C(I,J) + A(I,L)*TEMP1 +
333
IF (BETA.EQ.ZERO) THEN
337
ELSE IF (BETA.NE.ONE) THEN
343
IF ((A(J,L).NE.ZERO) .OR. (B(J,L).NE.ZERO)) THEN
347
C(I,J) = C(I,J) + A(I,L)*TEMP1 +
356
* Form C := alpha*A**T*B + alpha*B**T*A + C.
364
TEMP1 = TEMP1 + A(L,I)*B(L,J)
365
TEMP2 = TEMP2 + B(L,I)*A(L,J)
367
IF (BETA.EQ.ZERO) THEN
368
C(I,J) = ALPHA*TEMP1 + ALPHA*TEMP2
370
C(I,J) = BETA*C(I,J) + ALPHA*TEMP1 +
381
TEMP1 = TEMP1 + A(L,I)*B(L,J)
382
TEMP2 = TEMP2 + B(L,I)*A(L,J)
384
IF (BETA.EQ.ZERO) THEN
385
C(I,J) = ALPHA*TEMP1 + ALPHA*TEMP2
387
C(I,J) = BETA*C(I,J) + ALPHA*TEMP1 +