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