1 SUBROUTINE DSPR2
(UPLO
,N
,ALPHA
,X
,INCX
,Y
,INCY
,AP
)
2 * .. Scalar Arguments
..
7 * .. Array Arguments
..
8 DOUBLE PRECISION AP
(*),X
(*),Y
(*)
14 * DSPR2 performs the symmetric rank
2 operation
16 * A
:= alpha*x*y
' + alpha*y*x' + A
,
18 * where alpha is a scalar
, x and y are n element vectors and A is an
19 * n by n symmetric matrix
, supplied in packed form
.
25 * On entry
, UPLO specifies whether the upper or lower
26 * triangular part of the matrix A is supplied in the packed
27 * array AP as follows
:
29 * UPLO
= 'U' or
'u' The upper triangular part of A is
32 * UPLO
= 'L' or
'l' The lower triangular part of A is
38 * On entry
, N specifies the order of the matrix A
.
39 * N must be at least zero
.
42 * ALPHA
- DOUBLE PRECISION.
43 * On entry
, ALPHA specifies the scalar alpha
.
46 * X
- DOUBLE PRECISION array of
dimension at least
47 * ( 1 + ( n
- 1 )*abs
( INCX
) ).
48 * Before entry
, the incremented array X must contain the n
53 * On entry
, INCX specifies the increment
for the elements of
54 * X
. INCX must not be zero
.
57 * Y
- DOUBLE PRECISION array of
dimension at least
58 * ( 1 + ( n
- 1 )*abs
( INCY
) ).
59 * Before entry
, the incremented array Y must contain the n
64 * On entry
, INCY specifies the increment
for the elements of
65 * Y
. INCY must not be zero
.
68 * AP
- DOUBLE PRECISION array of
DIMENSION at least
69 * ( ( n*
( n
+ 1 ) )/2 ).
70 * Before entry with UPLO
= 'U' or
'u', the array AP must
71 * contain the upper triangular part of the symmetric matrix
72 * packed sequentially
, column by column
, so that AP
( 1 )
73 * contains a
( 1, 1 ), AP
( 2 ) and AP
( 3 ) contain a
( 1, 2 )
74 * and a
( 2, 2 ) respectively
, and so on
. On exit
, the array
75 * AP is overwritten by the upper triangular part of the
77 * Before entry with UPLO
= 'L' or
'l', the array AP must
78 * contain the lower triangular part of the symmetric matrix
79 * packed sequentially
, column by column
, so that AP
( 1 )
80 * contains a
( 1, 1 ), AP
( 2 ) and AP
( 3 ) contain a
( 2, 1 )
81 * and a
( 3, 1 ) respectively
, and so on
. On exit
, the array
82 * AP is overwritten by the lower triangular part of the
86 * Level
2 Blas routine
.
88 * -- Written on
22-October
-1986.
89 * Jack Dongarra
, Argonne National Lab
.
90 * Jeremy Du Croz
, Nag Central Office
.
91 * Sven Hammarling
, Nag Central Office
.
92 * Richard Hanson
, Sandia National Labs
.
97 PARAMETER (ZERO
=0.0D
+0)
100 DOUBLE PRECISION TEMP1
,TEMP2
101 INTEGER I
,INFO
,IX
,IY
,J
,JX
,JY
,K
,KK
,KX
,KY
103 * .. External Functions
..
107 * .. External Subroutines
..
111 * Test the input parameters
.
114 IF (.NOT
.LSAME
(UPLO
,'U') .AND
. .NOT
.LSAME
(UPLO
,'L')) THEN
116 ELSE IF (N
.LT
.0) THEN
118 ELSE IF (INCX
.EQ
.0) THEN
120 ELSE IF (INCY
.EQ
.0) THEN
124 CALL XERBLA
('DSPR2 ',INFO
)
128 * Quick
return if possible
.
130 IF ((N
.EQ
.0) .OR
. (ALPHA
.EQ
.ZERO
)) RETURN
132 * Set up the start points in X and Y
if the increments are not both
135 IF ((INCX
.NE
.1) .OR
. (INCY
.NE
.1)) THEN
150 * Start the operations
. In this version the elements of the array AP
151 * are accessed sequentially with one pass through AP
.
154 IF (LSAME
(UPLO
,'U')) THEN
156 * Form A when upper triangle is stored in AP
.
158 IF ((INCX
.EQ
.1) .AND
. (INCY
.EQ
.1)) THEN
160 IF ((X
(J
).NE
.ZERO
) .OR
. (Y
(J
).NE
.ZERO
)) THEN
165 AP
(K
) = AP
(K
) + X
(I
)*TEMP1
+ Y
(I
)*TEMP2
173 IF ((X
(JX
).NE
.ZERO
) .OR
. (Y
(JY
).NE
.ZERO
)) THEN
178 DO 30 K
= KK
,KK
+ J
- 1
179 AP
(K
) = AP
(K
) + X
(IX
)*TEMP1
+ Y
(IY
)*TEMP2
191 * Form A when lower triangle is stored in AP
.
193 IF ((INCX
.EQ
.1) .AND
. (INCY
.EQ
.1)) THEN
195 IF ((X
(J
).NE
.ZERO
) .OR
. (Y
(J
).NE
.ZERO
)) THEN
200 AP
(K
) = AP
(K
) + X
(I
)*TEMP1
+ Y
(I
)*TEMP2
208 IF ((X
(JX
).NE
.ZERO
) .OR
. (Y
(JY
).NE
.ZERO
)) THEN
213 DO 70 K
= KK
,KK
+ N
- J
214 AP
(K
) = AP
(K
) + X
(IX
)*TEMP1
+ Y
(IY
)*TEMP2