3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
11 * SUBROUTINE CTBSV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
13 * .. Scalar Arguments ..
14 * INTEGER INCX,K,LDA,N
15 * CHARACTER DIAG,TRANS,UPLO
17 * .. Array Arguments ..
18 * COMPLEX A(LDA,*),X(*)
27 *> CTBSV solves one of the systems of equations
29 *> A*x = b, or A**T*x = b, or A**H*x = b,
31 *> where b and x are n element vectors and A is an n by n unit, or
32 *> non-unit, upper or lower triangular band matrix, with ( k + 1 )
35 *> No test for singularity or near-singularity is included in this
36 *> routine. Such tests must be performed before calling this routine.
44 *> UPLO is CHARACTER*1
45 *> On entry, UPLO specifies whether the matrix is an upper or
46 *> lower triangular matrix as follows:
48 *> UPLO = 'U' or 'u' A is an upper triangular matrix.
50 *> UPLO = 'L' or 'l' A is a lower triangular matrix.
55 *> TRANS is CHARACTER*1
56 *> On entry, TRANS specifies the equations to be solved as
59 *> TRANS = 'N' or 'n' A*x = b.
61 *> TRANS = 'T' or 't' A**T*x = b.
63 *> TRANS = 'C' or 'c' A**H*x = b.
68 *> DIAG is CHARACTER*1
69 *> On entry, DIAG specifies whether or not A is unit
70 *> triangular as follows:
72 *> DIAG = 'U' or 'u' A is assumed to be unit triangular.
74 *> DIAG = 'N' or 'n' A is not assumed to be unit
81 *> On entry, N specifies the order of the matrix A.
82 *> N must be at least zero.
88 *> On entry with UPLO = 'U' or 'u', K specifies the number of
89 *> super-diagonals of the matrix A.
90 *> On entry with UPLO = 'L' or 'l', K specifies the number of
91 *> sub-diagonals of the matrix A.
92 *> K must satisfy 0 .le. K.
97 *> A is COMPLEX array of DIMENSION ( LDA, n ).
98 *> Before entry with UPLO = 'U' or 'u', the leading ( k + 1 )
99 *> by n part of the array A must contain the upper triangular
100 *> band part of the matrix of coefficients, supplied column by
101 *> column, with the leading diagonal of the matrix in row
102 *> ( k + 1 ) of the array, the first super-diagonal starting at
103 *> position 2 in row k, and so on. The top left k by k triangle
104 *> of the array A is not referenced.
105 *> The following program segment will transfer an upper
106 *> triangular band matrix from conventional full matrix storage
111 *> DO 10, I = MAX( 1, J - K ), J
112 *> A( M + I, J ) = matrix( I, J )
116 *> Before entry with UPLO = 'L' or 'l', the leading ( k + 1 )
117 *> by n part of the array A must contain the lower triangular
118 *> band part of the matrix of coefficients, supplied column by
119 *> column, with the leading diagonal of the matrix in row 1 of
120 *> the array, the first sub-diagonal starting at position 1 in
121 *> row 2, and so on. The bottom right k by k triangle of the
122 *> array A is not referenced.
123 *> The following program segment will transfer a lower
124 *> triangular band matrix from conventional full matrix storage
129 *> DO 10, I = J, MIN( N, J + K )
130 *> A( M + I, J ) = matrix( I, J )
134 *> Note that when DIAG = 'U' or 'u' the elements of the array A
135 *> corresponding to the diagonal elements of the matrix are not
136 *> referenced, but are assumed to be unity.
142 *> On entry, LDA specifies the first dimension of A as declared
143 *> in the calling (sub) program. LDA must be at least
149 *> X is COMPLEX array of dimension at least
150 *> ( 1 + ( n - 1 )*abs( INCX ) ).
151 *> Before entry, the incremented array X must contain the n
152 *> element right-hand side vector b. On exit, X is overwritten
153 *> with the solution vector x.
159 *> On entry, INCX specifies the increment for the elements of
160 *> X. INCX must not be zero.
166 *> \author Univ. of Tennessee
167 *> \author Univ. of California Berkeley
168 *> \author Univ. of Colorado Denver
171 *> \date November 2011
173 *> \ingroup complex_blas_level2
175 *> \par Further Details:
176 * =====================
180 *> Level 2 Blas routine.
182 *> -- Written on 22-October-1986.
183 *> Jack Dongarra, Argonne National Lab.
184 *> Jeremy Du Croz, Nag Central Office.
185 *> Sven Hammarling, Nag Central Office.
186 *> Richard Hanson, Sandia National Labs.
189 * =====================================================================
190 SUBROUTINE CTBSV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
192 * -- Reference BLAS level2 routine (version 3.4.0) --
193 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
194 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
197 * .. Scalar Arguments ..
199 CHARACTER DIAG,TRANS,UPLO
201 * .. Array Arguments ..
202 COMPLEX A(LDA,*),X(*)
205 * =====================================================================
209 PARAMETER (ZERO= (0.0E+0,0.0E+0))
211 * .. Local Scalars ..
213 INTEGER I,INFO,IX,J,JX,KPLUS1,KX,L
214 LOGICAL NOCONJ,NOUNIT
216 * .. External Functions ..
220 * .. External Subroutines ..
223 * .. Intrinsic Functions ..
224 INTRINSIC CONJG,MAX,MIN
227 * Test the input parameters.
230 IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
232 ELSE IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND.
233 + .NOT.LSAME(TRANS,'C')) THEN
235 ELSE IF (.NOT.LSAME(DIAG,'U') .AND. .NOT.LSAME(DIAG,'N')) THEN
237 ELSE IF (N.LT.0) THEN
239 ELSE IF (K.LT.0) THEN
241 ELSE IF (LDA.LT. (K+1)) THEN
243 ELSE IF (INCX.EQ.0) THEN
247 CALL XERBLA('CTBSV ',INFO)
251 * Quick return if possible.
255 NOCONJ = LSAME(TRANS,'T')
256 NOUNIT = LSAME(DIAG,'N')
258 * Set up the start point in X if the increment is not unity. This
259 * will be ( N - 1 )*INCX too small for descending loops.
263 ELSE IF (INCX.NE.1) THEN
267 * Start the operations. In this version the elements of A are
268 * accessed by sequentially with one pass through A.
270 IF (LSAME(TRANS,'N')) THEN
272 * Form x := inv( A )*x.
274 IF (LSAME(UPLO,'U')) THEN
278 IF (X(J).NE.ZERO) THEN
280 IF (NOUNIT) X(J) = X(J)/A(KPLUS1,J)
282 DO 10 I = J - 1,MAX(1,J-K),-1
283 X(I) = X(I) - TEMP*A(L+I,J)
292 IF (X(JX).NE.ZERO) THEN
295 IF (NOUNIT) X(JX) = X(JX)/A(KPLUS1,J)
297 DO 30 I = J - 1,MAX(1,J-K),-1
298 X(IX) = X(IX) - TEMP*A(L+I,J)
308 IF (X(J).NE.ZERO) THEN
310 IF (NOUNIT) X(J) = X(J)/A(1,J)
312 DO 50 I = J + 1,MIN(N,J+K)
313 X(I) = X(I) - TEMP*A(L+I,J)
321 IF (X(JX).NE.ZERO) THEN
324 IF (NOUNIT) X(JX) = X(JX)/A(1,J)
326 DO 70 I = J + 1,MIN(N,J+K)
327 X(IX) = X(IX) - TEMP*A(L+I,J)
337 * Form x := inv( A**T )*x or x := inv( A**H )*x.
339 IF (LSAME(UPLO,'U')) THEN
346 DO 90 I = MAX(1,J-K),J - 1
347 TEMP = TEMP - A(L+I,J)*X(I)
349 IF (NOUNIT) TEMP = TEMP/A(KPLUS1,J)
351 DO 100 I = MAX(1,J-K),J - 1
352 TEMP = TEMP - CONJG(A(L+I,J))*X(I)
354 IF (NOUNIT) TEMP = TEMP/CONJG(A(KPLUS1,J))
365 DO 120 I = MAX(1,J-K),J - 1
366 TEMP = TEMP - A(L+I,J)*X(IX)
369 IF (NOUNIT) TEMP = TEMP/A(KPLUS1,J)
371 DO 130 I = MAX(1,J-K),J - 1
372 TEMP = TEMP - CONJG(A(L+I,J))*X(IX)
375 IF (NOUNIT) TEMP = TEMP/CONJG(A(KPLUS1,J))
379 IF (J.GT.K) KX = KX + INCX
388 DO 150 I = MIN(N,J+K),J + 1,-1
389 TEMP = TEMP - A(L+I,J)*X(I)
391 IF (NOUNIT) TEMP = TEMP/A(1,J)
393 DO 160 I = MIN(N,J+K),J + 1,-1
394 TEMP = TEMP - CONJG(A(L+I,J))*X(I)
396 IF (NOUNIT) TEMP = TEMP/CONJG(A(1,J))
408 DO 180 I = MIN(N,J+K),J + 1,-1
409 TEMP = TEMP - A(L+I,J)*X(IX)
412 IF (NOUNIT) TEMP = TEMP/A(1,J)
414 DO 190 I = MIN(N,J+K),J + 1,-1
415 TEMP = TEMP - CONJG(A(L+I,J))*X(IX)
418 IF (NOUNIT) TEMP = TEMP/CONJG(A(1,J))
422 IF ((N-J).GE.K) KX = KX - INCX