001:       SUBROUTINE SGTTRS( TRANS, N, NRHS, DL, D, DU, DU2, IPIV, B, LDB,
002:      $                   INFO )
003: *
004: *  -- LAPACK routine (version 3.2) --
005: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
006: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
007: *     November 2006
008: *
009: *     .. Scalar Arguments ..
010:       CHARACTER          TRANS
011:       INTEGER            INFO, LDB, N, NRHS
012: *     ..
013: *     .. Array Arguments ..
014:       INTEGER            IPIV( * )
015:       REAL               B( LDB, * ), D( * ), DL( * ), DU( * ), DU2( * )
016: *     ..
017: *
018: *  Purpose
019: *  =======
020: *
021: *  SGTTRS solves one of the systems of equations
022: *     A*X = B  or  A'*X = B,
023: *  with a tridiagonal matrix A using the LU factorization computed
024: *  by SGTTRF.
025: *
026: *  Arguments
027: *  =========
028: *
029: *  TRANS   (input) CHARACTER*1
030: *          Specifies the form of the system of equations.
031: *          = 'N':  A * X = B  (No transpose)
032: *          = 'T':  A'* X = B  (Transpose)
033: *          = 'C':  A'* X = B  (Conjugate transpose = Transpose)
034: *
035: *  N       (input) INTEGER
036: *          The order of the matrix A.
037: *
038: *  NRHS    (input) INTEGER
039: *          The number of right hand sides, i.e., the number of columns
040: *          of the matrix B.  NRHS >= 0.
041: *
042: *  DL      (input) REAL array, dimension (N-1)
043: *          The (n-1) multipliers that define the matrix L from the
044: *          LU factorization of A.
045: *
046: *  D       (input) REAL array, dimension (N)
047: *          The n diagonal elements of the upper triangular matrix U from
048: *          the LU factorization of A.
049: *
050: *  DU      (input) REAL array, dimension (N-1)
051: *          The (n-1) elements of the first super-diagonal of U.
052: *
053: *  DU2     (input) REAL array, dimension (N-2)
054: *          The (n-2) elements of the second super-diagonal of U.
055: *
056: *  IPIV    (input) INTEGER array, dimension (N)
057: *          The pivot indices; for 1 <= i <= n, row i of the matrix was
058: *          interchanged with row IPIV(i).  IPIV(i) will always be either
059: *          i or i+1; IPIV(i) = i indicates a row interchange was not
060: *          required.
061: *
062: *  B       (input/output) REAL array, dimension (LDB,NRHS)
063: *          On entry, the matrix of right hand side vectors B.
064: *          On exit, B is overwritten by the solution vectors X.
065: *
066: *  LDB     (input) INTEGER
067: *          The leading dimension of the array B.  LDB >= max(1,N).
068: *
069: *  INFO    (output) INTEGER
070: *          = 0:  successful exit
071: *          < 0:  if INFO = -i, the i-th argument had an illegal value
072: *
073: *  =====================================================================
074: *
075: *     .. Local Scalars ..
076:       LOGICAL            NOTRAN
077:       INTEGER            ITRANS, J, JB, NB
078: *     ..
079: *     .. External Functions ..
080:       INTEGER            ILAENV
081:       EXTERNAL           ILAENV
082: *     ..
083: *     .. External Subroutines ..
084:       EXTERNAL           SGTTS2, XERBLA
085: *     ..
086: *     .. Intrinsic Functions ..
087:       INTRINSIC          MAX, MIN
088: *     ..
089: *     .. Executable Statements ..
090: *
091:       INFO = 0
092:       NOTRAN = ( TRANS.EQ.'N' .OR. TRANS.EQ.'n' )
093:       IF( .NOT.NOTRAN .AND. .NOT.( TRANS.EQ.'T' .OR. TRANS.EQ.
094:      $    't' ) .AND. .NOT.( TRANS.EQ.'C' .OR. TRANS.EQ.'c' ) ) THEN
095:          INFO = -1
096:       ELSE IF( N.LT.0 ) THEN
097:          INFO = -2
098:       ELSE IF( NRHS.LT.0 ) THEN
099:          INFO = -3
100:       ELSE IF( LDB.LT.MAX( N, 1 ) ) THEN
101:          INFO = -10
102:       END IF
103:       IF( INFO.NE.0 ) THEN
104:          CALL XERBLA( 'SGTTRS', -INFO )
105:          RETURN
106:       END IF
107: *
108: *     Quick return if possible
109: *
110:       IF( N.EQ.0 .OR. NRHS.EQ.0 )
111:      $   RETURN
112: *
113: *     Decode TRANS
114: *
115:       IF( NOTRAN ) THEN
116:          ITRANS = 0
117:       ELSE
118:          ITRANS = 1
119:       END IF
120: *
121: *     Determine the number of right-hand sides to solve at a time.
122: *
123:       IF( NRHS.EQ.1 ) THEN
124:          NB = 1
125:       ELSE
126:          NB = MAX( 1, ILAENV( 1, 'SGTTRS', TRANS, N, NRHS, -1, -1 ) )
127:       END IF
128: *
129:       IF( NB.GE.NRHS ) THEN
130:          CALL SGTTS2( ITRANS, N, NRHS, DL, D, DU, DU2, IPIV, B, LDB )
131:       ELSE
132:          DO 10 J = 1, NRHS, NB
133:             JB = MIN( NRHS-J+1, NB )
134:             CALL SGTTS2( ITRANS, N, JB, DL, D, DU, DU2, IPIV, B( 1, J ),
135:      $                   LDB )
136:    10    CONTINUE
137:       END IF
138: *
139: *     End of SGTTRS
140: *
141:       END
142: