1c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      SUBROUTINE CTBMV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
2c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     .. Scalar Arguments ..
3c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      INTEGER INCX,K,LDA,N
4c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      CHARACTER DIAG,TRANS,UPLO
5c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     ..
6c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     .. Array Arguments ..
7c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      COMPLEX A(LDA,*),X(*)
8c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     ..
9c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
10c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  Purpose
11c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  =======
12c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
13c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  CTBMV  performs one of the matrix-vector operations
14c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
15c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     x := A*x,   or   x := A'*x,   or   x := conjg( A' )*x,
16c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
17c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  where x is an n element vector and  A is an n by n unit, or non-unit,
18c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  upper or lower triangular band matrix, with ( k + 1 ) diagonals.
19c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
20c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  Arguments
21c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  ==========
22c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
23c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  UPLO   - CHARACTER*1.
24c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           On entry, UPLO specifies whether the matrix is an upper or
25c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           lower triangular matrix as follows:
26c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
27c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*              UPLO = 'U' or 'u'   A is an upper triangular matrix.
28c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
29c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*              UPLO = 'L' or 'l'   A is a lower triangular matrix.
30c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
31c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           Unchanged on exit.
32c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
33c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  TRANS  - CHARACTER*1.
34c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           On entry, TRANS specifies the operation to be performed as
35c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           follows:
36c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
37c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*              TRANS = 'N' or 'n'   x := A*x.
38c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
39c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*              TRANS = 'T' or 't'   x := A'*x.
40c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
41c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*              TRANS = 'C' or 'c'   x := conjg( A' )*x.
42c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
43c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           Unchanged on exit.
44c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
45c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  DIAG   - CHARACTER*1.
46c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           On entry, DIAG specifies whether or not A is unit
47c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           triangular as follows:
48c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
49c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*              DIAG = 'U' or 'u'   A is assumed to be unit triangular.
50c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
51c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*              DIAG = 'N' or 'n'   A is not assumed to be unit
52c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*                                  triangular.
53c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
54c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           Unchanged on exit.
55c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
56c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  N      - INTEGER.
57c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           On entry, N specifies the order of the matrix A.
58c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           N must be at least zero.
59c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           Unchanged on exit.
60c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
61c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  K      - INTEGER.
62c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           On entry with UPLO = 'U' or 'u', K specifies the number of
63c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           super-diagonals of the matrix A.
64c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           On entry with UPLO = 'L' or 'l', K specifies the number of
65c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           sub-diagonals of the matrix A.
66c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           K must satisfy  0 .le. K.
67c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           Unchanged on exit.
68c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
69c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  A      - COMPLEX          array of DIMENSION ( LDA, n ).
70c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           Before entry with UPLO = 'U' or 'u', the leading ( k + 1 )
71c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           by n part of the array A must contain the upper triangular
72c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           band part of the matrix of coefficients, supplied column by
73c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           column, with the leading diagonal of the matrix in row
74c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           ( k + 1 ) of the array, the first super-diagonal starting at
75c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           position 2 in row k, and so on. The top left k by k triangle
76c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           of the array A is not referenced.
77c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           The following program segment will transfer an upper
78c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           triangular band matrix from conventional full matrix storage
79c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           to band storage:
80c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
81c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*                 DO 20, J = 1, N
82c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*                    M = K + 1 - J
83c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*                    DO 10, I = MAX( 1, J - K ), J
84c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*                       A( M + I, J ) = matrix( I, J )
85c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*              10    CONTINUE
86c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*              20 CONTINUE
87c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
88c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           Before entry with UPLO = 'L' or 'l', the leading ( k + 1 )
89c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           by n part of the array A must contain the lower triangular
90c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           band part of the matrix of coefficients, supplied column by
91c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           column, with the leading diagonal of the matrix in row 1 of
92c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           the array, the first sub-diagonal starting at position 1 in
93c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           row 2, and so on. The bottom right k by k triangle of the
94c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           array A is not referenced.
95c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           The following program segment will transfer a lower
96c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           triangular band matrix from conventional full matrix storage
97c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           to band storage:
98c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
99c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*                 DO 20, J = 1, N
100c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*                    M = 1 - J
101c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*                    DO 10, I = J, MIN( N, J + K )
102c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*                       A( M + I, J ) = matrix( I, J )
103c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*              10    CONTINUE
104c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*              20 CONTINUE
105c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
106c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           Note that when DIAG = 'U' or 'u' the elements of the array A
107c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           corresponding to the diagonal elements of the matrix are not
108c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           referenced, but are assumed to be unity.
109c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           Unchanged on exit.
110c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
111c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  LDA    - INTEGER.
112c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           On entry, LDA specifies the first dimension of A as declared
113c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           in the calling (sub) program. LDA must be at least
114c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           ( k + 1 ).
115c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           Unchanged on exit.
116c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
117c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  X      - COMPLEX          array of dimension at least
118c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           ( 1 + ( n - 1 )*abs( INCX ) ).
119c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           Before entry, the incremented array X must contain the n
120c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           element vector x. On exit, X is overwritten with the
121c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           tranformed vector x.
122c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
123c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  INCX   - INTEGER.
124c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           On entry, INCX specifies the increment for the elements of
125c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           X. INCX must not be zero.
126c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*           Unchanged on exit.
127c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
128c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  Further Details
129c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  ===============
130c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
131c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  Level 2 Blas routine.
132c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
133c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  -- Written on 22-October-1986.
134c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     Jack Dongarra, Argonne National Lab.
135c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     Jeremy Du Croz, Nag Central Office.
136c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     Sven Hammarling, Nag Central Office.
137c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     Richard Hanson, Sandia National Labs.
138c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
139c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*  =====================================================================
140c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
141c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     .. Parameters ..
142c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      COMPLEX ZERO
143c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      PARAMETER (ZERO= (0.0E+0,0.0E+0))
144c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     ..
145c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     .. Local Scalars ..
146c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      COMPLEX TEMP
147c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      INTEGER I,INFO,IX,J,JX,KPLUS1,KX,L
148c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      LOGICAL NOCONJ,NOUNIT
149c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     ..
150c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     .. External Functions ..
151c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      LOGICAL LSAME
152c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      EXTERNAL LSAME
153c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     ..
154c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     .. External Subroutines ..
155c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      EXTERNAL XERBLA
156c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     ..
157c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     .. Intrinsic Functions ..
158c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      INTRINSIC CONJG,MAX,MIN
159c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     ..
160c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
161c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     Test the input parameters.
162c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
163c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      INFO = 0
164c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
165c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath          INFO = 1
166c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      ELSE IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND.
167c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath     +         .NOT.LSAME(TRANS,'C')) THEN
168c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath          INFO = 2
169c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      ELSE IF (.NOT.LSAME(DIAG,'U') .AND. .NOT.LSAME(DIAG,'N')) THEN
170c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath          INFO = 3
171c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      ELSE IF (N.LT.0) THEN
172c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath          INFO = 4
173c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      ELSE IF (K.LT.0) THEN
174c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath          INFO = 5
175c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      ELSE IF (LDA.LT. (K+1)) THEN
176c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath          INFO = 7
177c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      ELSE IF (INCX.EQ.0) THEN
178c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath          INFO = 9
179c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      END IF
180c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      IF (INFO.NE.0) THEN
181c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath          CALL XERBLA('CTBMV ',INFO)
182c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath          RETURN
183c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      END IF
184c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
185c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     Quick return if possible.
186c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
187c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      IF (N.EQ.0) RETURN
188c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
189c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      NOCONJ = LSAME(TRANS,'T')
190c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      NOUNIT = LSAME(DIAG,'N')
191c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
192c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     Set up the start point in X if the increment is not unity. This
193c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     will be  ( N - 1 )*INCX   too small for descending loops.
194c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
195c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      IF (INCX.LE.0) THEN
196c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath          KX = 1 - (N-1)*INCX
197c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      ELSE IF (INCX.NE.1) THEN
198c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath          KX = 1
199c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      END IF
200c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
201c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     Start the operations. In this version the elements of A are
202c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     accessed sequentially with one pass through A.
203c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
204c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      IF (LSAME(TRANS,'N')) THEN
205c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
206c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*         Form  x := A*x.
207c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
208c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath          IF (LSAME(UPLO,'U')) THEN
209c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath              KPLUS1 = K + 1
210c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath              IF (INCX.EQ.1) THEN
211c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                  DO 20 J = 1,N
212c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      IF (X(J).NE.ZERO) THEN
213c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          TEMP = X(J)
214c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          L = KPLUS1 - J
215c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          DO 10 I = MAX(1,J-K),J - 1
216c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                              X(I) = X(I) + TEMP*A(L+I,J)
217c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath   10                     CONTINUE
218c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          IF (NOUNIT) X(J) = X(J)*A(KPLUS1,J)
219c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      END IF
220c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath   20             CONTINUE
221c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath              ELSE
222c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                  JX = KX
223c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                  DO 40 J = 1,N
224c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      IF (X(JX).NE.ZERO) THEN
225c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          TEMP = X(JX)
226c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          IX = KX
227c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          L = KPLUS1 - J
228c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          DO 30 I = MAX(1,J-K),J - 1
229c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                              X(IX) = X(IX) + TEMP*A(L+I,J)
230c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                              IX = IX + INCX
231c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath   30                     CONTINUE
232c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          IF (NOUNIT) X(JX) = X(JX)*A(KPLUS1,J)
233c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      END IF
234c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      JX = JX + INCX
235c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      IF (J.GT.K) KX = KX + INCX
236c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath   40             CONTINUE
237c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath              END IF
238c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath          ELSE
239c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath              IF (INCX.EQ.1) THEN
240c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                  DO 60 J = N,1,-1
241c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      IF (X(J).NE.ZERO) THEN
242c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          TEMP = X(J)
243c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          L = 1 - J
244c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          DO 50 I = MIN(N,J+K),J + 1,-1
245c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                              X(I) = X(I) + TEMP*A(L+I,J)
246c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath   50                     CONTINUE
247c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          IF (NOUNIT) X(J) = X(J)*A(1,J)
248c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      END IF
249c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath   60             CONTINUE
250c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath              ELSE
251c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                  KX = KX + (N-1)*INCX
252c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                  JX = KX
253c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                  DO 80 J = N,1,-1
254c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      IF (X(JX).NE.ZERO) THEN
255c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          TEMP = X(JX)
256c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          IX = KX
257c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          L = 1 - J
258c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          DO 70 I = MIN(N,J+K),J + 1,-1
259c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                              X(IX) = X(IX) + TEMP*A(L+I,J)
260c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                              IX = IX - INCX
261c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath   70                     CONTINUE
262c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          IF (NOUNIT) X(JX) = X(JX)*A(1,J)
263c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      END IF
264c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      JX = JX - INCX
265c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      IF ((N-J).GE.K) KX = KX - INCX
266c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath   80             CONTINUE
267c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath              END IF
268c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath          END IF
269c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      ELSE
270c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
271c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*        Form  x := A'*x  or  x := conjg( A' )*x.
272c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
273c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath          IF (LSAME(UPLO,'U')) THEN
274c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath              KPLUS1 = K + 1
275c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath              IF (INCX.EQ.1) THEN
276c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                  DO 110 J = N,1,-1
277c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      TEMP = X(J)
278c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      L = KPLUS1 - J
279c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      IF (NOCONJ) THEN
280c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          IF (NOUNIT) TEMP = TEMP*A(KPLUS1,J)
281c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          DO 90 I = J - 1,MAX(1,J-K),-1
282c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                              TEMP = TEMP + A(L+I,J)*X(I)
283c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath   90                     CONTINUE
284c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      ELSE
285c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          IF (NOUNIT) TEMP = TEMP*CONJG(A(KPLUS1,J))
286c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          DO 100 I = J - 1,MAX(1,J-K),-1
287c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                              TEMP = TEMP + CONJG(A(L+I,J))*X(I)
288c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  100                     CONTINUE
289c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      END IF
290c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      X(J) = TEMP
291c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  110             CONTINUE
292c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath              ELSE
293c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                  KX = KX + (N-1)*INCX
294c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                  JX = KX
295c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                  DO 140 J = N,1,-1
296c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      TEMP = X(JX)
297c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      KX = KX - INCX
298c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      IX = KX
299c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      L = KPLUS1 - J
300c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      IF (NOCONJ) THEN
301c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          IF (NOUNIT) TEMP = TEMP*A(KPLUS1,J)
302c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          DO 120 I = J - 1,MAX(1,J-K),-1
303c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                              TEMP = TEMP + A(L+I,J)*X(IX)
304c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                              IX = IX - INCX
305c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  120                     CONTINUE
306c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      ELSE
307c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          IF (NOUNIT) TEMP = TEMP*CONJG(A(KPLUS1,J))
308c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          DO 130 I = J - 1,MAX(1,J-K),-1
309c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                              TEMP = TEMP + CONJG(A(L+I,J))*X(IX)
310c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                              IX = IX - INCX
311c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  130                     CONTINUE
312c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      END IF
313c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      X(JX) = TEMP
314c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      JX = JX - INCX
315c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  140             CONTINUE
316c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath              END IF
317c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath          ELSE
318c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath              IF (INCX.EQ.1) THEN
319c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                  DO 170 J = 1,N
320c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      TEMP = X(J)
321c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      L = 1 - J
322c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      IF (NOCONJ) THEN
323c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          IF (NOUNIT) TEMP = TEMP*A(1,J)
324c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          DO 150 I = J + 1,MIN(N,J+K)
325c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                              TEMP = TEMP + A(L+I,J)*X(I)
326c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  150                     CONTINUE
327c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      ELSE
328c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          IF (NOUNIT) TEMP = TEMP*CONJG(A(1,J))
329c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          DO 160 I = J + 1,MIN(N,J+K)
330c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                              TEMP = TEMP + CONJG(A(L+I,J))*X(I)
331c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  160                     CONTINUE
332c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      END IF
333c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      X(J) = TEMP
334c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  170             CONTINUE
335c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath              ELSE
336c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                  JX = KX
337c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                  DO 200 J = 1,N
338c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      TEMP = X(JX)
339c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      KX = KX + INCX
340c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      IX = KX
341c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      L = 1 - J
342c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      IF (NOCONJ) THEN
343c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          IF (NOUNIT) TEMP = TEMP*A(1,J)
344c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          DO 180 I = J + 1,MIN(N,J+K)
345c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                              TEMP = TEMP + A(L+I,J)*X(IX)
346c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                              IX = IX + INCX
347c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  180                     CONTINUE
348c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      ELSE
349c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          IF (NOUNIT) TEMP = TEMP*CONJG(A(1,J))
350c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                          DO 190 I = J + 1,MIN(N,J+K)
351c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                              TEMP = TEMP + CONJG(A(L+I,J))*X(IX)
352c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                              IX = IX + INCX
353c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  190                     CONTINUE
354c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      END IF
355c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      X(JX) = TEMP
356c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath                      JX = JX + INCX
357c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  200             CONTINUE
358c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath              END IF
359c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath          END IF
360c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      END IF
361c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
362c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      RETURN
363c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
364c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*     End of CTBMV .
365c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath*
366c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      END
367