1
SUBROUTINE DSYR2 ( UPLO, N, ALPHA, X, INCX, Y, INCY, A, LDA )
3
* $Id: dsyr2.f 19695 2010-10-29 16:51:02Z d3y133 $
3
* =========== DOCUMENTATION ===========
5
* Online html documentation available at
6
* http://www.netlib.org/lapack/explore-html/
11
* SUBROUTINE DSYR2(UPLO,N,ALPHA,X,INCX,Y,INCY,A,LDA)
13
* .. Scalar Arguments ..
14
* DOUBLE PRECISION ALPHA
15
* INTEGER INCX,INCY,LDA,N
18
* .. Array Arguments ..
19
* DOUBLE PRECISION A(LDA,*),X(*),Y(*)
28
*> DSYR2 performs the symmetric rank 2 operation
30
*> A := alpha*x*y**T + alpha*y*x**T + A,
32
*> where alpha is a scalar, x and y are n element vectors and A is an n
33
*> by n symmetric matrix.
41
*> UPLO is CHARACTER*1
42
*> On entry, UPLO specifies whether the upper or lower
43
*> triangular part of the array A is to be referenced as
46
*> UPLO = 'U' or 'u' Only the upper triangular part of A
47
*> is to be referenced.
49
*> UPLO = 'L' or 'l' Only the lower triangular part of A
50
*> is to be referenced.
56
*> On entry, N specifies the order of the matrix A.
57
*> N must be at least zero.
62
*> ALPHA is DOUBLE PRECISION.
63
*> On entry, ALPHA specifies the scalar alpha.
68
*> X is DOUBLE PRECISION array of dimension at least
69
*> ( 1 + ( n - 1 )*abs( INCX ) ).
70
*> Before entry, the incremented array X must contain the n
77
*> On entry, INCX specifies the increment for the elements of
78
*> X. INCX must not be zero.
83
*> Y is DOUBLE PRECISION array of dimension at least
84
*> ( 1 + ( n - 1 )*abs( INCY ) ).
85
*> Before entry, the incremented array Y must contain the n
92
*> On entry, INCY specifies the increment for the elements of
93
*> Y. INCY must not be zero.
98
*> A is DOUBLE PRECISION array of DIMENSION ( LDA, n ).
99
*> Before entry with UPLO = 'U' or 'u', the leading n by n
100
*> upper triangular part of the array A must contain the upper
101
*> triangular part of the symmetric matrix and the strictly
102
*> lower triangular part of A is not referenced. On exit, the
103
*> upper triangular part of the array A is overwritten by the
104
*> upper triangular part of the updated matrix.
105
*> Before entry with UPLO = 'L' or 'l', the leading n by n
106
*> lower triangular part of the array A must contain the lower
107
*> triangular part of the symmetric matrix and the strictly
108
*> upper triangular part of A is not referenced. On exit, the
109
*> lower triangular part of the array A is overwritten by the
110
*> lower triangular part of the updated matrix.
116
*> On entry, LDA specifies the first dimension of A as declared
117
*> in the calling (sub) program. LDA must be at least
124
*> \author Univ. of Tennessee
125
*> \author Univ. of California Berkeley
126
*> \author Univ. of Colorado Denver
129
*> \date November 2011
131
*> \ingroup double_blas_level2
133
*> \par Further Details:
134
* =====================
138
*> Level 2 Blas routine.
140
*> -- Written on 22-October-1986.
141
*> Jack Dongarra, Argonne National Lab.
142
*> Jeremy Du Croz, Nag Central Office.
143
*> Sven Hammarling, Nag Central Office.
144
*> Richard Hanson, Sandia National Labs.
147
* =====================================================================
148
SUBROUTINE DSYR2(UPLO,N,ALPHA,X,INCX,Y,INCY,A,LDA)
150
* -- Reference BLAS level2 routine (version 3.4.0) --
151
* -- Reference BLAS is a software package provided by Univ. of Tennessee, --
152
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
5
155
* .. Scalar Arguments ..
7
INTEGER INCX, INCY, LDA, N
156
DOUBLE PRECISION ALPHA
157
INTEGER INCX,INCY,LDA,N
9
160
* .. Array Arguments ..
10
DOUBLE PRECISION A( LDA, * ), X( * ), Y( * )
161
DOUBLE PRECISION A(LDA,*),X(*),Y(*)
16
* DSYR2 performs the symmetric rank 2 operation
18
* A := alpha*x*y' + alpha*y*x' + A,
20
* where alpha is a scalar, x and y are n element vectors and A is an n
21
* by n symmetric matrix.
27
* On entry, UPLO specifies whether the upper or lower
28
* triangular part of the array A is to be referenced as
31
* UPLO = 'U' or 'u' Only the upper triangular part of A
32
* is to be referenced.
34
* UPLO = 'L' or 'l' Only the lower triangular part of A
35
* is to be referenced.
40
* On entry, N specifies the order of the matrix A.
41
* N must be at least zero.
44
* ALPHA - DOUBLE PRECISION.
45
* On entry, ALPHA specifies the scalar alpha.
48
* X - DOUBLE PRECISION array of dimension at least
49
* ( 1 + ( n - 1 )*abs( INCX ) ).
50
* Before entry, the incremented array X must contain the n
55
* On entry, INCX specifies the increment for the elements of
56
* X. INCX must not be zero.
59
* Y - DOUBLE PRECISION array of dimension at least
60
* ( 1 + ( n - 1 )*abs( INCY ) ).
61
* Before entry, the incremented array Y must contain the n
66
* On entry, INCY specifies the increment for the elements of
67
* Y. INCY must not be zero.
70
* A - DOUBLE PRECISION array of DIMENSION ( LDA, n ).
71
* Before entry with UPLO = 'U' or 'u', the leading n by n
72
* upper triangular part of the array A must contain the upper
73
* triangular part of the symmetric matrix and the strictly
74
* lower triangular part of A is not referenced. On exit, the
75
* upper triangular part of the array A is overwritten by the
76
* upper triangular part of the updated matrix.
77
* Before entry with UPLO = 'L' or 'l', the leading n by n
78
* lower triangular part of the array A must contain the lower
79
* triangular part of the symmetric matrix and the strictly
80
* upper triangular part of A is not referenced. On exit, the
81
* lower triangular part of the array A is overwritten by the
82
* lower triangular part of the updated matrix.
85
* On entry, LDA specifies the first dimension of A as declared
86
* in the calling (sub) program. LDA must be at least
91
* Level 2 Blas routine.
93
* -- Written on 22-October-1986.
94
* Jack Dongarra, Argonne National Lab.
95
* Jeremy Du Croz, Nag Central Office.
96
* Sven Hammarling, Nag Central Office.
97
* Richard Hanson, Sandia National Labs.
164
* =====================================================================
100
166
* .. Parameters ..
101
DOUBLE PRECISION ZERO
102
PARAMETER ( ZERO = 0.0D+0 )
167
DOUBLE PRECISION ZERO
168
PARAMETER (ZERO=0.0D+0)
103
170
* .. Local Scalars ..
104
DOUBLE PRECISION TEMP1, TEMP2
105
INTEGER I, INFO, IX, IY, J, JX, JY, KX, KY
171
DOUBLE PRECISION TEMP1,TEMP2
172
INTEGER I,INFO,IX,IY,J,JX,JY,KX,KY
106
174
* .. External Functions ..
109
178
* .. External Subroutines ..
111
181
* .. Intrinsic Functions ..
114
* .. Executable Statements ..
116
185
* Test the input parameters.
119
IF ( .NOT.LSAME( UPLO, 'U' ).AND.
120
$ .NOT.LSAME( UPLO, 'L' ) )THEN
122
ELSE IF( N.LT.0 )THEN
124
ELSE IF( INCX.EQ.0 )THEN
126
ELSE IF( INCY.EQ.0 )THEN
128
ELSE IF( LDA.LT.MAX( 1, N ) )THEN
188
IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
190
ELSE IF (N.LT.0) THEN
192
ELSE IF (INCX.EQ.0) THEN
194
ELSE IF (INCY.EQ.0) THEN
196
ELSE IF (LDA.LT.MAX(1,N)) THEN
132
CALL XERBLA( 'DSYR2 ', INFO )
200
CALL XERBLA('DSYR2 ',INFO)
136
204
* Quick return if possible.
138
IF( ( N.EQ.0 ).OR.( ALPHA.EQ.ZERO ) )
206
IF ((N.EQ.0) .OR. (ALPHA.EQ.ZERO)) RETURN
141
208
* Set up the start points in X and Y if the increments are not both
143
* The next 4 lines are to satisfy compiler warnings.
149
IF( ( INCX.NE.1 ).OR.( INCY.NE.1 ) )THEN
153
KX = 1 - ( N - 1 )*INCX
158
KY = 1 - ( N - 1 )*INCY
211
IF ((INCX.NE.1) .OR. (INCY.NE.1)) THEN
164
226
* Start the operations. In this version the elements of A are
165
227
* accessed sequentially with one pass through the triangular part
168
IF( LSAME( UPLO, 'U' ) )THEN
230
IF (LSAME(UPLO,'U')) THEN
170
232
* Form A when A is stored in the upper triangle.
172
IF( ( INCX.EQ.1 ).AND.( INCY.EQ.1 ) )THEN
174
IF( ( X( J ).NE.ZERO ).OR.( Y( J ).NE.ZERO ) )THEN
178
A( I, J ) = A( I, J ) + X( I )*TEMP1 + Y( I )*TEMP2
184
IF( ( X( JX ).NE.ZERO ).OR.( Y( JY ).NE.ZERO ) )THEN
185
TEMP1 = ALPHA*Y( JY )
186
TEMP2 = ALPHA*X( JX )
190
A( I, J ) = A( I, J ) + X( IX )*TEMP1
234
IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN
236
IF ((X(J).NE.ZERO) .OR. (Y(J).NE.ZERO)) THEN
240
A(I,J) = A(I,J) + X(I)*TEMP1 + Y(I)*TEMP2
246
IF ((X(JX).NE.ZERO) .OR. (Y(JY).NE.ZERO)) THEN
252
A(I,J) = A(I,J) + X(IX)*TEMP1 + Y(IY)*TEMP2
202
263
* Form A when A is stored in the lower triangle.
204
IF( ( INCX.EQ.1 ).AND.( INCY.EQ.1 ) )THEN
206
IF( ( X( J ).NE.ZERO ).OR.( Y( J ).NE.ZERO ) )THEN
210
A( I, J ) = A( I, J ) + X( I )*TEMP1 + Y( I )*TEMP2
216
IF( ( X( JX ).NE.ZERO ).OR.( Y( JY ).NE.ZERO ) )THEN
217
TEMP1 = ALPHA*Y( JY )
218
TEMP2 = ALPHA*X( JX )
222
A( I, J ) = A( I, J ) + X( IX )*TEMP1
265
IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN
267
IF ((X(J).NE.ZERO) .OR. (Y(J).NE.ZERO)) THEN
271
A(I,J) = A(I,J) + X(I)*TEMP1 + Y(I)*TEMP2
277
IF ((X(JX).NE.ZERO) .OR. (Y(JY).NE.ZERO)) THEN
283
A(I,J) = A(I,J) + X(IX)*TEMP1 + Y(IY)*TEMP2