1 SUBROUTINE DSPMV
(UPLO
,N
,ALPHA
,AP
,X
,INCX
,BETA
,Y
,INCY
)
2 * .. Scalar Arguments
..
3 DOUBLE PRECISION ALPHA
,BETA
7 * .. Array Arguments
..
8 DOUBLE PRECISION AP
(*),X
(*),Y
(*)
14 * DSPMV performs the matrix
-vector operation
16 * y
:= alpha*A*x
+ beta*y
,
18 * where alpha and beta are scalars
, x and y are n element vectors and
19 * A is an 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 * AP
- DOUBLE PRECISION array of
DIMENSION at least
47 * ( ( n*
( n
+ 1 ) )/2 ).
48 * Before entry with UPLO
= 'U' or
'u', the array AP must
49 * contain the upper triangular part of the symmetric matrix
50 * packed sequentially
, column by column
, so that AP
( 1 )
51 * contains a
( 1, 1 ), AP
( 2 ) and AP
( 3 ) contain a
( 1, 2 )
52 * and a
( 2, 2 ) respectively
, and so on
.
53 * Before entry with UPLO
= 'L' or
'l', the array AP must
54 * contain the lower triangular part of the symmetric matrix
55 * packed sequentially
, column by column
, so that AP
( 1 )
56 * contains a
( 1, 1 ), AP
( 2 ) and AP
( 3 ) contain a
( 2, 1 )
57 * and a
( 3, 1 ) respectively
, and so on
.
60 * X
- DOUBLE PRECISION array of
dimension at least
61 * ( 1 + ( n
- 1 )*abs
( INCX
) ).
62 * Before entry
, the incremented array X must contain the n
67 * On entry
, INCX specifies the increment
for the elements of
68 * X
. INCX must not be zero
.
71 * BETA
- DOUBLE PRECISION.
72 * On entry
, BETA specifies the scalar beta
. When BETA is
73 * supplied as zero
then Y need not be set on input
.
76 * Y
- DOUBLE PRECISION array of
dimension at least
77 * ( 1 + ( n
- 1 )*abs
( INCY
) ).
78 * Before entry
, the incremented array Y must contain the n
79 * element vector y
. On exit
, Y is overwritten by the updated
83 * On entry
, INCY specifies the increment
for the elements of
84 * Y
. INCY must not be zero
.
90 * Level
2 Blas routine
.
92 * -- Written on
22-October
-1986.
93 * Jack Dongarra
, Argonne National Lab
.
94 * Jeremy Du Croz
, Nag Central Office
.
95 * Sven Hammarling
, Nag Central Office
.
96 * Richard Hanson
, Sandia National Labs
.
98 * =====================================================================
101 DOUBLE PRECISION ONE
,ZERO
102 PARAMETER (ONE
=1.0D
+0,ZERO
=0.0D
+0)
104 * .. Local Scalars
..
105 DOUBLE PRECISION TEMP1
,TEMP2
106 INTEGER I
,INFO
,IX
,IY
,J
,JX
,JY
,K
,KK
,KX
,KY
108 * .. External Functions
..
112 * .. External Subroutines
..
116 * Test the input parameters
.
119 IF (.NOT
.LSAME
(UPLO
,'U') .AND
. .NOT
.LSAME
(UPLO
,'L')) THEN
121 ELSE IF (N
.LT
.0) THEN
123 ELSE IF (INCX
.EQ
.0) THEN
125 ELSE IF (INCY
.EQ
.0) THEN
129 CALL XERBLA
('DSPMV ',INFO
)
133 * Quick
return if possible
.
135 IF ((N
.EQ
.0) .OR
. ((ALPHA
.EQ
.ZERO
).AND
. (BETA
.EQ
.ONE
))) RETURN
137 * Set up the start points in X and Y
.
150 * Start the operations
. In this version the elements of the array AP
151 * are accessed sequentially with one pass through AP
.
153 * First form y
:= beta*y
.
155 IF (BETA
.NE
.ONE
) THEN
157 IF (BETA
.EQ
.ZERO
) THEN
168 IF (BETA
.EQ
.ZERO
) THEN
181 IF (ALPHA
.EQ
.ZERO
) RETURN
183 IF (LSAME
(UPLO
,'U')) THEN
185 * Form y when AP contains the upper triangle
.
187 IF ((INCX
.EQ
.1) .AND
. (INCY
.EQ
.1)) THEN
193 Y
(I
) = Y
(I
) + TEMP1*AP
(K
)
194 TEMP2
= TEMP2
+ AP
(K
)*X
(I
)
197 Y
(J
) = Y
(J
) + TEMP1*AP
(KK
+J
-1) + ALPHA*TEMP2
208 DO 70 K
= KK
,KK
+ J
- 2
209 Y
(IY
) = Y
(IY
) + TEMP1*AP
(K
)
210 TEMP2
= TEMP2
+ AP
(K
)*X
(IX
)
214 Y
(JY
) = Y
(JY
) + TEMP1*AP
(KK
+J
-1) + ALPHA*TEMP2
222 * Form y when AP contains the lower triangle
.
224 IF ((INCX
.EQ
.1) .AND
. (INCY
.EQ
.1)) THEN
228 Y
(J
) = Y
(J
) + TEMP1*AP
(KK
)
231 Y
(I
) = Y
(I
) + TEMP1*AP
(K
)
232 TEMP2
= TEMP2
+ AP
(K
)*X
(I
)
235 Y
(J
) = Y
(J
) + ALPHA*TEMP2
244 Y
(JY
) = Y
(JY
) + TEMP1*AP
(KK
)
247 DO 110 K
= KK
+ 1,KK
+ N
- J
250 Y
(IY
) = Y
(IY
) + TEMP1*AP
(K
)
251 TEMP2
= TEMP2
+ AP
(K
)*X
(IX
)
253 Y
(JY
) = Y
(JY
) + ALPHA*TEMP2