LAPACK 3.3.1
Linear Algebra PACKage
|
00001 SUBROUTINE DSPMV(UPLO,N,ALPHA,AP,X,INCX,BETA,Y,INCY) 00002 * .. Scalar Arguments .. 00003 DOUBLE PRECISION ALPHA,BETA 00004 INTEGER INCX,INCY,N 00005 CHARACTER UPLO 00006 * .. 00007 * .. Array Arguments .. 00008 DOUBLE PRECISION AP(*),X(*),Y(*) 00009 * .. 00010 * 00011 * Purpose 00012 * ======= 00013 * 00014 * DSPMV performs the matrix-vector operation 00015 * 00016 * y := alpha*A*x + beta*y, 00017 * 00018 * where alpha and beta are scalars, x and y are n element vectors and 00019 * A is an n by n symmetric matrix, supplied in packed form. 00020 * 00021 * Arguments 00022 * ========== 00023 * 00024 * UPLO - CHARACTER*1. 00025 * On entry, UPLO specifies whether the upper or lower 00026 * triangular part of the matrix A is supplied in the packed 00027 * array AP as follows: 00028 * 00029 * UPLO = 'U' or 'u' The upper triangular part of A is 00030 * supplied in AP. 00031 * 00032 * UPLO = 'L' or 'l' The lower triangular part of A is 00033 * supplied in AP. 00034 * 00035 * Unchanged on exit. 00036 * 00037 * N - INTEGER. 00038 * On entry, N specifies the order of the matrix A. 00039 * N must be at least zero. 00040 * Unchanged on exit. 00041 * 00042 * ALPHA - DOUBLE PRECISION. 00043 * On entry, ALPHA specifies the scalar alpha. 00044 * Unchanged on exit. 00045 * 00046 * AP - DOUBLE PRECISION array of DIMENSION at least 00047 * ( ( n*( n + 1 ) )/2 ). 00048 * Before entry with UPLO = 'U' or 'u', the array AP must 00049 * contain the upper triangular part of the symmetric matrix 00050 * packed sequentially, column by column, so that AP( 1 ) 00051 * contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 ) 00052 * and a( 2, 2 ) respectively, and so on. 00053 * Before entry with UPLO = 'L' or 'l', the array AP must 00054 * contain the lower triangular part of the symmetric matrix 00055 * packed sequentially, column by column, so that AP( 1 ) 00056 * contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 ) 00057 * and a( 3, 1 ) respectively, and so on. 00058 * Unchanged on exit. 00059 * 00060 * X - DOUBLE PRECISION array of dimension at least 00061 * ( 1 + ( n - 1 )*abs( INCX ) ). 00062 * Before entry, the incremented array X must contain the n 00063 * element vector x. 00064 * Unchanged on exit. 00065 * 00066 * INCX - INTEGER. 00067 * On entry, INCX specifies the increment for the elements of 00068 * X. INCX must not be zero. 00069 * Unchanged on exit. 00070 * 00071 * BETA - DOUBLE PRECISION. 00072 * On entry, BETA specifies the scalar beta. When BETA is 00073 * supplied as zero then Y need not be set on input. 00074 * Unchanged on exit. 00075 * 00076 * Y - DOUBLE PRECISION array of dimension at least 00077 * ( 1 + ( n - 1 )*abs( INCY ) ). 00078 * Before entry, the incremented array Y must contain the n 00079 * element vector y. On exit, Y is overwritten by the updated 00080 * vector y. 00081 * 00082 * INCY - INTEGER. 00083 * On entry, INCY specifies the increment for the elements of 00084 * Y. INCY must not be zero. 00085 * Unchanged on exit. 00086 * 00087 * Further Details 00088 * =============== 00089 * 00090 * Level 2 Blas routine. 00091 * The vector and matrix arguments are not referenced when N = 0, or M = 0 00092 * 00093 * -- Written on 22-October-1986. 00094 * Jack Dongarra, Argonne National Lab. 00095 * Jeremy Du Croz, Nag Central Office. 00096 * Sven Hammarling, Nag Central Office. 00097 * Richard Hanson, Sandia National Labs. 00098 * 00099 * ===================================================================== 00100 * 00101 * .. Parameters .. 00102 DOUBLE PRECISION ONE,ZERO 00103 PARAMETER (ONE=1.0D+0,ZERO=0.0D+0) 00104 * .. 00105 * .. Local Scalars .. 00106 DOUBLE PRECISION TEMP1,TEMP2 00107 INTEGER I,INFO,IX,IY,J,JX,JY,K,KK,KX,KY 00108 * .. 00109 * .. External Functions .. 00110 LOGICAL LSAME 00111 EXTERNAL LSAME 00112 * .. 00113 * .. External Subroutines .. 00114 EXTERNAL XERBLA 00115 * .. 00116 * 00117 * Test the input parameters. 00118 * 00119 INFO = 0 00120 IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN 00121 INFO = 1 00122 ELSE IF (N.LT.0) THEN 00123 INFO = 2 00124 ELSE IF (INCX.EQ.0) THEN 00125 INFO = 6 00126 ELSE IF (INCY.EQ.0) THEN 00127 INFO = 9 00128 END IF 00129 IF (INFO.NE.0) THEN 00130 CALL XERBLA('DSPMV ',INFO) 00131 RETURN 00132 END IF 00133 * 00134 * Quick return if possible. 00135 * 00136 IF ((N.EQ.0) .OR. ((ALPHA.EQ.ZERO).AND. (BETA.EQ.ONE))) RETURN 00137 * 00138 * Set up the start points in X and Y. 00139 * 00140 IF (INCX.GT.0) THEN 00141 KX = 1 00142 ELSE 00143 KX = 1 - (N-1)*INCX 00144 END IF 00145 IF (INCY.GT.0) THEN 00146 KY = 1 00147 ELSE 00148 KY = 1 - (N-1)*INCY 00149 END IF 00150 * 00151 * Start the operations. In this version the elements of the array AP 00152 * are accessed sequentially with one pass through AP. 00153 * 00154 * First form y := beta*y. 00155 * 00156 IF (BETA.NE.ONE) THEN 00157 IF (INCY.EQ.1) THEN 00158 IF (BETA.EQ.ZERO) THEN 00159 DO 10 I = 1,N 00160 Y(I) = ZERO 00161 10 CONTINUE 00162 ELSE 00163 DO 20 I = 1,N 00164 Y(I) = BETA*Y(I) 00165 20 CONTINUE 00166 END IF 00167 ELSE 00168 IY = KY 00169 IF (BETA.EQ.ZERO) THEN 00170 DO 30 I = 1,N 00171 Y(IY) = ZERO 00172 IY = IY + INCY 00173 30 CONTINUE 00174 ELSE 00175 DO 40 I = 1,N 00176 Y(IY) = BETA*Y(IY) 00177 IY = IY + INCY 00178 40 CONTINUE 00179 END IF 00180 END IF 00181 END IF 00182 IF (ALPHA.EQ.ZERO) RETURN 00183 KK = 1 00184 IF (LSAME(UPLO,'U')) THEN 00185 * 00186 * Form y when AP contains the upper triangle. 00187 * 00188 IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN 00189 DO 60 J = 1,N 00190 TEMP1 = ALPHA*X(J) 00191 TEMP2 = ZERO 00192 K = KK 00193 DO 50 I = 1,J - 1 00194 Y(I) = Y(I) + TEMP1*AP(K) 00195 TEMP2 = TEMP2 + AP(K)*X(I) 00196 K = K + 1 00197 50 CONTINUE 00198 Y(J) = Y(J) + TEMP1*AP(KK+J-1) + ALPHA*TEMP2 00199 KK = KK + J 00200 60 CONTINUE 00201 ELSE 00202 JX = KX 00203 JY = KY 00204 DO 80 J = 1,N 00205 TEMP1 = ALPHA*X(JX) 00206 TEMP2 = ZERO 00207 IX = KX 00208 IY = KY 00209 DO 70 K = KK,KK + J - 2 00210 Y(IY) = Y(IY) + TEMP1*AP(K) 00211 TEMP2 = TEMP2 + AP(K)*X(IX) 00212 IX = IX + INCX 00213 IY = IY + INCY 00214 70 CONTINUE 00215 Y(JY) = Y(JY) + TEMP1*AP(KK+J-1) + ALPHA*TEMP2 00216 JX = JX + INCX 00217 JY = JY + INCY 00218 KK = KK + J 00219 80 CONTINUE 00220 END IF 00221 ELSE 00222 * 00223 * Form y when AP contains the lower triangle. 00224 * 00225 IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN 00226 DO 100 J = 1,N 00227 TEMP1 = ALPHA*X(J) 00228 TEMP2 = ZERO 00229 Y(J) = Y(J) + TEMP1*AP(KK) 00230 K = KK + 1 00231 DO 90 I = J + 1,N 00232 Y(I) = Y(I) + TEMP1*AP(K) 00233 TEMP2 = TEMP2 + AP(K)*X(I) 00234 K = K + 1 00235 90 CONTINUE 00236 Y(J) = Y(J) + ALPHA*TEMP2 00237 KK = KK + (N-J+1) 00238 100 CONTINUE 00239 ELSE 00240 JX = KX 00241 JY = KY 00242 DO 120 J = 1,N 00243 TEMP1 = ALPHA*X(JX) 00244 TEMP2 = ZERO 00245 Y(JY) = Y(JY) + TEMP1*AP(KK) 00246 IX = JX 00247 IY = JY 00248 DO 110 K = KK + 1,KK + N - J 00249 IX = IX + INCX 00250 IY = IY + INCY 00251 Y(IY) = Y(IY) + TEMP1*AP(K) 00252 TEMP2 = TEMP2 + AP(K)*X(IX) 00253 110 CONTINUE 00254 Y(JY) = Y(JY) + ALPHA*TEMP2 00255 JX = JX + INCX 00256 JY = JY + INCY 00257 KK = KK + (N-J+1) 00258 120 CONTINUE 00259 END IF 00260 END IF 00261 * 00262 RETURN 00263 * 00264 * End of DSPMV . 00265 * 00266 END