1*> \brief \b CTBTRS
2*
3*  =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6*            http://www.netlib.org/lapack/explore-html/
7*
8*> \htmlonly
9*> Download CTBTRS + dependencies
10*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ctbtrs.f">
11*> [TGZ]</a>
12*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ctbtrs.f">
13*> [ZIP]</a>
14*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ctbtrs.f">
15*> [TXT]</a>
16*> \endhtmlonly
17*
18*  Definition:
19*  ===========
20*
21*       SUBROUTINE CTBTRS( UPLO, TRANS, DIAG, N, KD, NRHS, AB, LDAB, B,
22*                          LDB, INFO )
23*
24*       .. Scalar Arguments ..
25*       CHARACTER          DIAG, TRANS, UPLO
26*       INTEGER            INFO, KD, LDAB, LDB, N, NRHS
27*       ..
28*       .. Array Arguments ..
29*       COMPLEX            AB( LDAB, * ), B( LDB, * )
30*       ..
31*
32*
33*> \par Purpose:
34*  =============
35*>
36*> \verbatim
37*>
38*> CTBTRS solves a triangular system of the form
39*>
40*>    A * X = B,  A**T * X = B,  or  A**H * X = B,
41*>
42*> where A is a triangular band matrix of order N, and B is an
43*> N-by-NRHS matrix.  A check is made to verify that A is nonsingular.
44*> \endverbatim
45*
46*  Arguments:
47*  ==========
48*
49*> \param[in] UPLO
50*> \verbatim
51*>          UPLO is CHARACTER*1
52*>          = 'U':  A is upper triangular;
53*>          = 'L':  A is lower triangular.
54*> \endverbatim
55*>
56*> \param[in] TRANS
57*> \verbatim
58*>          TRANS is CHARACTER*1
59*>          Specifies the form of the system of equations:
60*>          = 'N':  A * X = B     (No transpose)
61*>          = 'T':  A**T * X = B  (Transpose)
62*>          = 'C':  A**H * X = B  (Conjugate transpose)
63*> \endverbatim
64*>
65*> \param[in] DIAG
66*> \verbatim
67*>          DIAG is CHARACTER*1
68*>          = 'N':  A is non-unit triangular;
69*>          = 'U':  A is unit triangular.
70*> \endverbatim
71*>
72*> \param[in] N
73*> \verbatim
74*>          N is INTEGER
75*>          The order of the matrix A.  N >= 0.
76*> \endverbatim
77*>
78*> \param[in] KD
79*> \verbatim
80*>          KD is INTEGER
81*>          The number of superdiagonals or subdiagonals of the
82*>          triangular band matrix A.  KD >= 0.
83*> \endverbatim
84*>
85*> \param[in] NRHS
86*> \verbatim
87*>          NRHS is INTEGER
88*>          The number of right hand sides, i.e., the number of columns
89*>          of the matrix B.  NRHS >= 0.
90*> \endverbatim
91*>
92*> \param[in] AB
93*> \verbatim
94*>          AB is COMPLEX array, dimension (LDAB,N)
95*>          The upper or lower triangular band matrix A, stored in the
96*>          first kd+1 rows of AB.  The j-th column of A is stored
97*>          in the j-th column of the array AB as follows:
98*>          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
99*>          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd).
100*>          If DIAG = 'U', the diagonal elements of A are not referenced
101*>          and are assumed to be 1.
102*> \endverbatim
103*>
104*> \param[in] LDAB
105*> \verbatim
106*>          LDAB is INTEGER
107*>          The leading dimension of the array AB.  LDAB >= KD+1.
108*> \endverbatim
109*>
110*> \param[in,out] B
111*> \verbatim
112*>          B is COMPLEX array, dimension (LDB,NRHS)
113*>          On entry, the right hand side matrix B.
114*>          On exit, if INFO = 0, the solution matrix X.
115*> \endverbatim
116*>
117*> \param[in] LDB
118*> \verbatim
119*>          LDB is INTEGER
120*>          The leading dimension of the array B.  LDB >= max(1,N).
121*> \endverbatim
122*>
123*> \param[out] INFO
124*> \verbatim
125*>          INFO is INTEGER
126*>          = 0:  successful exit
127*>          < 0:  if INFO = -i, the i-th argument had an illegal value
128*>          > 0:  if INFO = i, the i-th diagonal element of A is zero,
129*>                indicating that the matrix is singular and the
130*>                solutions X have not been computed.
131*> \endverbatim
132*
133*  Authors:
134*  ========
135*
136*> \author Univ. of Tennessee
137*> \author Univ. of California Berkeley
138*> \author Univ. of Colorado Denver
139*> \author NAG Ltd.
140*
141*> \ingroup complexOTHERcomputational
142*
143*  =====================================================================
144      SUBROUTINE CTBTRS( UPLO, TRANS, DIAG, N, KD, NRHS, AB, LDAB, B,
145     $                   LDB, INFO )
146*
147*  -- LAPACK computational routine --
148*  -- LAPACK is a software package provided by Univ. of Tennessee,    --
149*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
150*
151*     .. Scalar Arguments ..
152      CHARACTER          DIAG, TRANS, UPLO
153      INTEGER            INFO, KD, LDAB, LDB, N, NRHS
154*     ..
155*     .. Array Arguments ..
156      COMPLEX            AB( LDAB, * ), B( LDB, * )
157*     ..
158*
159*  =====================================================================
160*
161*     .. Parameters ..
162      COMPLEX            ZERO
163      PARAMETER          ( ZERO = ( 0.0E+0, 0.0E+0 ) )
164*     ..
165*     .. Local Scalars ..
166      LOGICAL            NOUNIT, UPPER
167      INTEGER            J
168*     ..
169*     .. External Functions ..
170      LOGICAL            LSAME
171      EXTERNAL           LSAME
172*     ..
173*     .. External Subroutines ..
174      EXTERNAL           CTBSV, XERBLA
175*     ..
176*     .. Intrinsic Functions ..
177      INTRINSIC          MAX
178*     ..
179*     .. Executable Statements ..
180*
181*     Test the input parameters.
182*
183      INFO = 0
184      NOUNIT = LSAME( DIAG, 'N' )
185      UPPER = LSAME( UPLO, 'U' )
186      IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
187         INFO = -1
188      ELSE IF( .NOT.LSAME( TRANS, 'N' ) .AND. .NOT.
189     $         LSAME( TRANS, 'T' ) .AND. .NOT.LSAME( TRANS, 'C' ) ) THEN
190         INFO = -2
191      ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THEN
192         INFO = -3
193      ELSE IF( N.LT.0 ) THEN
194         INFO = -4
195      ELSE IF( KD.LT.0 ) THEN
196         INFO = -5
197      ELSE IF( NRHS.LT.0 ) THEN
198         INFO = -6
199      ELSE IF( LDAB.LT.KD+1 ) THEN
200         INFO = -8
201      ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
202         INFO = -10
203      END IF
204      IF( INFO.NE.0 ) THEN
205         CALL XERBLA( 'CTBTRS', -INFO )
206         RETURN
207      END IF
208*
209*     Quick return if possible
210*
211      IF( N.EQ.0 )
212     $   RETURN
213*
214*     Check for singularity.
215*
216      IF( NOUNIT ) THEN
217         IF( UPPER ) THEN
218            DO 10 INFO = 1, N
219               IF( AB( KD+1, INFO ).EQ.ZERO )
220     $            RETURN
221   10       CONTINUE
222         ELSE
223            DO 20 INFO = 1, N
224               IF( AB( 1, INFO ).EQ.ZERO )
225     $            RETURN
226   20       CONTINUE
227         END IF
228      END IF
229      INFO = 0
230*
231*     Solve A * X = B,  A**T * X = B,  or  A**H * X = B.
232*
233      DO 30 J = 1, NRHS
234         CALL CTBSV( UPLO, TRANS, DIAG, N, KD, AB, LDAB, B( 1, J ), 1 )
235   30 CONTINUE
236*
237      RETURN
238*
239*     End of CTBTRS
240*
241      END
242