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