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