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