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