001:       SUBROUTINE CGTTRS( 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:       COMPLEX            B( LDB, * ), D( * ), DL( * ), DU( * ), DU2( * )
015: *     ..
016: *
017: *  Purpose
018: *  =======
019: *
020: *  CGTTRS solves one of the systems of equations
021: *     A * X = B,  A**T * X = B,  or  A**H * X = B,
022: *  with a tridiagonal matrix A using the LU factorization computed
023: *  by CGTTRF.
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**T * X = B  (Transpose)
032: *          = 'C':  A**H * X = B  (Conjugate 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) COMPLEX 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) COMPLEX 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) COMPLEX array, dimension (N-1)
050: *          The (n-1) elements of the first super-diagonal of U.
051: *
052: *  DU2     (input) COMPLEX 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) COMPLEX 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 = -k, the k-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           CGTTS2, 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( 'CGTTRS', -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 IF( TRANS.EQ.'T' .OR. TRANS.EQ.'t' ) THEN
117:          ITRANS = 1
118:       ELSE
119:          ITRANS = 2
120:       END IF
121: *
122: *     Determine the number of right-hand sides to solve at a time.
123: *
124:       IF( NRHS.EQ.1 ) THEN
125:          NB = 1
126:       ELSE
127:          NB = MAX( 1, ILAENV( 1, 'CGTTRS', TRANS, N, NRHS, -1, -1 ) )
128:       END IF
129: *
130:       IF( NB.GE.NRHS ) THEN
131:          CALL CGTTS2( ITRANS, N, NRHS, DL, D, DU, DU2, IPIV, B, LDB )
132:       ELSE
133:          DO 10 J = 1, NRHS, NB
134:             JB = MIN( NRHS-J+1, NB )
135:             CALL CGTTS2( ITRANS, N, JB, DL, D, DU, DU2, IPIV, B( 1, J ),
136:      $                   LDB )
137:    10    CONTINUE
138:       END IF
139: *
140: *     End of CGTTRS
141: *
142:       END
143: