LAPACK 3.3.0

dtbsv.f

Go to the documentation of this file.
00001       SUBROUTINE DTBSV(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       DOUBLE PRECISION A(LDA,*),X(*)
00008 *     ..
00009 *
00010 *  Purpose
00011 *  =======
00012 *
00013 *  DTBSV  solves one of the systems of equations
00014 *
00015 *     A*x = b,   or   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'   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      - DOUBLE PRECISION 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      - DOUBLE PRECISION 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       DOUBLE PRECISION ZERO
00147       PARAMETER (ZERO=0.0D+0)
00148 *     ..
00149 *     .. Local Scalars ..
00150       DOUBLE PRECISION TEMP
00151       INTEGER I,INFO,IX,J,JX,KPLUS1,KX,L
00152       LOGICAL NOUNIT
00153 *     ..
00154 *     .. External Functions ..
00155       LOGICAL LSAME
00156       EXTERNAL LSAME
00157 *     ..
00158 *     .. External Subroutines ..
00159       EXTERNAL XERBLA
00160 *     ..
00161 *     .. Intrinsic Functions ..
00162       INTRINSIC 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('DTBSV ',INFO)
00186           RETURN
00187       END IF
00188 *
00189 *     Quick return if possible.
00190 *
00191       IF (N.EQ.0) RETURN
00192 *
00193       NOUNIT = LSAME(DIAG,'N')
00194 *
00195 *     Set up the start point in X if the increment is not unity. This
00196 *     will be  ( N - 1 )*INCX  too small for descending loops.
00197 *
00198       IF (INCX.LE.0) THEN
00199           KX = 1 - (N-1)*INCX
00200       ELSE IF (INCX.NE.1) THEN
00201           KX = 1
00202       END IF
00203 *
00204 *     Start the operations. In this version the elements of A are
00205 *     accessed by sequentially with one pass through A.
00206 *
00207       IF (LSAME(TRANS,'N')) THEN
00208 *
00209 *        Form  x := inv( A )*x.
00210 *
00211           IF (LSAME(UPLO,'U')) THEN
00212               KPLUS1 = K + 1
00213               IF (INCX.EQ.1) THEN
00214                   DO 20 J = N,1,-1
00215                       IF (X(J).NE.ZERO) THEN
00216                           L = KPLUS1 - J
00217                           IF (NOUNIT) X(J) = X(J)/A(KPLUS1,J)
00218                           TEMP = X(J)
00219                           DO 10 I = J - 1,MAX(1,J-K),-1
00220                               X(I) = X(I) - TEMP*A(L+I,J)
00221    10                     CONTINUE
00222                       END IF
00223    20             CONTINUE
00224               ELSE
00225                   KX = KX + (N-1)*INCX
00226                   JX = KX
00227                   DO 40 J = N,1,-1
00228                       KX = KX - INCX
00229                       IF (X(JX).NE.ZERO) THEN
00230                           IX = KX
00231                           L = KPLUS1 - J
00232                           IF (NOUNIT) X(JX) = X(JX)/A(KPLUS1,J)
00233                           TEMP = X(JX)
00234                           DO 30 I = J - 1,MAX(1,J-K),-1
00235                               X(IX) = X(IX) - TEMP*A(L+I,J)
00236                               IX = IX - INCX
00237    30                     CONTINUE
00238                       END IF
00239                       JX = JX - INCX
00240    40             CONTINUE
00241               END IF
00242           ELSE
00243               IF (INCX.EQ.1) THEN
00244                   DO 60 J = 1,N
00245                       IF (X(J).NE.ZERO) THEN
00246                           L = 1 - J
00247                           IF (NOUNIT) X(J) = X(J)/A(1,J)
00248                           TEMP = X(J)
00249                           DO 50 I = J + 1,MIN(N,J+K)
00250                               X(I) = X(I) - TEMP*A(L+I,J)
00251    50                     CONTINUE
00252                       END IF
00253    60             CONTINUE
00254               ELSE
00255                   JX = KX
00256                   DO 80 J = 1,N
00257                       KX = KX + INCX
00258                       IF (X(JX).NE.ZERO) THEN
00259                           IX = KX
00260                           L = 1 - J
00261                           IF (NOUNIT) X(JX) = X(JX)/A(1,J)
00262                           TEMP = X(JX)
00263                           DO 70 I = J + 1,MIN(N,J+K)
00264                               X(IX) = X(IX) - TEMP*A(L+I,J)
00265                               IX = IX + INCX
00266    70                     CONTINUE
00267                       END IF
00268                       JX = JX + INCX
00269    80             CONTINUE
00270               END IF
00271           END IF
00272       ELSE
00273 *
00274 *        Form  x := inv( A')*x.
00275 *
00276           IF (LSAME(UPLO,'U')) THEN
00277               KPLUS1 = K + 1
00278               IF (INCX.EQ.1) THEN
00279                   DO 100 J = 1,N
00280                       TEMP = X(J)
00281                       L = KPLUS1 - J
00282                       DO 90 I = MAX(1,J-K),J - 1
00283                           TEMP = TEMP - A(L+I,J)*X(I)
00284    90                 CONTINUE
00285                       IF (NOUNIT) TEMP = TEMP/A(KPLUS1,J)
00286                       X(J) = TEMP
00287   100             CONTINUE
00288               ELSE
00289                   JX = KX
00290                   DO 120 J = 1,N
00291                       TEMP = X(JX)
00292                       IX = KX
00293                       L = KPLUS1 - J
00294                       DO 110 I = MAX(1,J-K),J - 1
00295                           TEMP = TEMP - A(L+I,J)*X(IX)
00296                           IX = IX + INCX
00297   110                 CONTINUE
00298                       IF (NOUNIT) TEMP = TEMP/A(KPLUS1,J)
00299                       X(JX) = TEMP
00300                       JX = JX + INCX
00301                       IF (J.GT.K) KX = KX + INCX
00302   120             CONTINUE
00303               END IF
00304           ELSE
00305               IF (INCX.EQ.1) THEN
00306                   DO 140 J = N,1,-1
00307                       TEMP = X(J)
00308                       L = 1 - J
00309                       DO 130 I = MIN(N,J+K),J + 1,-1
00310                           TEMP = TEMP - A(L+I,J)*X(I)
00311   130                 CONTINUE
00312                       IF (NOUNIT) TEMP = TEMP/A(1,J)
00313                       X(J) = TEMP
00314   140             CONTINUE
00315               ELSE
00316                   KX = KX + (N-1)*INCX
00317                   JX = KX
00318                   DO 160 J = N,1,-1
00319                       TEMP = X(JX)
00320                       IX = KX
00321                       L = 1 - J
00322                       DO 150 I = MIN(N,J+K),J + 1,-1
00323                           TEMP = TEMP - A(L+I,J)*X(IX)
00324                           IX = IX - INCX
00325   150                 CONTINUE
00326                       IF (NOUNIT) TEMP = TEMP/A(1,J)
00327                       X(JX) = TEMP
00328                       JX = JX - INCX
00329                       IF ((N-J).GE.K) KX = KX - INCX
00330   160             CONTINUE
00331               END IF
00332           END IF
00333       END IF
00334 *
00335       RETURN
00336 *
00337 *     End of DTBSV .
00338 *
00339       END
 All Files Functions