Debian Codegraph @

debian/external_deps/fetk/punc/src/blas/ztbsv.c

raw
1 /* ./src_f77/ztbsv.f -- translated by f2c (version 20030320).
2 You must link the resulting object file with the libraries:
3 -lf2c -lm (in that order)
4 */
5
6 #include <punc/vf2c.h>
7
8 /* Subroutine */ int ztbsv_(char *uplo, char *trans, char *diag, integer *n,
9 integer *k, doublecomplex *a, integer *lda, doublecomplex *x, integer
10 *incx, ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len)
11 {
12 /* System generated locals */
13 integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
14 doublecomplex z__1, z__2, z__3;
15
16 /* Builtin functions */
17 void z_div(doublecomplex *, doublecomplex *, doublecomplex *), d_cnjg(
18 doublecomplex *, doublecomplex *);
19
20 /* Local variables */
21 static integer i__, j, l, ix, jx, kx, info;
22 static doublecomplex temp;
23 extern logical lsame_(char *, char *, ftnlen, ftnlen);
24 static integer kplus1;
25 extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
26 static logical noconj, nounit;
27
28 /* .. Scalar Arguments .. */
29 /* .. Array Arguments .. */
30 /* .. */
31
32 /* Purpose */
33 /* ======= */
34
35 /* ZTBSV solves one of the systems of equations */
36
37 /* A*x = b, or A'*x = b, or conjg( A' )*x = b, */
38
39 /* where b and x are n element vectors and A is an n by n unit, or */
40 /* non-unit, upper or lower triangular band matrix, with ( k + 1 ) */
41 /* diagonals. */
42
43 /* No test for singularity or near-singularity is included in this */
44 /* routine. Such tests must be performed before calling this routine. */
45
46 /* Parameters */
47 /* ========== */
48
49 /* UPLO - CHARACTER*1. */
50 /* On entry, UPLO specifies whether the matrix is an upper or */
51 /* lower triangular matrix as follows: */
52
53 /* UPLO = 'U' or 'u' A is an upper triangular matrix. */
54
55 /* UPLO = 'L' or 'l' A is a lower triangular matrix. */
56
57 /* Unchanged on exit. */
58
59 /* TRANS - CHARACTER*1. */
60 /* On entry, TRANS specifies the equations to be solved as */
61 /* follows: */
62
63 /* TRANS = 'N' or 'n' A*x = b. */
64
65 /* TRANS = 'T' or 't' A'*x = b. */
66
67 /* TRANS = 'C' or 'c' conjg( A' )*x = b. */
68
69 /* Unchanged on exit. */
70
71 /* DIAG - CHARACTER*1. */
72 /* On entry, DIAG specifies whether or not A is unit */
73 /* triangular as follows: */
74
75 /* DIAG = 'U' or 'u' A is assumed to be unit triangular. */
76
77 /* DIAG = 'N' or 'n' A is not assumed to be unit */
78 /* triangular. */
79
80 /* Unchanged on exit. */
81
82 /* N - INTEGER. */
83 /* On entry, N specifies the order of the matrix A. */
84 /* N must be at least zero. */
85 /* Unchanged on exit. */
86
87 /* K - INTEGER. */
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. */
93 /* Unchanged on exit. */
94
95 /* A - COMPLEX*16 array of DIMENSION ( LDA, n ). */
96 /* Before entry with UPLO = 'U' or 'u', the leading ( k + 1 ) */
97 /* by n part of the array A must contain the upper triangular */
98 /* band part of the matrix of coefficients, supplied column by */
99 /* column, with the leading diagonal of the matrix in row */
100 /* ( k + 1 ) of the array, the first super-diagonal starting at */
101 /* position 2 in row k, and so on. The top left k by k triangle */
102 /* of the array A is not referenced. */
103 /* The following program segment will transfer an upper */
104 /* triangular band matrix from conventional full matrix storage */
105 /* to band storage: */
106
107 /* DO 20, J = 1, N */
108 /* M = K + 1 - J */
109 /* DO 10, I = MAX( 1, J - K ), J */
110 /* A( M + I, J ) = matrix( I, J ) */
111 /* 10 CONTINUE */
112 /* 20 CONTINUE */
113
114 /* Before entry with UPLO = 'L' or 'l', the leading ( k + 1 ) */
115 /* by n part of the array A must contain the lower triangular */
116 /* band part of the matrix of coefficients, supplied column by */
117 /* column, with the leading diagonal of the matrix in row 1 of */
118 /* the array, the first sub-diagonal starting at position 1 in */
119 /* row 2, and so on. The bottom right k by k triangle of the */
120 /* array A is not referenced. */
121 /* The following program segment will transfer a lower */
122 /* triangular band matrix from conventional full matrix storage */
123 /* to band storage: */
124
125 /* DO 20, J = 1, N */
126 /* M = 1 - J */
127 /* DO 10, I = J, MIN( N, J + K ) */
128 /* A( M + I, J ) = matrix( I, J ) */
129 /* 10 CONTINUE */
130 /* 20 CONTINUE */
131
132 /* Note that when DIAG = 'U' or 'u' the elements of the array A */
133 /* corresponding to the diagonal elements of the matrix are not */
134 /* referenced, but are assumed to be unity. */
135 /* Unchanged on exit. */
136
137 /* LDA - INTEGER. */
138 /* On entry, LDA specifies the first dimension of A as declared */
139 /* in the calling (sub) program. LDA must be at least */
140 /* ( k + 1 ). */
141 /* Unchanged on exit. */
142
143 /* X - COMPLEX*16 array of dimension at least */
144 /* ( 1 + ( n - 1 )*abs( INCX ) ). */
145 /* Before entry, the incremented array X must contain the n */
146 /* element right-hand side vector b. On exit, X is overwritten */
147 /* with the solution vector x. */
148
149 /* INCX - INTEGER. */
150 /* On entry, INCX specifies the increment for the elements of */
151 /* X. INCX must not be zero. */
152 /* Unchanged on exit. */
153
154
155 /* Level 2 Blas routine. */
156
157 /* -- Written on 22-October-1986. */
158 /* Jack Dongarra, Argonne National Lab. */
159 /* Jeremy Du Croz, Nag Central Office. */
160 /* Sven Hammarling, Nag Central Office. */
161 /* Richard Hanson, Sandia National Labs. */
162
163
164 /* .. Parameters .. */
165 /* .. Local Scalars .. */
166 /* .. External Functions .. */
167 /* .. External Subroutines .. */
168 /* .. Intrinsic Functions .. */
169 /* .. */
170 /* .. Executable Statements .. */
171
172 /* Test the input parameters. */
173
174 /* Parameter adjustments */
175 a_dim1 = *lda;
176 a_offset = 1 + a_dim1;
177 a -= a_offset;
178 --x;
179
180 /* Function Body */
181 info = 0;
182 if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (
183 ftnlen)1, (ftnlen)1)) {
184 info = 1;
185 } else if (! lsame_(trans, "N", (ftnlen)1, (ftnlen)1) && ! lsame_(trans,
186 "T", (ftnlen)1, (ftnlen)1) && ! lsame_(trans, "C", (ftnlen)1, (
187 ftnlen)1)) {
188 info = 2;
189 } else if (! lsame_(diag, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(diag,
190 "N", (ftnlen)1, (ftnlen)1)) {
191 info = 3;
192 } else if (*n < 0) {
193 info = 4;
194 } else if (*k < 0) {
195 info = 5;
196 } else if (*lda < *k + 1) {
197 info = 7;
198 } else if (*incx == 0) {
199 info = 9;
200 }
201 if (info != 0) {
202 xerbla_("ZTBSV ", &info, (ftnlen)6);
203 return 0;
204 }
205
206 /* Quick return if possible. */
207
208 if (*n == 0) {
209 return 0;
210 }
211
212 noconj = lsame_(trans, "T", (ftnlen)1, (ftnlen)1);
213 nounit = lsame_(diag, "N", (ftnlen)1, (ftnlen)1);
214
215 /* Set up the start point in X if the increment is not unity. This */
216 /* will be ( N - 1 )*INCX too small for descending loops. */
217
218 if (*incx <= 0) {
219 kx = 1 - (*n - 1) * *incx;
220 } else if (*incx != 1) {
221 kx = 1;
222 }
223
224 /* Start the operations. In this version the elements of A are */
225 /* accessed by sequentially with one pass through A. */
226
227 if (lsame_(trans, "N", (ftnlen)1, (ftnlen)1)) {
228
229 /* Form x := inv( A )*x. */
230
231 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
232 kplus1 = *k + 1;
233 if (*incx == 1) {
234 for (j = *n; j >= 1; --j) {
235 i__1 = j;
236 if (x[i__1].r != 0. || x[i__1].i != 0.) {
237 l = kplus1 - j;
238 if (nounit) {
239 i__1 = j;
240 z_div(&z__1, &x[j], &a[kplus1 + j * a_dim1]);
241 x[i__1].r = z__1.r, x[i__1].i = z__1.i;
242 }
243 i__1 = j;
244 temp.r = x[i__1].r, temp.i = x[i__1].i;
245 /* Computing MAX */
246 i__2 = 1, i__3 = j - *k;
247 i__1 = max(i__2,i__3);
248 for (i__ = j - 1; i__ >= i__1; --i__) {
249 i__2 = i__;
250 i__3 = i__;
251 i__4 = l + i__ + j * a_dim1;
252 z__2.r = temp.r * a[i__4].r - temp.i * a[i__4].i,
253 z__2.i = temp.r * a[i__4].i + temp.i * a[
254 i__4].r;
255 z__1.r = x[i__3].r - z__2.r, z__1.i = x[i__3].i -
256 z__2.i;
257 x[i__2].r = z__1.r, x[i__2].i = z__1.i;
258 /* L10: */
259 }
260 }
261 /* L20: */
262 }
263 } else {
264 kx += (*n - 1) * *incx;
265 jx = kx;
266 for (j = *n; j >= 1; --j) {
267 kx -= *incx;
268 i__1 = jx;
269 if (x[i__1].r != 0. || x[i__1].i != 0.) {
270 ix = kx;
271 l = kplus1 - j;
272 if (nounit) {
273 i__1 = jx;
274 z_div(&z__1, &x[jx], &a[kplus1 + j * a_dim1]);
275 x[i__1].r = z__1.r, x[i__1].i = z__1.i;
276 }
277 i__1 = jx;
278 temp.r = x[i__1].r, temp.i = x[i__1].i;
279 /* Computing MAX */
280 i__2 = 1, i__3 = j - *k;
281 i__1 = max(i__2,i__3);
282 for (i__ = j - 1; i__ >= i__1; --i__) {
283 i__2 = ix;
284 i__3 = ix;
285 i__4 = l + i__ + j * a_dim1;
286 z__2.r = temp.r * a[i__4].r - temp.i * a[i__4].i,
287 z__2.i = temp.r * a[i__4].i + temp.i * a[
288 i__4].r;
289 z__1.r = x[i__3].r - z__2.r, z__1.i = x[i__3].i -
290 z__2.i;
291 x[i__2].r = z__1.r, x[i__2].i = z__1.i;
292 ix -= *incx;
293 /* L30: */
294 }
295 }
296 jx -= *incx;
297 /* L40: */
298 }
299 }
300 } else {
301 if (*incx == 1) {
302 i__1 = *n;
303 for (j = 1; j <= i__1; ++j) {
304 i__2 = j;
305 if (x[i__2].r != 0. || x[i__2].i != 0.) {
306 l = 1 - j;
307 if (nounit) {
308 i__2 = j;
309 z_div(&z__1, &x[j], &a[j * a_dim1 + 1]);
310 x[i__2].r = z__1.r, x[i__2].i = z__1.i;
311 }
312 i__2 = j;
313 temp.r = x[i__2].r, temp.i = x[i__2].i;
314 /* Computing MIN */
315 i__3 = *n, i__4 = j + *k;
316 i__2 = min(i__3,i__4);
317 for (i__ = j + 1; i__ <= i__2; ++i__) {
318 i__3 = i__;
319 i__4 = i__;
320 i__5 = l + i__ + j * a_dim1;
321 z__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
322 z__2.i = temp.r * a[i__5].i + temp.i * a[
323 i__5].r;
324 z__1.r = x[i__4].r - z__2.r, z__1.i = x[i__4].i -
325 z__2.i;
326 x[i__3].r = z__1.r, x[i__3].i = z__1.i;
327 /* L50: */
328 }
329 }
330 /* L60: */
331 }
332 } else {
333 jx = kx;
334 i__1 = *n;
335 for (j = 1; j <= i__1; ++j) {
336 kx += *incx;
337 i__2 = jx;
338 if (x[i__2].r != 0. || x[i__2].i != 0.) {
339 ix = kx;
340 l = 1 - j;
341 if (nounit) {
342 i__2 = jx;
343 z_div(&z__1, &x[jx], &a[j * a_dim1 + 1]);
344 x[i__2].r = z__1.r, x[i__2].i = z__1.i;
345 }
346 i__2 = jx;
347 temp.r = x[i__2].r, temp.i = x[i__2].i;
348 /* Computing MIN */
349 i__3 = *n, i__4 = j + *k;
350 i__2 = min(i__3,i__4);
351 for (i__ = j + 1; i__ <= i__2; ++i__) {
352 i__3 = ix;
353 i__4 = ix;
354 i__5 = l + i__ + j * a_dim1;
355 z__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
356 z__2.i = temp.r * a[i__5].i + temp.i * a[
357 i__5].r;
358 z__1.r = x[i__4].r - z__2.r, z__1.i = x[i__4].i -
359 z__2.i;
360 x[i__3].r = z__1.r, x[i__3].i = z__1.i;
361 ix += *incx;
362 /* L70: */
363 }
364 }
365 jx += *incx;
366 /* L80: */
367 }
368 }
369 }
370 } else {
371
372 /* Form x := inv( A' )*x or x := inv( conjg( A') )*x. */
373
374 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
375 kplus1 = *k + 1;
376 if (*incx == 1) {
377 i__1 = *n;
378 for (j = 1; j <= i__1; ++j) {
379 i__2 = j;
380 temp.r = x[i__2].r, temp.i = x[i__2].i;
381 l = kplus1 - j;
382 if (noconj) {
383 /* Computing MAX */
384 i__2 = 1, i__3 = j - *k;
385 i__4 = j - 1;
386 for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
387 i__2 = l + i__ + j * a_dim1;
388 i__3 = i__;
389 z__2.r = a[i__2].r * x[i__3].r - a[i__2].i * x[
390 i__3].i, z__2.i = a[i__2].r * x[i__3].i +
391 a[i__2].i * x[i__3].r;
392 z__1.r = temp.r - z__2.r, z__1.i = temp.i -
393 z__2.i;
394 temp.r = z__1.r, temp.i = z__1.i;
395 /* L90: */
396 }
397 if (nounit) {
398 z_div(&z__1, &temp, &a[kplus1 + j * a_dim1]);
399 temp.r = z__1.r, temp.i = z__1.i;
400 }
401 } else {
402 /* Computing MAX */
403 i__4 = 1, i__2 = j - *k;
404 i__3 = j - 1;
405 for (i__ = max(i__4,i__2); i__ <= i__3; ++i__) {
406 d_cnjg(&z__3, &a[l + i__ + j * a_dim1]);
407 i__4 = i__;
408 z__2.r = z__3.r * x[i__4].r - z__3.i * x[i__4].i,
409 z__2.i = z__3.r * x[i__4].i + z__3.i * x[
410 i__4].r;
411 z__1.r = temp.r - z__2.r, z__1.i = temp.i -
412 z__2.i;
413 temp.r = z__1.r, temp.i = z__1.i;
414 /* L100: */
415 }
416 if (nounit) {
417 d_cnjg(&z__2, &a[kplus1 + j * a_dim1]);
418 z_div(&z__1, &temp, &z__2);
419 temp.r = z__1.r, temp.i = z__1.i;
420 }
421 }
422 i__3 = j;
423 x[i__3].r = temp.r, x[i__3].i = temp.i;
424 /* L110: */
425 }
426 } else {
427 jx = kx;
428 i__1 = *n;
429 for (j = 1; j <= i__1; ++j) {
430 i__3 = jx;
431 temp.r = x[i__3].r, temp.i = x[i__3].i;
432 ix = kx;
433 l = kplus1 - j;
434 if (noconj) {
435 /* Computing MAX */
436 i__3 = 1, i__4 = j - *k;
437 i__2 = j - 1;
438 for (i__ = max(i__3,i__4); i__ <= i__2; ++i__) {
439 i__3 = l + i__ + j * a_dim1;
440 i__4 = ix;
441 z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[
442 i__4].i, z__2.i = a[i__3].r * x[i__4].i +
443 a[i__3].i * x[i__4].r;
444 z__1.r = temp.r - z__2.r, z__1.i = temp.i -
445 z__2.i;
446 temp.r = z__1.r, temp.i = z__1.i;
447 ix += *incx;
448 /* L120: */
449 }
450 if (nounit) {
451 z_div(&z__1, &temp, &a[kplus1 + j * a_dim1]);
452 temp.r = z__1.r, temp.i = z__1.i;
453 }
454 } else {
455 /* Computing MAX */
456 i__2 = 1, i__3 = j - *k;
457 i__4 = j - 1;
458 for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
459 d_cnjg(&z__3, &a[l + i__ + j * a_dim1]);
460 i__2 = ix;
461 z__2.r = z__3.r * x[i__2].r - z__3.i * x[i__2].i,
462 z__2.i = z__3.r * x[i__2].i + z__3.i * x[
463 i__2].r;
464 z__1.r = temp.r - z__2.r, z__1.i = temp.i -
465 z__2.i;
466 temp.r = z__1.r, temp.i = z__1.i;
467 ix += *incx;
468 /* L130: */
469 }
470 if (nounit) {
471 d_cnjg(&z__2, &a[kplus1 + j * a_dim1]);
472 z_div(&z__1, &temp, &z__2);
473 temp.r = z__1.r, temp.i = z__1.i;
474 }
475 }
476 i__4 = jx;
477 x[i__4].r = temp.r, x[i__4].i = temp.i;
478 jx += *incx;
479 if (j > *k) {
480 kx += *incx;
481 }
482 /* L140: */
483 }
484 }
485 } else {
486 if (*incx == 1) {
487 for (j = *n; j >= 1; --j) {
488 i__1 = j;
489 temp.r = x[i__1].r, temp.i = x[i__1].i;
490 l = 1 - j;
491 if (noconj) {
492 /* Computing MIN */
493 i__1 = *n, i__4 = j + *k;
494 i__2 = j + 1;
495 for (i__ = min(i__1,i__4); i__ >= i__2; --i__) {
496 i__1 = l + i__ + j * a_dim1;
497 i__4 = i__;
498 z__2.r = a[i__1].r * x[i__4].r - a[i__1].i * x[
499 i__4].i, z__2.i = a[i__1].r * x[i__4].i +
500 a[i__1].i * x[i__4].r;
501 z__1.r = temp.r - z__2.r, z__1.i = temp.i -
502 z__2.i;
503 temp.r = z__1.r, temp.i = z__1.i;
504 /* L150: */
505 }
506 if (nounit) {
507 z_div(&z__1, &temp, &a[j * a_dim1 + 1]);
508 temp.r = z__1.r, temp.i = z__1.i;
509 }
510 } else {
511 /* Computing MIN */
512 i__2 = *n, i__1 = j + *k;
513 i__4 = j + 1;
514 for (i__ = min(i__2,i__1); i__ >= i__4; --i__) {
515 d_cnjg(&z__3, &a[l + i__ + j * a_dim1]);
516 i__2 = i__;
517 z__2.r = z__3.r * x[i__2].r - z__3.i * x[i__2].i,
518 z__2.i = z__3.r * x[i__2].i + z__3.i * x[
519 i__2].r;
520 z__1.r = temp.r - z__2.r, z__1.i = temp.i -
521 z__2.i;
522 temp.r = z__1.r, temp.i = z__1.i;
523 /* L160: */
524 }
525 if (nounit) {
526 d_cnjg(&z__2, &a[j * a_dim1 + 1]);
527 z_div(&z__1, &temp, &z__2);
528 temp.r = z__1.r, temp.i = z__1.i;
529 }
530 }
531 i__4 = j;
532 x[i__4].r = temp.r, x[i__4].i = temp.i;
533 /* L170: */
534 }
535 } else {
536 kx += (*n - 1) * *incx;
537 jx = kx;
538 for (j = *n; j >= 1; --j) {
539 i__4 = jx;
540 temp.r = x[i__4].r, temp.i = x[i__4].i;
541 ix = kx;
542 l = 1 - j;
543 if (noconj) {
544 /* Computing MIN */
545 i__4 = *n, i__2 = j + *k;
546 i__1 = j + 1;
547 for (i__ = min(i__4,i__2); i__ >= i__1; --i__) {
548 i__4 = l + i__ + j * a_dim1;
549 i__2 = ix;
550 z__2.r = a[i__4].r * x[i__2].r - a[i__4].i * x[
551 i__2].i, z__2.i = a[i__4].r * x[i__2].i +
552 a[i__4].i * x[i__2].r;
553 z__1.r = temp.r - z__2.r, z__1.i = temp.i -
554 z__2.i;
555 temp.r = z__1.r, temp.i = z__1.i;
556 ix -= *incx;
557 /* L180: */
558 }
559 if (nounit) {
560 z_div(&z__1, &temp, &a[j * a_dim1 + 1]);
561 temp.r = z__1.r, temp.i = z__1.i;
562 }
563 } else {
564 /* Computing MIN */
565 i__1 = *n, i__4 = j + *k;
566 i__2 = j + 1;
567 for (i__ = min(i__1,i__4); i__ >= i__2; --i__) {
568 d_cnjg(&z__3, &a[l + i__ + j * a_dim1]);
569 i__1 = ix;
570 z__2.r = z__3.r * x[i__1].r - z__3.i * x[i__1].i,
571 z__2.i = z__3.r * x[i__1].i + z__3.i * x[
572 i__1].r;
573 z__1.r = temp.r - z__2.r, z__1.i = temp.i -
574 z__2.i;
575 temp.r = z__1.r, temp.i = z__1.i;
576 ix -= *incx;
577 /* L190: */
578 }
579 if (nounit) {
580 d_cnjg(&z__2, &a[j * a_dim1 + 1]);
581 z_div(&z__1, &temp, &z__2);
582 temp.r = z__1.r, temp.i = z__1.i;
583 }
584 }
585 i__2 = jx;
586 x[i__2].r = temp.r, x[i__2].i = temp.i;
587 jx -= *incx;
588 if (*n - j >= *k) {
589 kx -= *incx;
590 }
591 /* L200: */
592 }
593 }
594 }
595 }
596
597 return 0;
598
599 /* End of ZTBSV . */
600
601 } /* ztbsv_ */
602