LAPACK 3.3.0
|
00001 SUBROUTINE CTBMV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX) 00002 * .. Scalar Arguments .. 00003 INTEGER INCX,K,LDA,N 00004 CHARACTER DIAG,TRANS,UPLO 00005 * .. 00006 * .. Array Arguments .. 00007 COMPLEX A(LDA,*),X(*) 00008 * .. 00009 * 00010 * Purpose 00011 * ======= 00012 * 00013 * CTBMV performs one of the matrix-vector operations 00014 * 00015 * x := A*x, or x := A'*x, or x := conjg( A' )*x, 00016 * 00017 * where x is an n element vector and A is an n by n unit, or non-unit, 00018 * upper or lower triangular band matrix, with ( k + 1 ) diagonals. 00019 * 00020 * Arguments 00021 * ========== 00022 * 00023 * UPLO - CHARACTER*1. 00024 * On entry, UPLO specifies whether the matrix is an upper or 00025 * lower triangular matrix as follows: 00026 * 00027 * UPLO = 'U' or 'u' A is an upper triangular matrix. 00028 * 00029 * UPLO = 'L' or 'l' A is a lower triangular matrix. 00030 * 00031 * Unchanged on exit. 00032 * 00033 * TRANS - CHARACTER*1. 00034 * On entry, TRANS specifies the operation to be performed as 00035 * follows: 00036 * 00037 * TRANS = 'N' or 'n' x := A*x. 00038 * 00039 * TRANS = 'T' or 't' x := A'*x. 00040 * 00041 * TRANS = 'C' or 'c' x := conjg( A' )*x. 00042 * 00043 * Unchanged on exit. 00044 * 00045 * DIAG - CHARACTER*1. 00046 * On entry, DIAG specifies whether or not A is unit 00047 * triangular as follows: 00048 * 00049 * DIAG = 'U' or 'u' A is assumed to be unit triangular. 00050 * 00051 * DIAG = 'N' or 'n' A is not assumed to be unit 00052 * triangular. 00053 * 00054 * Unchanged on exit. 00055 * 00056 * N - INTEGER. 00057 * On entry, N specifies the order of the matrix A. 00058 * N must be at least zero. 00059 * Unchanged on exit. 00060 * 00061 * K - INTEGER. 00062 * On entry with UPLO = 'U' or 'u', K specifies the number of 00063 * super-diagonals of the matrix A. 00064 * On entry with UPLO = 'L' or 'l', K specifies the number of 00065 * sub-diagonals of the matrix A. 00066 * K must satisfy 0 .le. K. 00067 * Unchanged on exit. 00068 * 00069 * A - COMPLEX array of DIMENSION ( LDA, n ). 00070 * Before entry with UPLO = 'U' or 'u', the leading ( k + 1 ) 00071 * by n part of the array A must contain the upper triangular 00072 * band part of the matrix of coefficients, supplied column by 00073 * column, with the leading diagonal of the matrix in row 00074 * ( k + 1 ) of the array, the first super-diagonal starting at 00075 * position 2 in row k, and so on. The top left k by k triangle 00076 * of the array A is not referenced. 00077 * The following program segment will transfer an upper 00078 * triangular band matrix from conventional full matrix storage 00079 * to band storage: 00080 * 00081 * DO 20, J = 1, N 00082 * M = K + 1 - J 00083 * DO 10, I = MAX( 1, J - K ), J 00084 * A( M + I, J ) = matrix( I, J ) 00085 * 10 CONTINUE 00086 * 20 CONTINUE 00087 * 00088 * Before entry with UPLO = 'L' or 'l', the leading ( k + 1 ) 00089 * by n part of the array A must contain the lower triangular 00090 * band part of the matrix of coefficients, supplied column by 00091 * column, with the leading diagonal of the matrix in row 1 of 00092 * the array, the first sub-diagonal starting at position 1 in 00093 * row 2, and so on. The bottom right k by k triangle of the 00094 * array A is not referenced. 00095 * The following program segment will transfer a lower 00096 * triangular band matrix from conventional full matrix storage 00097 * to band storage: 00098 * 00099 * DO 20, J = 1, N 00100 * M = 1 - J 00101 * DO 10, I = J, MIN( N, J + K ) 00102 * A( M + I, J ) = matrix( I, J ) 00103 * 10 CONTINUE 00104 * 20 CONTINUE 00105 * 00106 * Note that when DIAG = 'U' or 'u' the elements of the array A 00107 * corresponding to the diagonal elements of the matrix are not 00108 * referenced, but are assumed to be unity. 00109 * Unchanged on exit. 00110 * 00111 * LDA - INTEGER. 00112 * On entry, LDA specifies the first dimension of A as declared 00113 * in the calling (sub) program. LDA must be at least 00114 * ( k + 1 ). 00115 * Unchanged on exit. 00116 * 00117 * X - COMPLEX array of dimension at least 00118 * ( 1 + ( n - 1 )*abs( INCX ) ). 00119 * Before entry, the incremented array X must contain the n 00120 * element vector x. On exit, X is overwritten with the 00121 * tranformed vector x. 00122 * 00123 * INCX - INTEGER. 00124 * On entry, INCX specifies the increment for the elements of 00125 * X. INCX must not be zero. 00126 * Unchanged on exit. 00127 * 00128 * Further Details 00129 * =============== 00130 * 00131 * Level 2 Blas routine. 00132 * 00133 * -- Written on 22-October-1986. 00134 * Jack Dongarra, Argonne National Lab. 00135 * Jeremy Du Croz, Nag Central Office. 00136 * Sven Hammarling, Nag Central Office. 00137 * Richard Hanson, Sandia National Labs. 00138 * 00139 * ===================================================================== 00140 * 00141 * .. Parameters .. 00142 COMPLEX ZERO 00143 PARAMETER (ZERO= (0.0E+0,0.0E+0)) 00144 * .. 00145 * .. Local Scalars .. 00146 COMPLEX TEMP 00147 INTEGER I,INFO,IX,J,JX,KPLUS1,KX,L 00148 LOGICAL NOCONJ,NOUNIT 00149 * .. 00150 * .. External Functions .. 00151 LOGICAL LSAME 00152 EXTERNAL LSAME 00153 * .. 00154 * .. External Subroutines .. 00155 EXTERNAL XERBLA 00156 * .. 00157 * .. Intrinsic Functions .. 00158 INTRINSIC CONJG,MAX,MIN 00159 * .. 00160 * 00161 * Test the input parameters. 00162 * 00163 INFO = 0 00164 IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN 00165 INFO = 1 00166 ELSE IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND. 00167 + .NOT.LSAME(TRANS,'C')) THEN 00168 INFO = 2 00169 ELSE IF (.NOT.LSAME(DIAG,'U') .AND. .NOT.LSAME(DIAG,'N')) THEN 00170 INFO = 3 00171 ELSE IF (N.LT.0) THEN 00172 INFO = 4 00173 ELSE IF (K.LT.0) THEN 00174 INFO = 5 00175 ELSE IF (LDA.LT. (K+1)) THEN 00176 INFO = 7 00177 ELSE IF (INCX.EQ.0) THEN 00178 INFO = 9 00179 END IF 00180 IF (INFO.NE.0) THEN 00181 CALL XERBLA('CTBMV ',INFO) 00182 RETURN 00183 END IF 00184 * 00185 * Quick return if possible. 00186 * 00187 IF (N.EQ.0) RETURN 00188 * 00189 NOCONJ = LSAME(TRANS,'T') 00190 NOUNIT = LSAME(DIAG,'N') 00191 * 00192 * Set up the start point in X if the increment is not unity. This 00193 * will be ( N - 1 )*INCX too small for descending loops. 00194 * 00195 IF (INCX.LE.0) THEN 00196 KX = 1 - (N-1)*INCX 00197 ELSE IF (INCX.NE.1) THEN 00198 KX = 1 00199 END IF 00200 * 00201 * Start the operations. In this version the elements of A are 00202 * accessed sequentially with one pass through A. 00203 * 00204 IF (LSAME(TRANS,'N')) THEN 00205 * 00206 * Form x := A*x. 00207 * 00208 IF (LSAME(UPLO,'U')) THEN 00209 KPLUS1 = K + 1 00210 IF (INCX.EQ.1) THEN 00211 DO 20 J = 1,N 00212 IF (X(J).NE.ZERO) THEN 00213 TEMP = X(J) 00214 L = KPLUS1 - J 00215 DO 10 I = MAX(1,J-K),J - 1 00216 X(I) = X(I) + TEMP*A(L+I,J) 00217 10 CONTINUE 00218 IF (NOUNIT) X(J) = X(J)*A(KPLUS1,J) 00219 END IF 00220 20 CONTINUE 00221 ELSE 00222 JX = KX 00223 DO 40 J = 1,N 00224 IF (X(JX).NE.ZERO) THEN 00225 TEMP = X(JX) 00226 IX = KX 00227 L = KPLUS1 - J 00228 DO 30 I = MAX(1,J-K),J - 1 00229 X(IX) = X(IX) + TEMP*A(L+I,J) 00230 IX = IX + INCX 00231 30 CONTINUE 00232 IF (NOUNIT) X(JX) = X(JX)*A(KPLUS1,J) 00233 END IF 00234 JX = JX + INCX 00235 IF (J.GT.K) KX = KX + INCX 00236 40 CONTINUE 00237 END IF 00238 ELSE 00239 IF (INCX.EQ.1) THEN 00240 DO 60 J = N,1,-1 00241 IF (X(J).NE.ZERO) THEN 00242 TEMP = X(J) 00243 L = 1 - J 00244 DO 50 I = MIN(N,J+K),J + 1,-1 00245 X(I) = X(I) + TEMP*A(L+I,J) 00246 50 CONTINUE 00247 IF (NOUNIT) X(J) = X(J)*A(1,J) 00248 END IF 00249 60 CONTINUE 00250 ELSE 00251 KX = KX + (N-1)*INCX 00252 JX = KX 00253 DO 80 J = N,1,-1 00254 IF (X(JX).NE.ZERO) THEN 00255 TEMP = X(JX) 00256 IX = KX 00257 L = 1 - J 00258 DO 70 I = MIN(N,J+K),J + 1,-1 00259 X(IX) = X(IX) + TEMP*A(L+I,J) 00260 IX = IX - INCX 00261 70 CONTINUE 00262 IF (NOUNIT) X(JX) = X(JX)*A(1,J) 00263 END IF 00264 JX = JX - INCX 00265 IF ((N-J).GE.K) KX = KX - INCX 00266 80 CONTINUE 00267 END IF 00268 END IF 00269 ELSE 00270 * 00271 * Form x := A'*x or x := conjg( A' )*x. 00272 * 00273 IF (LSAME(UPLO,'U')) THEN 00274 KPLUS1 = K + 1 00275 IF (INCX.EQ.1) THEN 00276 DO 110 J = N,1,-1 00277 TEMP = X(J) 00278 L = KPLUS1 - J 00279 IF (NOCONJ) THEN 00280 IF (NOUNIT) TEMP = TEMP*A(KPLUS1,J) 00281 DO 90 I = J - 1,MAX(1,J-K),-1 00282 TEMP = TEMP + A(L+I,J)*X(I) 00283 90 CONTINUE 00284 ELSE 00285 IF (NOUNIT) TEMP = TEMP*CONJG(A(KPLUS1,J)) 00286 DO 100 I = J - 1,MAX(1,J-K),-1 00287 TEMP = TEMP + CONJG(A(L+I,J))*X(I) 00288 100 CONTINUE 00289 END IF 00290 X(J) = TEMP 00291 110 CONTINUE 00292 ELSE 00293 KX = KX + (N-1)*INCX 00294 JX = KX 00295 DO 140 J = N,1,-1 00296 TEMP = X(JX) 00297 KX = KX - INCX 00298 IX = KX 00299 L = KPLUS1 - J 00300 IF (NOCONJ) THEN 00301 IF (NOUNIT) TEMP = TEMP*A(KPLUS1,J) 00302 DO 120 I = J - 1,MAX(1,J-K),-1 00303 TEMP = TEMP + A(L+I,J)*X(IX) 00304 IX = IX - INCX 00305 120 CONTINUE 00306 ELSE 00307 IF (NOUNIT) TEMP = TEMP*CONJG(A(KPLUS1,J)) 00308 DO 130 I = J - 1,MAX(1,J-K),-1 00309 TEMP = TEMP + CONJG(A(L+I,J))*X(IX) 00310 IX = IX - INCX 00311 130 CONTINUE 00312 END IF 00313 X(JX) = TEMP 00314 JX = JX - INCX 00315 140 CONTINUE 00316 END IF 00317 ELSE 00318 IF (INCX.EQ.1) THEN 00319 DO 170 J = 1,N 00320 TEMP = X(J) 00321 L = 1 - J 00322 IF (NOCONJ) THEN 00323 IF (NOUNIT) TEMP = TEMP*A(1,J) 00324 DO 150 I = J + 1,MIN(N,J+K) 00325 TEMP = TEMP + A(L+I,J)*X(I) 00326 150 CONTINUE 00327 ELSE 00328 IF (NOUNIT) TEMP = TEMP*CONJG(A(1,J)) 00329 DO 160 I = J + 1,MIN(N,J+K) 00330 TEMP = TEMP + CONJG(A(L+I,J))*X(I) 00331 160 CONTINUE 00332 END IF 00333 X(J) = TEMP 00334 170 CONTINUE 00335 ELSE 00336 JX = KX 00337 DO 200 J = 1,N 00338 TEMP = X(JX) 00339 KX = KX + INCX 00340 IX = KX 00341 L = 1 - J 00342 IF (NOCONJ) THEN 00343 IF (NOUNIT) TEMP = TEMP*A(1,J) 00344 DO 180 I = J + 1,MIN(N,J+K) 00345 TEMP = TEMP + A(L+I,J)*X(IX) 00346 IX = IX + INCX 00347 180 CONTINUE 00348 ELSE 00349 IF (NOUNIT) TEMP = TEMP*CONJG(A(1,J)) 00350 DO 190 I = J + 1,MIN(N,J+K) 00351 TEMP = TEMP + CONJG(A(L+I,J))*X(IX) 00352 IX = IX + INCX 00353 190 CONTINUE 00354 END IF 00355 X(JX) = TEMP 00356 JX = JX + INCX 00357 200 CONTINUE 00358 END IF 00359 END IF 00360 END IF 00361 * 00362 RETURN 00363 * 00364 * End of CTBMV . 00365 * 00366 END