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