001:       SUBROUTINE ZPTTRS( UPLO, N, NRHS, D, E, B, LDB, INFO )
002: *
003: *  -- LAPACK routine (version 3.2) --
004: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
005: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
006: *     November 2006
007: *
008: *     .. Scalar Arguments ..
009:       CHARACTER          UPLO
010:       INTEGER            INFO, LDB, N, NRHS
011: *     ..
012: *     .. Array Arguments ..
013:       DOUBLE PRECISION   D( * )
014:       COMPLEX*16         B( LDB, * ), E( * )
015: *     ..
016: *
017: *  Purpose
018: *  =======
019: *
020: *  ZPTTRS solves a tridiagonal system of the form
021: *     A * X = B
022: *  using the factorization A = U'*D*U or A = L*D*L' computed by ZPTTRF.
023: *  D is a diagonal matrix specified in the vector D, U (or L) is a unit
024: *  bidiagonal matrix whose superdiagonal (subdiagonal) is specified in
025: *  the vector E, and X and B are N by NRHS matrices.
026: *
027: *  Arguments
028: *  =========
029: *
030: *  UPLO    (input) CHARACTER*1
031: *          Specifies the form of the factorization and whether the
032: *          vector E is the superdiagonal of the upper bidiagonal factor
033: *          U or the subdiagonal of the lower bidiagonal factor L.
034: *          = 'U':  A = U'*D*U, E is the superdiagonal of U
035: *          = 'L':  A = L*D*L', E is the subdiagonal of L
036: *
037: *  N       (input) INTEGER
038: *          The order of the tridiagonal matrix A.  N >= 0.
039: *
040: *  NRHS    (input) INTEGER
041: *          The number of right hand sides, i.e., the number of columns
042: *          of the matrix B.  NRHS >= 0.
043: *
044: *  D       (input) DOUBLE PRECISION array, dimension (N)
045: *          The n diagonal elements of the diagonal matrix D from the
046: *          factorization A = U'*D*U or A = L*D*L'.
047: *
048: *  E       (input) COMPLEX*16 array, dimension (N-1)
049: *          If UPLO = 'U', the (n-1) superdiagonal elements of the unit
050: *          bidiagonal factor U from the factorization A = U'*D*U.
051: *          If UPLO = 'L', the (n-1) subdiagonal elements of the unit
052: *          bidiagonal factor L from the factorization A = L*D*L'.
053: *
054: *  B       (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
055: *          On entry, the right hand side vectors B for the system of
056: *          linear equations.
057: *          On exit, the solution vectors, X.
058: *
059: *  LDB     (input) INTEGER
060: *          The leading dimension of the array B.  LDB >= max(1,N).
061: *
062: *  INFO    (output) INTEGER
063: *          = 0: successful exit
064: *          < 0: if INFO = -k, the k-th argument had an illegal value
065: *
066: *  =====================================================================
067: *
068: *     .. Local Scalars ..
069:       LOGICAL            UPPER
070:       INTEGER            IUPLO, J, JB, NB
071: *     ..
072: *     .. External Functions ..
073:       INTEGER            ILAENV
074:       EXTERNAL           ILAENV
075: *     ..
076: *     .. External Subroutines ..
077:       EXTERNAL           XERBLA, ZPTTS2
078: *     ..
079: *     .. Intrinsic Functions ..
080:       INTRINSIC          MAX, MIN
081: *     ..
082: *     .. Executable Statements ..
083: *
084: *     Test the input arguments.
085: *
086:       INFO = 0
087:       UPPER = ( UPLO.EQ.'U' .OR. UPLO.EQ.'u' )
088:       IF( .NOT.UPPER .AND. .NOT.( UPLO.EQ.'L' .OR. UPLO.EQ.'l' ) ) THEN
089:          INFO = -1
090:       ELSE IF( N.LT.0 ) THEN
091:          INFO = -2
092:       ELSE IF( NRHS.LT.0 ) THEN
093:          INFO = -3
094:       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
095:          INFO = -7
096:       END IF
097:       IF( INFO.NE.0 ) THEN
098:          CALL XERBLA( 'ZPTTRS', -INFO )
099:          RETURN
100:       END IF
101: *
102: *     Quick return if possible
103: *
104:       IF( N.EQ.0 .OR. NRHS.EQ.0 )
105:      $   RETURN
106: *
107: *     Determine the number of right-hand sides to solve at a time.
108: *
109:       IF( NRHS.EQ.1 ) THEN
110:          NB = 1
111:       ELSE
112:          NB = MAX( 1, ILAENV( 1, 'ZPTTRS', UPLO, N, NRHS, -1, -1 ) )
113:       END IF
114: *
115: *     Decode UPLO
116: *
117:       IF( UPPER ) THEN
118:          IUPLO = 1
119:       ELSE
120:          IUPLO = 0
121:       END IF
122: *
123:       IF( NB.GE.NRHS ) THEN
124:          CALL ZPTTS2( IUPLO, N, NRHS, D, E, B, LDB )
125:       ELSE
126:          DO 10 J = 1, NRHS, NB
127:             JB = MIN( NRHS-J+1, NB )
128:             CALL ZPTTS2( IUPLO, N, JB, D, E, B( 1, J ), LDB )
129:    10    CONTINUE
130:       END IF
131: *
132:       RETURN
133: *
134: *     End of ZPTTRS
135: *
136:       END
137: