LAPACK 3.3.0
|
00001 SUBROUTINE SSPMV(UPLO,N,ALPHA,AP,X,INCX,BETA,Y,INCY) 00002 * .. Scalar Arguments .. 00003 REAL ALPHA,BETA 00004 INTEGER INCX,INCY,N 00005 CHARACTER UPLO 00006 * .. 00007 * .. Array Arguments .. 00008 REAL AP(*),X(*),Y(*) 00009 * .. 00010 * 00011 * Purpose 00012 * ======= 00013 * 00014 * SSPMV 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 - REAL . 00043 * On entry, ALPHA specifies the scalar alpha. 00044 * Unchanged on exit. 00045 * 00046 * AP - REAL 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 - REAL 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 - REAL . 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 - REAL 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 * 00092 * -- Written on 22-October-1986. 00093 * Jack Dongarra, Argonne National Lab. 00094 * Jeremy Du Croz, Nag Central Office. 00095 * Sven Hammarling, Nag Central Office. 00096 * Richard Hanson, Sandia National Labs. 00097 * 00098 * ===================================================================== 00099 * 00100 * .. Parameters .. 00101 REAL ONE,ZERO 00102 PARAMETER (ONE=1.0E+0,ZERO=0.0E+0) 00103 * .. 00104 * .. Local Scalars .. 00105 REAL TEMP1,TEMP2 00106 INTEGER I,INFO,IX,IY,J,JX,JY,K,KK,KX,KY 00107 * .. 00108 * .. External Functions .. 00109 LOGICAL LSAME 00110 EXTERNAL LSAME 00111 * .. 00112 * .. External Subroutines .. 00113 EXTERNAL XERBLA 00114 * .. 00115 * 00116 * Test the input parameters. 00117 * 00118 INFO = 0 00119 IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN 00120 INFO = 1 00121 ELSE IF (N.LT.0) THEN 00122 INFO = 2 00123 ELSE IF (INCX.EQ.0) THEN 00124 INFO = 6 00125 ELSE IF (INCY.EQ.0) THEN 00126 INFO = 9 00127 END IF 00128 IF (INFO.NE.0) THEN 00129 CALL XERBLA('SSPMV ',INFO) 00130 RETURN 00131 END IF 00132 * 00133 * Quick return if possible. 00134 * 00135 IF ((N.EQ.0) .OR. ((ALPHA.EQ.ZERO).AND. (BETA.EQ.ONE))) RETURN 00136 * 00137 * Set up the start points in X and Y. 00138 * 00139 IF (INCX.GT.0) THEN 00140 KX = 1 00141 ELSE 00142 KX = 1 - (N-1)*INCX 00143 END IF 00144 IF (INCY.GT.0) THEN 00145 KY = 1 00146 ELSE 00147 KY = 1 - (N-1)*INCY 00148 END IF 00149 * 00150 * Start the operations. In this version the elements of the array AP 00151 * are accessed sequentially with one pass through AP. 00152 * 00153 * First form y := beta*y. 00154 * 00155 IF (BETA.NE.ONE) THEN 00156 IF (INCY.EQ.1) THEN 00157 IF (BETA.EQ.ZERO) THEN 00158 DO 10 I = 1,N 00159 Y(I) = ZERO 00160 10 CONTINUE 00161 ELSE 00162 DO 20 I = 1,N 00163 Y(I) = BETA*Y(I) 00164 20 CONTINUE 00165 END IF 00166 ELSE 00167 IY = KY 00168 IF (BETA.EQ.ZERO) THEN 00169 DO 30 I = 1,N 00170 Y(IY) = ZERO 00171 IY = IY + INCY 00172 30 CONTINUE 00173 ELSE 00174 DO 40 I = 1,N 00175 Y(IY) = BETA*Y(IY) 00176 IY = IY + INCY 00177 40 CONTINUE 00178 END IF 00179 END IF 00180 END IF 00181 IF (ALPHA.EQ.ZERO) RETURN 00182 KK = 1 00183 IF (LSAME(UPLO,'U')) THEN 00184 * 00185 * Form y when AP contains the upper triangle. 00186 * 00187 IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN 00188 DO 60 J = 1,N 00189 TEMP1 = ALPHA*X(J) 00190 TEMP2 = ZERO 00191 K = KK 00192 DO 50 I = 1,J - 1 00193 Y(I) = Y(I) + TEMP1*AP(K) 00194 TEMP2 = TEMP2 + AP(K)*X(I) 00195 K = K + 1 00196 50 CONTINUE 00197 Y(J) = Y(J) + TEMP1*AP(KK+J-1) + ALPHA*TEMP2 00198 KK = KK + J 00199 60 CONTINUE 00200 ELSE 00201 JX = KX 00202 JY = KY 00203 DO 80 J = 1,N 00204 TEMP1 = ALPHA*X(JX) 00205 TEMP2 = ZERO 00206 IX = KX 00207 IY = KY 00208 DO 70 K = KK,KK + J - 2 00209 Y(IY) = Y(IY) + TEMP1*AP(K) 00210 TEMP2 = TEMP2 + AP(K)*X(IX) 00211 IX = IX + INCX 00212 IY = IY + INCY 00213 70 CONTINUE 00214 Y(JY) = Y(JY) + TEMP1*AP(KK+J-1) + ALPHA*TEMP2 00215 JX = JX + INCX 00216 JY = JY + INCY 00217 KK = KK + J 00218 80 CONTINUE 00219 END IF 00220 ELSE 00221 * 00222 * Form y when AP contains the lower triangle. 00223 * 00224 IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN 00225 DO 100 J = 1,N 00226 TEMP1 = ALPHA*X(J) 00227 TEMP2 = ZERO 00228 Y(J) = Y(J) + TEMP1*AP(KK) 00229 K = KK + 1 00230 DO 90 I = J + 1,N 00231 Y(I) = Y(I) + TEMP1*AP(K) 00232 TEMP2 = TEMP2 + AP(K)*X(I) 00233 K = K + 1 00234 90 CONTINUE 00235 Y(J) = Y(J) + ALPHA*TEMP2 00236 KK = KK + (N-J+1) 00237 100 CONTINUE 00238 ELSE 00239 JX = KX 00240 JY = KY 00241 DO 120 J = 1,N 00242 TEMP1 = ALPHA*X(JX) 00243 TEMP2 = ZERO 00244 Y(JY) = Y(JY) + TEMP1*AP(KK) 00245 IX = JX 00246 IY = JY 00247 DO 110 K = KK + 1,KK + N - J 00248 IX = IX + INCX 00249 IY = IY + INCY 00250 Y(IY) = Y(IY) + TEMP1*AP(K) 00251 TEMP2 = TEMP2 + AP(K)*X(IX) 00252 110 CONTINUE 00253 Y(JY) = Y(JY) + ALPHA*TEMP2 00254 JX = JX + INCX 00255 JY = JY + INCY 00256 KK = KK + (N-J+1) 00257 120 CONTINUE 00258 END IF 00259 END IF 00260 * 00261 RETURN 00262 * 00263 * End of SSPMV . 00264 * 00265 END