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