2
SUBROUTINE CTBMV (UPLO, TRANS, DIAG, N, K, A, LDA, X, INCX)
3
C***BEGIN PROLOGUE CTBMV
4
C***PURPOSE Multiply a complex vector by a complex triangular band
6
C***LIBRARY SLATEC (BLAS)
8
C***TYPE COMPLEX (STBMV-S, DTBMV-D, CTBMV-C)
9
C***KEYWORDS LEVEL 2 BLAS, LINEAR ALGEBRA
10
C***AUTHOR Dongarra, J. J., (ANL)
12
C Hammarling, S., (NAG)
13
C Hanson, R. J., (SNLA)
16
C CTBMV performs one of the matrix-vector operations
18
C x := A*x, or x := A'*x, or x := conjg( A')*x,
20
C where x is an n element vector and A is an n by n unit, or non-unit,
21
C upper or lower triangular band matrix, with ( k + 1 ) diagonals.
27
C On entry, UPLO specifies whether the matrix is an upper or
28
C lower triangular matrix as follows:
30
C UPLO = 'U' or 'u' A is an upper triangular matrix.
32
C UPLO = 'L' or 'l' A is a lower triangular matrix.
36
C TRANS - CHARACTER*1.
37
C On entry, TRANS specifies the operation to be performed as
40
C TRANS = 'N' or 'n' x := A*x.
42
C TRANS = 'T' or 't' x := A'*x.
44
C TRANS = 'C' or 'c' x := conjg( A' )*x.
49
C On entry, DIAG specifies whether or not A is unit
50
C triangular as follows:
52
C DIAG = 'U' or 'u' A is assumed to be unit triangular.
54
C DIAG = 'N' or 'n' A is not assumed to be unit
60
C On entry, N specifies the order of the matrix A.
61
C N must be at least zero.
65
C On entry with UPLO = 'U' or 'u', K specifies the number of
66
C super-diagonals of the matrix A.
67
C On entry with UPLO = 'L' or 'l', K specifies the number of
68
C sub-diagonals of the matrix A.
69
C K must satisfy 0 .le. K.
72
C A - COMPLEX array of DIMENSION ( LDA, n ).
73
C Before entry with UPLO = 'U' or 'u', the leading ( k + 1 )
74
C by n part of the array A must contain the upper triangular
75
C band part of the matrix of coefficients, supplied column by
76
C column, with the leading diagonal of the matrix in row
77
C ( k + 1 ) of the array, the first super-diagonal starting at
78
C position 2 in row k, and so on. The top left k by k triangle
79
C of the array A is not referenced.
80
C The following program segment will transfer an upper
81
C triangular band matrix from conventional full matrix storage
86
C DO 10, I = MAX( 1, J - K ), J
87
C A( M + I, J ) = matrix( I, J )
91
C Before entry with UPLO = 'L' or 'l', the leading ( k + 1 )
92
C by n part of the array A must contain the lower triangular
93
C band part of the matrix of coefficients, supplied column by
94
C column, with the leading diagonal of the matrix in row 1 of
95
C the array, the first sub-diagonal starting at position 1 in
96
C row 2, and so on. The bottom right k by k triangle of the
97
C array A is not referenced.
98
C The following program segment will transfer a lower
99
C triangular band matrix from conventional full matrix storage
104
C DO 10, I = J, MIN( N, J + K )
105
C A( M + I, J ) = matrix( I, J )
109
C Note that when DIAG = 'U' or 'u' the elements of the array A
110
C corresponding to the diagonal elements of the matrix are not
111
C referenced, but are assumed to be unity.
115
C On entry, LDA specifies the first dimension of A as declared
116
C in the calling (sub) program. LDA must be at least
120
C X - COMPLEX array of dimension at least
121
C ( 1 + ( n - 1 )*abs( INCX ) ).
122
C Before entry, the incremented array X must contain the n
123
C element vector x. On exit, X is overwritten with the
124
C transformed vector x.
127
C On entry, INCX specifies the increment for the elements of
128
C X. INCX must not be zero.
131
C***REFERENCES Dongarra, J. J., Du Croz, J., Hammarling, S., and
132
C Hanson, R. J. An extended set of Fortran basic linear
133
C algebra subprograms. ACM TOMS, Vol. 14, No. 1,
134
C pp. 1-17, March 1988.
135
C***ROUTINES CALLED LSAME, XERBLA
136
C***REVISION HISTORY (YYMMDD)
137
C 861022 DATE WRITTEN
138
C 910605 Modified to meet SLATEC prologue standards. Only comment
139
C lines were modified. (BKS)
140
C***END PROLOGUE CTBMV
141
C .. Scalar Arguments ..
142
INTEGER INCX, K, LDA, N
143
CHARACTER*1 DIAG, TRANS, UPLO
144
C .. Array Arguments ..
145
COMPLEX A( LDA, * ), X( * )
148
PARAMETER ( ZERO = ( 0.0E+0, 0.0E+0 ) )
149
C .. Local Scalars ..
151
INTEGER I, INFO, IX, J, JX, KPLUS1, KX, L
152
LOGICAL NOCONJ, NOUNIT
153
C .. External Functions ..
156
C .. External Subroutines ..
158
C .. Intrinsic Functions ..
159
INTRINSIC CONJG, MAX, MIN
160
C***FIRST EXECUTABLE STATEMENT CTBMV
162
C Test the input parameters.
165
IF ( .NOT.LSAME( UPLO , 'U' ).AND.
166
$ .NOT.LSAME( UPLO , 'L' ) )THEN
168
ELSE IF( .NOT.LSAME( TRANS, 'N' ).AND.
169
$ .NOT.LSAME( TRANS, 'T' ).AND.
170
$ .NOT.LSAME( TRANS, 'C' ) )THEN
172
ELSE IF( .NOT.LSAME( DIAG , 'U' ).AND.
173
$ .NOT.LSAME( DIAG , 'N' ) )THEN
175
ELSE IF( N.LT.0 )THEN
177
ELSE IF( K.LT.0 )THEN
179
ELSE IF( LDA.LT.( K + 1 ) )THEN
181
ELSE IF( INCX.EQ.0 )THEN
185
CALL XERBLA( 'CTBMV ', INFO )
189
C Quick return if possible.
194
NOCONJ = LSAME( TRANS, 'T' )
195
NOUNIT = LSAME( DIAG , 'N' )
197
C Set up the start point in X if the increment is not unity. This
198
C will be ( N - 1 )*INCX too small for descending loops.
201
KX = 1 - ( N - 1 )*INCX
202
ELSE IF( INCX.NE.1 )THEN
206
C Start the operations. In this version the elements of A are
207
C accessed sequentially with one pass through A.
209
IF( LSAME( TRANS, 'N' ) )THEN
213
IF( LSAME( UPLO, 'U' ) )THEN
217
IF( X( J ).NE.ZERO )THEN
220
DO 10, I = MAX( 1, J - K ), J - 1
221
X( I ) = X( I ) + TEMP*A( L + I, J )
224
$ X( J ) = X( J )*A( KPLUS1, J )
230
IF( X( JX ).NE.ZERO )THEN
234
DO 30, I = MAX( 1, J - K ), J - 1
235
X( IX ) = X( IX ) + TEMP*A( L + I, J )
239
$ X( JX ) = X( JX )*A( KPLUS1, J )
249
IF( X( J ).NE.ZERO )THEN
252
DO 50, I = MIN( N, J + K ), J + 1, -1
253
X( I ) = X( I ) + TEMP*A( L + I, J )
256
$ X( J ) = X( J )*A( 1, J )
260
KX = KX + ( N - 1 )*INCX
263
IF( X( JX ).NE.ZERO )THEN
267
DO 70, I = MIN( N, J + K ), J + 1, -1
268
X( IX ) = X( IX ) + TEMP*A( L + I, J )
272
$ X( JX ) = X( JX )*A( 1, J )
282
C Form x := A'*x or x := conjg( A' )*x.
284
IF( LSAME( UPLO, 'U' ) )THEN
292
$ TEMP = TEMP*A( KPLUS1, J )
293
DO 90, I = J - 1, MAX( 1, J - K ), -1
294
TEMP = TEMP + A( L + I, J )*X( I )
298
$ TEMP = TEMP*CONJG( A( KPLUS1, J ) )
299
DO 100, I = J - 1, MAX( 1, J - K ), -1
300
TEMP = TEMP + CONJG( A( L + I, J ) )*X( I )
306
KX = KX + ( N - 1 )*INCX
315
$ TEMP = TEMP*A( KPLUS1, J )
316
DO 120, I = J - 1, MAX( 1, J - K ), -1
317
TEMP = TEMP + A( L + I, J )*X( IX )
322
$ TEMP = TEMP*CONJG( A( KPLUS1, J ) )
323
DO 130, I = J - 1, MAX( 1, J - K ), -1
324
TEMP = TEMP + CONJG( A( L + I, J ) )*X( IX )
339
$ TEMP = TEMP*A( 1, J )
340
DO 150, I = J + 1, MIN( N, J + K )
341
TEMP = TEMP + A( L + I, J )*X( I )
345
$ TEMP = TEMP*CONJG( A( 1, J ) )
346
DO 160, I = J + 1, MIN( N, J + K )
347
TEMP = TEMP + CONJG( A( L + I, J ) )*X( I )
361
$ TEMP = TEMP*A( 1, J )
362
DO 180, I = J + 1, MIN( N, J + K )
363
TEMP = TEMP + A( L + I, J )*X( IX )
368
$ TEMP = TEMP*CONJG( A( 1, J ) )
369
DO 190, I = J + 1, MIN( N, J + K )
370
TEMP = TEMP + CONJG( A( L + I, J ) )*X( IX )