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