```001:       SUBROUTINE CLAGTM( TRANS, N, NRHS, ALPHA, DL, D, DU, X, LDX, BETA,
002:      \$                   B, LDB )
003: *
004: *  -- LAPACK auxiliary routine (version 3.2) --
005: *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
006: *     November 2006
007: *
008: *     .. Scalar Arguments ..
009:       CHARACTER          TRANS
010:       INTEGER            LDB, LDX, N, NRHS
011:       REAL               ALPHA, BETA
012: *     ..
013: *     .. Array Arguments ..
014:       COMPLEX            B( LDB, * ), D( * ), DL( * ), DU( * ),
015:      \$                   X( LDX, * )
016: *     ..
017: *
018: *  Purpose
019: *  =======
020: *
021: *  CLAGTM performs a matrix-vector product of the form
022: *
023: *     B := alpha * A * X + beta * B
024: *
025: *  where A is a tridiagonal matrix of order N, B and X are N by NRHS
026: *  matrices, and alpha and beta are real scalars, each of which may be
027: *  0., 1., or -1.
028: *
029: *  Arguments
030: *  =========
031: *
032: *  TRANS   (input) CHARACTER*1
033: *          Specifies the operation applied to A.
034: *          = 'N':  No transpose, B := alpha * A * X + beta * B
035: *          = 'T':  Transpose,    B := alpha * A**T * X + beta * B
036: *          = 'C':  Conjugate transpose, B := alpha * A**H * X + beta * B
037: *
038: *  N       (input) INTEGER
039: *          The order of the matrix A.  N >= 0.
040: *
041: *  NRHS    (input) INTEGER
042: *          The number of right hand sides, i.e., the number of columns
043: *          of the matrices X and B.
044: *
045: *  ALPHA   (input) REAL
046: *          The scalar alpha.  ALPHA must be 0., 1., or -1.; otherwise,
047: *          it is assumed to be 0.
048: *
049: *  DL      (input) COMPLEX array, dimension (N-1)
050: *          The (n-1) sub-diagonal elements of T.
051: *
052: *  D       (input) COMPLEX array, dimension (N)
053: *          The diagonal elements of T.
054: *
055: *  DU      (input) COMPLEX array, dimension (N-1)
056: *          The (n-1) super-diagonal elements of T.
057: *
058: *  X       (input) COMPLEX array, dimension (LDX,NRHS)
059: *          The N by NRHS matrix X.
060: *  LDX     (input) INTEGER
061: *          The leading dimension of the array X.  LDX >= max(N,1).
062: *
063: *  BETA    (input) REAL
064: *          The scalar beta.  BETA must be 0., 1., or -1.; otherwise,
065: *          it is assumed to be 1.
066: *
067: *  B       (input/output) COMPLEX array, dimension (LDB,NRHS)
068: *          On entry, the N by NRHS matrix B.
069: *          On exit, B is overwritten by the matrix expression
070: *          B := alpha * A * X + beta * B.
071: *
072: *  LDB     (input) INTEGER
073: *          The leading dimension of the array B.  LDB >= max(N,1).
074: *
075: *  =====================================================================
076: *
077: *     .. Parameters ..
078:       REAL               ONE, ZERO
079:       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
080: *     ..
081: *     .. Local Scalars ..
082:       INTEGER            I, J
083: *     ..
084: *     .. External Functions ..
085:       LOGICAL            LSAME
086:       EXTERNAL           LSAME
087: *     ..
088: *     .. Intrinsic Functions ..
089:       INTRINSIC          CONJG
090: *     ..
091: *     .. Executable Statements ..
092: *
093:       IF( N.EQ.0 )
094:      \$   RETURN
095: *
096: *     Multiply B by BETA if BETA.NE.1.
097: *
098:       IF( BETA.EQ.ZERO ) THEN
099:          DO 20 J = 1, NRHS
100:             DO 10 I = 1, N
101:                B( I, J ) = ZERO
102:    10       CONTINUE
103:    20    CONTINUE
104:       ELSE IF( BETA.EQ.-ONE ) THEN
105:          DO 40 J = 1, NRHS
106:             DO 30 I = 1, N
107:                B( I, J ) = -B( I, J )
108:    30       CONTINUE
109:    40    CONTINUE
110:       END IF
111: *
112:       IF( ALPHA.EQ.ONE ) THEN
113:          IF( LSAME( TRANS, 'N' ) ) THEN
114: *
115: *           Compute B := B + A*X
116: *
117:             DO 60 J = 1, NRHS
118:                IF( N.EQ.1 ) THEN
119:                   B( 1, J ) = B( 1, J ) + D( 1 )*X( 1, J )
120:                ELSE
121:                   B( 1, J ) = B( 1, J ) + D( 1 )*X( 1, J ) +
122:      \$                        DU( 1 )*X( 2, J )
123:                   B( N, J ) = B( N, J ) + DL( N-1 )*X( N-1, J ) +
124:      \$                        D( N )*X( N, J )
125:                   DO 50 I = 2, N - 1
126:                      B( I, J ) = B( I, J ) + DL( I-1 )*X( I-1, J ) +
127:      \$                           D( I )*X( I, J ) + DU( I )*X( I+1, J )
128:    50             CONTINUE
129:                END IF
130:    60       CONTINUE
131:          ELSE IF( LSAME( TRANS, 'T' ) ) THEN
132: *
133: *           Compute B := B + A**T * X
134: *
135:             DO 80 J = 1, NRHS
136:                IF( N.EQ.1 ) THEN
137:                   B( 1, J ) = B( 1, J ) + D( 1 )*X( 1, J )
138:                ELSE
139:                   B( 1, J ) = B( 1, J ) + D( 1 )*X( 1, J ) +
140:      \$                        DL( 1 )*X( 2, J )
141:                   B( N, J ) = B( N, J ) + DU( N-1 )*X( N-1, J ) +
142:      \$                        D( N )*X( N, J )
143:                   DO 70 I = 2, N - 1
144:                      B( I, J ) = B( I, J ) + DU( I-1 )*X( I-1, J ) +
145:      \$                           D( I )*X( I, J ) + DL( I )*X( I+1, J )
146:    70             CONTINUE
147:                END IF
148:    80       CONTINUE
149:          ELSE IF( LSAME( TRANS, 'C' ) ) THEN
150: *
151: *           Compute B := B + A**H * X
152: *
153:             DO 100 J = 1, NRHS
154:                IF( N.EQ.1 ) THEN
155:                   B( 1, J ) = B( 1, J ) + CONJG( D( 1 ) )*X( 1, J )
156:                ELSE
157:                   B( 1, J ) = B( 1, J ) + CONJG( D( 1 ) )*X( 1, J ) +
158:      \$                        CONJG( DL( 1 ) )*X( 2, J )
159:                   B( N, J ) = B( N, J ) + CONJG( DU( N-1 ) )*
160:      \$                        X( N-1, J ) + CONJG( D( N ) )*X( N, J )
161:                   DO 90 I = 2, N - 1
162:                      B( I, J ) = B( I, J ) + CONJG( DU( I-1 ) )*
163:      \$                           X( I-1, J ) + CONJG( D( I ) )*
164:      \$                           X( I, J ) + CONJG( DL( I ) )*
165:      \$                           X( I+1, J )
166:    90             CONTINUE
167:                END IF
168:   100       CONTINUE
169:          END IF
170:       ELSE IF( ALPHA.EQ.-ONE ) THEN
171:          IF( LSAME( TRANS, 'N' ) ) THEN
172: *
173: *           Compute B := B - A*X
174: *
175:             DO 120 J = 1, NRHS
176:                IF( N.EQ.1 ) THEN
177:                   B( 1, J ) = B( 1, J ) - D( 1 )*X( 1, J )
178:                ELSE
179:                   B( 1, J ) = B( 1, J ) - D( 1 )*X( 1, J ) -
180:      \$                        DU( 1 )*X( 2, J )
181:                   B( N, J ) = B( N, J ) - DL( N-1 )*X( N-1, J ) -
182:      \$                        D( N )*X( N, J )
183:                   DO 110 I = 2, N - 1
184:                      B( I, J ) = B( I, J ) - DL( I-1 )*X( I-1, J ) -
185:      \$                           D( I )*X( I, J ) - DU( I )*X( I+1, J )
186:   110             CONTINUE
187:                END IF
188:   120       CONTINUE
189:          ELSE IF( LSAME( TRANS, 'T' ) ) THEN
190: *
191: *           Compute B := B - A'*X
192: *
193:             DO 140 J = 1, NRHS
194:                IF( N.EQ.1 ) THEN
195:                   B( 1, J ) = B( 1, J ) - D( 1 )*X( 1, J )
196:                ELSE
197:                   B( 1, J ) = B( 1, J ) - D( 1 )*X( 1, J ) -
198:      \$                        DL( 1 )*X( 2, J )
199:                   B( N, J ) = B( N, J ) - DU( N-1 )*X( N-1, J ) -
200:      \$                        D( N )*X( N, J )
201:                   DO 130 I = 2, N - 1
202:                      B( I, J ) = B( I, J ) - DU( I-1 )*X( I-1, J ) -
203:      \$                           D( I )*X( I, J ) - DL( I )*X( I+1, J )
204:   130             CONTINUE
205:                END IF
206:   140       CONTINUE
207:          ELSE IF( LSAME( TRANS, 'C' ) ) THEN
208: *
209: *           Compute B := B - A'*X
210: *
211:             DO 160 J = 1, NRHS
212:                IF( N.EQ.1 ) THEN
213:                   B( 1, J ) = B( 1, J ) - CONJG( D( 1 ) )*X( 1, J )
214:                ELSE
215:                   B( 1, J ) = B( 1, J ) - CONJG( D( 1 ) )*X( 1, J ) -
216:      \$                        CONJG( DL( 1 ) )*X( 2, J )
217:                   B( N, J ) = B( N, J ) - CONJG( DU( N-1 ) )*
218:      \$                        X( N-1, J ) - CONJG( D( N ) )*X( N, J )
219:                   DO 150 I = 2, N - 1
220:                      B( I, J ) = B( I, J ) - CONJG( DU( I-1 ) )*
221:      \$                           X( I-1, J ) - CONJG( D( I ) )*
222:      \$                           X( I, J ) - CONJG( DL( I ) )*
223:      \$                           X( I+1, J )
224:   150             CONTINUE
225:                END IF
226:   160       CONTINUE
227:          END IF
228:       END IF
229:       RETURN
230: *
231: *     End of CLAGTM
232: *
233:       END
234: ```