00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016
00017
00018 static integer c__1 = 1;
00019 static doublereal c_b36 = .5;
00020
00021 int zlatbs_(char *uplo, char *trans, char *diag, char *
00022 normin, integer *n, integer *kd, doublecomplex *ab, integer *ldab,
00023 doublecomplex *x, doublereal *scale, doublereal *cnorm, integer *info)
00024 {
00025
00026 integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4, i__5;
00027 doublereal d__1, d__2, d__3, d__4;
00028 doublecomplex z__1, z__2, z__3, z__4;
00029
00030
00031 double d_imag(doublecomplex *);
00032 void d_cnjg(doublecomplex *, doublecomplex *);
00033
00034
00035 integer i__, j;
00036 doublereal xj, rec, tjj;
00037 integer jinc, jlen;
00038 doublereal xbnd;
00039 integer imax;
00040 doublereal tmax;
00041 doublecomplex tjjs;
00042 doublereal xmax, grow;
00043 extern int dscal_(integer *, doublereal *, doublereal *,
00044 integer *);
00045 integer maind;
00046 extern logical lsame_(char *, char *);
00047 doublereal tscal;
00048 doublecomplex uscal;
00049 integer jlast;
00050 doublecomplex csumj;
00051 extern VOID zdotc_(doublecomplex *, integer *,
00052 doublecomplex *, integer *, doublecomplex *, integer *);
00053 logical upper;
00054 extern VOID zdotu_(doublecomplex *, integer *,
00055 doublecomplex *, integer *, doublecomplex *, integer *);
00056 extern int ztbsv_(char *, char *, char *, integer *,
00057 integer *, doublecomplex *, integer *, doublecomplex *, integer *), zaxpy_(integer *, doublecomplex *,
00058 doublecomplex *, integer *, doublecomplex *, integer *), dlabad_(
00059 doublereal *, doublereal *);
00060 extern doublereal dlamch_(char *);
00061 extern integer idamax_(integer *, doublereal *, integer *);
00062 extern int xerbla_(char *, integer *), zdscal_(
00063 integer *, doublereal *, doublecomplex *, integer *);
00064 doublereal bignum;
00065 extern integer izamax_(integer *, doublecomplex *, integer *);
00066 extern VOID zladiv_(doublecomplex *, doublecomplex *,
00067 doublecomplex *);
00068 logical notran;
00069 integer jfirst;
00070 extern doublereal dzasum_(integer *, doublecomplex *, integer *);
00071 doublereal smlnum;
00072 logical nounit;
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256 ab_dim1 = *ldab;
00257 ab_offset = 1 + ab_dim1;
00258 ab -= ab_offset;
00259 --x;
00260 --cnorm;
00261
00262
00263 *info = 0;
00264 upper = lsame_(uplo, "U");
00265 notran = lsame_(trans, "N");
00266 nounit = lsame_(diag, "N");
00267
00268
00269
00270 if (! upper && ! lsame_(uplo, "L")) {
00271 *info = -1;
00272 } else if (! notran && ! lsame_(trans, "T") && !
00273 lsame_(trans, "C")) {
00274 *info = -2;
00275 } else if (! nounit && ! lsame_(diag, "U")) {
00276 *info = -3;
00277 } else if (! lsame_(normin, "Y") && ! lsame_(normin,
00278 "N")) {
00279 *info = -4;
00280 } else if (*n < 0) {
00281 *info = -5;
00282 } else if (*kd < 0) {
00283 *info = -6;
00284 } else if (*ldab < *kd + 1) {
00285 *info = -8;
00286 }
00287 if (*info != 0) {
00288 i__1 = -(*info);
00289 xerbla_("ZLATBS", &i__1);
00290 return 0;
00291 }
00292
00293
00294
00295 if (*n == 0) {
00296 return 0;
00297 }
00298
00299
00300
00301 smlnum = dlamch_("Safe minimum");
00302 bignum = 1. / smlnum;
00303 dlabad_(&smlnum, &bignum);
00304 smlnum /= dlamch_("Precision");
00305 bignum = 1. / smlnum;
00306 *scale = 1.;
00307
00308 if (lsame_(normin, "N")) {
00309
00310
00311
00312 if (upper) {
00313
00314
00315
00316 i__1 = *n;
00317 for (j = 1; j <= i__1; ++j) {
00318
00319 i__2 = *kd, i__3 = j - 1;
00320 jlen = min(i__2,i__3);
00321 cnorm[j] = dzasum_(&jlen, &ab[*kd + 1 - jlen + j * ab_dim1], &
00322 c__1);
00323
00324 }
00325 } else {
00326
00327
00328
00329 i__1 = *n;
00330 for (j = 1; j <= i__1; ++j) {
00331
00332 i__2 = *kd, i__3 = *n - j;
00333 jlen = min(i__2,i__3);
00334 if (jlen > 0) {
00335 cnorm[j] = dzasum_(&jlen, &ab[j * ab_dim1 + 2], &c__1);
00336 } else {
00337 cnorm[j] = 0.;
00338 }
00339
00340 }
00341 }
00342 }
00343
00344
00345
00346
00347 imax = idamax_(n, &cnorm[1], &c__1);
00348 tmax = cnorm[imax];
00349 if (tmax <= bignum * .5) {
00350 tscal = 1.;
00351 } else {
00352 tscal = .5 / (smlnum * tmax);
00353 dscal_(n, &tscal, &cnorm[1], &c__1);
00354 }
00355
00356
00357
00358
00359 xmax = 0.;
00360 i__1 = *n;
00361 for (j = 1; j <= i__1; ++j) {
00362
00363 i__2 = j;
00364 d__3 = xmax, d__4 = (d__1 = x[i__2].r / 2., abs(d__1)) + (d__2 =
00365 d_imag(&x[j]) / 2., abs(d__2));
00366 xmax = max(d__3,d__4);
00367
00368 }
00369 xbnd = xmax;
00370 if (notran) {
00371
00372
00373
00374 if (upper) {
00375 jfirst = *n;
00376 jlast = 1;
00377 jinc = -1;
00378 maind = *kd + 1;
00379 } else {
00380 jfirst = 1;
00381 jlast = *n;
00382 jinc = 1;
00383 maind = 1;
00384 }
00385
00386 if (tscal != 1.) {
00387 grow = 0.;
00388 goto L60;
00389 }
00390
00391 if (nounit) {
00392
00393
00394
00395
00396
00397
00398 grow = .5 / max(xbnd,smlnum);
00399 xbnd = grow;
00400 i__1 = jlast;
00401 i__2 = jinc;
00402 for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
00403
00404
00405
00406 if (grow <= smlnum) {
00407 goto L60;
00408 }
00409
00410 i__3 = maind + j * ab_dim1;
00411 tjjs.r = ab[i__3].r, tjjs.i = ab[i__3].i;
00412 tjj = (d__1 = tjjs.r, abs(d__1)) + (d__2 = d_imag(&tjjs), abs(
00413 d__2));
00414
00415 if (tjj >= smlnum) {
00416
00417
00418
00419
00420 d__1 = xbnd, d__2 = min(1.,tjj) * grow;
00421 xbnd = min(d__1,d__2);
00422 } else {
00423
00424
00425
00426 xbnd = 0.;
00427 }
00428
00429 if (tjj + cnorm[j] >= smlnum) {
00430
00431
00432
00433 grow *= tjj / (tjj + cnorm[j]);
00434 } else {
00435
00436
00437
00438 grow = 0.;
00439 }
00440
00441 }
00442 grow = xbnd;
00443 } else {
00444
00445
00446
00447
00448
00449
00450 d__1 = 1., d__2 = .5 / max(xbnd,smlnum);
00451 grow = min(d__1,d__2);
00452 i__2 = jlast;
00453 i__1 = jinc;
00454 for (j = jfirst; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
00455
00456
00457
00458 if (grow <= smlnum) {
00459 goto L60;
00460 }
00461
00462
00463
00464 grow *= 1. / (cnorm[j] + 1.);
00465
00466 }
00467 }
00468 L60:
00469
00470 ;
00471 } else {
00472
00473
00474
00475 if (upper) {
00476 jfirst = 1;
00477 jlast = *n;
00478 jinc = 1;
00479 maind = *kd + 1;
00480 } else {
00481 jfirst = *n;
00482 jlast = 1;
00483 jinc = -1;
00484 maind = 1;
00485 }
00486
00487 if (tscal != 1.) {
00488 grow = 0.;
00489 goto L90;
00490 }
00491
00492 if (nounit) {
00493
00494
00495
00496
00497
00498
00499 grow = .5 / max(xbnd,smlnum);
00500 xbnd = grow;
00501 i__1 = jlast;
00502 i__2 = jinc;
00503 for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
00504
00505
00506
00507 if (grow <= smlnum) {
00508 goto L90;
00509 }
00510
00511
00512
00513 xj = cnorm[j] + 1.;
00514
00515 d__1 = grow, d__2 = xbnd / xj;
00516 grow = min(d__1,d__2);
00517
00518 i__3 = maind + j * ab_dim1;
00519 tjjs.r = ab[i__3].r, tjjs.i = ab[i__3].i;
00520 tjj = (d__1 = tjjs.r, abs(d__1)) + (d__2 = d_imag(&tjjs), abs(
00521 d__2));
00522
00523 if (tjj >= smlnum) {
00524
00525
00526
00527 if (xj > tjj) {
00528 xbnd *= tjj / xj;
00529 }
00530 } else {
00531
00532
00533
00534 xbnd = 0.;
00535 }
00536
00537 }
00538 grow = min(grow,xbnd);
00539 } else {
00540
00541
00542
00543
00544
00545
00546 d__1 = 1., d__2 = .5 / max(xbnd,smlnum);
00547 grow = min(d__1,d__2);
00548 i__2 = jlast;
00549 i__1 = jinc;
00550 for (j = jfirst; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
00551
00552
00553
00554 if (grow <= smlnum) {
00555 goto L90;
00556 }
00557
00558
00559
00560 xj = cnorm[j] + 1.;
00561 grow /= xj;
00562
00563 }
00564 }
00565 L90:
00566 ;
00567 }
00568
00569 if (grow * tscal > smlnum) {
00570
00571
00572
00573
00574 ztbsv_(uplo, trans, diag, n, kd, &ab[ab_offset], ldab, &x[1], &c__1);
00575 } else {
00576
00577
00578
00579 if (xmax > bignum * .5) {
00580
00581
00582
00583
00584 *scale = bignum * .5 / xmax;
00585 zdscal_(n, scale, &x[1], &c__1);
00586 xmax = bignum;
00587 } else {
00588 xmax *= 2.;
00589 }
00590
00591 if (notran) {
00592
00593
00594
00595 i__1 = jlast;
00596 i__2 = jinc;
00597 for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
00598
00599
00600
00601 i__3 = j;
00602 xj = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = d_imag(&x[j]),
00603 abs(d__2));
00604 if (nounit) {
00605 i__3 = maind + j * ab_dim1;
00606 z__1.r = tscal * ab[i__3].r, z__1.i = tscal * ab[i__3].i;
00607 tjjs.r = z__1.r, tjjs.i = z__1.i;
00608 } else {
00609 tjjs.r = tscal, tjjs.i = 0.;
00610 if (tscal == 1.) {
00611 goto L110;
00612 }
00613 }
00614 tjj = (d__1 = tjjs.r, abs(d__1)) + (d__2 = d_imag(&tjjs), abs(
00615 d__2));
00616 if (tjj > smlnum) {
00617
00618
00619
00620 if (tjj < 1.) {
00621 if (xj > tjj * bignum) {
00622
00623
00624
00625 rec = 1. / xj;
00626 zdscal_(n, &rec, &x[1], &c__1);
00627 *scale *= rec;
00628 xmax *= rec;
00629 }
00630 }
00631 i__3 = j;
00632 zladiv_(&z__1, &x[j], &tjjs);
00633 x[i__3].r = z__1.r, x[i__3].i = z__1.i;
00634 i__3 = j;
00635 xj = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = d_imag(&x[j])
00636 , abs(d__2));
00637 } else if (tjj > 0.) {
00638
00639
00640
00641 if (xj > tjj * bignum) {
00642
00643
00644
00645
00646 rec = tjj * bignum / xj;
00647 if (cnorm[j] > 1.) {
00648
00649
00650
00651
00652 rec /= cnorm[j];
00653 }
00654 zdscal_(n, &rec, &x[1], &c__1);
00655 *scale *= rec;
00656 xmax *= rec;
00657 }
00658 i__3 = j;
00659 zladiv_(&z__1, &x[j], &tjjs);
00660 x[i__3].r = z__1.r, x[i__3].i = z__1.i;
00661 i__3 = j;
00662 xj = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = d_imag(&x[j])
00663 , abs(d__2));
00664 } else {
00665
00666
00667
00668
00669 i__3 = *n;
00670 for (i__ = 1; i__ <= i__3; ++i__) {
00671 i__4 = i__;
00672 x[i__4].r = 0., x[i__4].i = 0.;
00673
00674 }
00675 i__3 = j;
00676 x[i__3].r = 1., x[i__3].i = 0.;
00677 xj = 1.;
00678 *scale = 0.;
00679 xmax = 0.;
00680 }
00681 L110:
00682
00683
00684
00685
00686 if (xj > 1.) {
00687 rec = 1. / xj;
00688 if (cnorm[j] > (bignum - xmax) * rec) {
00689
00690
00691
00692 rec *= .5;
00693 zdscal_(n, &rec, &x[1], &c__1);
00694 *scale *= rec;
00695 }
00696 } else if (xj * cnorm[j] > bignum - xmax) {
00697
00698
00699
00700 zdscal_(n, &c_b36, &x[1], &c__1);
00701 *scale *= .5;
00702 }
00703
00704 if (upper) {
00705 if (j > 1) {
00706
00707
00708
00709
00710
00711
00712 i__3 = *kd, i__4 = j - 1;
00713 jlen = min(i__3,i__4);
00714 i__3 = j;
00715 z__2.r = -x[i__3].r, z__2.i = -x[i__3].i;
00716 z__1.r = tscal * z__2.r, z__1.i = tscal * z__2.i;
00717 zaxpy_(&jlen, &z__1, &ab[*kd + 1 - jlen + j * ab_dim1]
00718 , &c__1, &x[j - jlen], &c__1);
00719 i__3 = j - 1;
00720 i__ = izamax_(&i__3, &x[1], &c__1);
00721 i__3 = i__;
00722 xmax = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = d_imag(
00723 &x[i__]), abs(d__2));
00724 }
00725 } else if (j < *n) {
00726
00727
00728
00729
00730
00731
00732 i__3 = *kd, i__4 = *n - j;
00733 jlen = min(i__3,i__4);
00734 if (jlen > 0) {
00735 i__3 = j;
00736 z__2.r = -x[i__3].r, z__2.i = -x[i__3].i;
00737 z__1.r = tscal * z__2.r, z__1.i = tscal * z__2.i;
00738 zaxpy_(&jlen, &z__1, &ab[j * ab_dim1 + 2], &c__1, &x[
00739 j + 1], &c__1);
00740 }
00741 i__3 = *n - j;
00742 i__ = j + izamax_(&i__3, &x[j + 1], &c__1);
00743 i__3 = i__;
00744 xmax = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = d_imag(&x[
00745 i__]), abs(d__2));
00746 }
00747
00748 }
00749
00750 } else if (lsame_(trans, "T")) {
00751
00752
00753
00754 i__2 = jlast;
00755 i__1 = jinc;
00756 for (j = jfirst; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
00757
00758
00759
00760
00761 i__3 = j;
00762 xj = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = d_imag(&x[j]),
00763 abs(d__2));
00764 uscal.r = tscal, uscal.i = 0.;
00765 rec = 1. / max(xmax,1.);
00766 if (cnorm[j] > (bignum - xj) * rec) {
00767
00768
00769
00770 rec *= .5;
00771 if (nounit) {
00772 i__3 = maind + j * ab_dim1;
00773 z__1.r = tscal * ab[i__3].r, z__1.i = tscal * ab[i__3]
00774 .i;
00775 tjjs.r = z__1.r, tjjs.i = z__1.i;
00776 } else {
00777 tjjs.r = tscal, tjjs.i = 0.;
00778 }
00779 tjj = (d__1 = tjjs.r, abs(d__1)) + (d__2 = d_imag(&tjjs),
00780 abs(d__2));
00781 if (tjj > 1.) {
00782
00783
00784
00785
00786 d__1 = 1., d__2 = rec * tjj;
00787 rec = min(d__1,d__2);
00788 zladiv_(&z__1, &uscal, &tjjs);
00789 uscal.r = z__1.r, uscal.i = z__1.i;
00790 }
00791 if (rec < 1.) {
00792 zdscal_(n, &rec, &x[1], &c__1);
00793 *scale *= rec;
00794 xmax *= rec;
00795 }
00796 }
00797
00798 csumj.r = 0., csumj.i = 0.;
00799 if (uscal.r == 1. && uscal.i == 0.) {
00800
00801
00802
00803
00804 if (upper) {
00805
00806 i__3 = *kd, i__4 = j - 1;
00807 jlen = min(i__3,i__4);
00808 zdotu_(&z__1, &jlen, &ab[*kd + 1 - jlen + j * ab_dim1]
00809 , &c__1, &x[j - jlen], &c__1);
00810 csumj.r = z__1.r, csumj.i = z__1.i;
00811 } else {
00812
00813 i__3 = *kd, i__4 = *n - j;
00814 jlen = min(i__3,i__4);
00815 if (jlen > 1) {
00816 zdotu_(&z__1, &jlen, &ab[j * ab_dim1 + 2], &c__1,
00817 &x[j + 1], &c__1);
00818 csumj.r = z__1.r, csumj.i = z__1.i;
00819 }
00820 }
00821 } else {
00822
00823
00824
00825 if (upper) {
00826
00827 i__3 = *kd, i__4 = j - 1;
00828 jlen = min(i__3,i__4);
00829 i__3 = jlen;
00830 for (i__ = 1; i__ <= i__3; ++i__) {
00831 i__4 = *kd + i__ - jlen + j * ab_dim1;
00832 z__3.r = ab[i__4].r * uscal.r - ab[i__4].i *
00833 uscal.i, z__3.i = ab[i__4].r * uscal.i +
00834 ab[i__4].i * uscal.r;
00835 i__5 = j - jlen - 1 + i__;
00836 z__2.r = z__3.r * x[i__5].r - z__3.i * x[i__5].i,
00837 z__2.i = z__3.r * x[i__5].i + z__3.i * x[
00838 i__5].r;
00839 z__1.r = csumj.r + z__2.r, z__1.i = csumj.i +
00840 z__2.i;
00841 csumj.r = z__1.r, csumj.i = z__1.i;
00842
00843 }
00844 } else {
00845
00846 i__3 = *kd, i__4 = *n - j;
00847 jlen = min(i__3,i__4);
00848 i__3 = jlen;
00849 for (i__ = 1; i__ <= i__3; ++i__) {
00850 i__4 = i__ + 1 + j * ab_dim1;
00851 z__3.r = ab[i__4].r * uscal.r - ab[i__4].i *
00852 uscal.i, z__3.i = ab[i__4].r * uscal.i +
00853 ab[i__4].i * uscal.r;
00854 i__5 = j + i__;
00855 z__2.r = z__3.r * x[i__5].r - z__3.i * x[i__5].i,
00856 z__2.i = z__3.r * x[i__5].i + z__3.i * x[
00857 i__5].r;
00858 z__1.r = csumj.r + z__2.r, z__1.i = csumj.i +
00859 z__2.i;
00860 csumj.r = z__1.r, csumj.i = z__1.i;
00861
00862 }
00863 }
00864 }
00865
00866 z__1.r = tscal, z__1.i = 0.;
00867 if (uscal.r == z__1.r && uscal.i == z__1.i) {
00868
00869
00870
00871
00872 i__3 = j;
00873 i__4 = j;
00874 z__1.r = x[i__4].r - csumj.r, z__1.i = x[i__4].i -
00875 csumj.i;
00876 x[i__3].r = z__1.r, x[i__3].i = z__1.i;
00877 i__3 = j;
00878 xj = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = d_imag(&x[j])
00879 , abs(d__2));
00880 if (nounit) {
00881
00882
00883
00884 i__3 = maind + j * ab_dim1;
00885 z__1.r = tscal * ab[i__3].r, z__1.i = tscal * ab[i__3]
00886 .i;
00887 tjjs.r = z__1.r, tjjs.i = z__1.i;
00888 } else {
00889 tjjs.r = tscal, tjjs.i = 0.;
00890 if (tscal == 1.) {
00891 goto L160;
00892 }
00893 }
00894 tjj = (d__1 = tjjs.r, abs(d__1)) + (d__2 = d_imag(&tjjs),
00895 abs(d__2));
00896 if (tjj > smlnum) {
00897
00898
00899
00900 if (tjj < 1.) {
00901 if (xj > tjj * bignum) {
00902
00903
00904
00905 rec = 1. / xj;
00906 zdscal_(n, &rec, &x[1], &c__1);
00907 *scale *= rec;
00908 xmax *= rec;
00909 }
00910 }
00911 i__3 = j;
00912 zladiv_(&z__1, &x[j], &tjjs);
00913 x[i__3].r = z__1.r, x[i__3].i = z__1.i;
00914 } else if (tjj > 0.) {
00915
00916
00917
00918 if (xj > tjj * bignum) {
00919
00920
00921
00922 rec = tjj * bignum / xj;
00923 zdscal_(n, &rec, &x[1], &c__1);
00924 *scale *= rec;
00925 xmax *= rec;
00926 }
00927 i__3 = j;
00928 zladiv_(&z__1, &x[j], &tjjs);
00929 x[i__3].r = z__1.r, x[i__3].i = z__1.i;
00930 } else {
00931
00932
00933
00934
00935 i__3 = *n;
00936 for (i__ = 1; i__ <= i__3; ++i__) {
00937 i__4 = i__;
00938 x[i__4].r = 0., x[i__4].i = 0.;
00939
00940 }
00941 i__3 = j;
00942 x[i__3].r = 1., x[i__3].i = 0.;
00943 *scale = 0.;
00944 xmax = 0.;
00945 }
00946 L160:
00947 ;
00948 } else {
00949
00950
00951
00952
00953 i__3 = j;
00954 zladiv_(&z__2, &x[j], &tjjs);
00955 z__1.r = z__2.r - csumj.r, z__1.i = z__2.i - csumj.i;
00956 x[i__3].r = z__1.r, x[i__3].i = z__1.i;
00957 }
00958
00959 i__3 = j;
00960 d__3 = xmax, d__4 = (d__1 = x[i__3].r, abs(d__1)) + (d__2 =
00961 d_imag(&x[j]), abs(d__2));
00962 xmax = max(d__3,d__4);
00963
00964 }
00965
00966 } else {
00967
00968
00969
00970 i__1 = jlast;
00971 i__2 = jinc;
00972 for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
00973
00974
00975
00976
00977 i__3 = j;
00978 xj = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = d_imag(&x[j]),
00979 abs(d__2));
00980 uscal.r = tscal, uscal.i = 0.;
00981 rec = 1. / max(xmax,1.);
00982 if (cnorm[j] > (bignum - xj) * rec) {
00983
00984
00985
00986 rec *= .5;
00987 if (nounit) {
00988 d_cnjg(&z__2, &ab[maind + j * ab_dim1]);
00989 z__1.r = tscal * z__2.r, z__1.i = tscal * z__2.i;
00990 tjjs.r = z__1.r, tjjs.i = z__1.i;
00991 } else {
00992 tjjs.r = tscal, tjjs.i = 0.;
00993 }
00994 tjj = (d__1 = tjjs.r, abs(d__1)) + (d__2 = d_imag(&tjjs),
00995 abs(d__2));
00996 if (tjj > 1.) {
00997
00998
00999
01000
01001 d__1 = 1., d__2 = rec * tjj;
01002 rec = min(d__1,d__2);
01003 zladiv_(&z__1, &uscal, &tjjs);
01004 uscal.r = z__1.r, uscal.i = z__1.i;
01005 }
01006 if (rec < 1.) {
01007 zdscal_(n, &rec, &x[1], &c__1);
01008 *scale *= rec;
01009 xmax *= rec;
01010 }
01011 }
01012
01013 csumj.r = 0., csumj.i = 0.;
01014 if (uscal.r == 1. && uscal.i == 0.) {
01015
01016
01017
01018
01019 if (upper) {
01020
01021 i__3 = *kd, i__4 = j - 1;
01022 jlen = min(i__3,i__4);
01023 zdotc_(&z__1, &jlen, &ab[*kd + 1 - jlen + j * ab_dim1]
01024 , &c__1, &x[j - jlen], &c__1);
01025 csumj.r = z__1.r, csumj.i = z__1.i;
01026 } else {
01027
01028 i__3 = *kd, i__4 = *n - j;
01029 jlen = min(i__3,i__4);
01030 if (jlen > 1) {
01031 zdotc_(&z__1, &jlen, &ab[j * ab_dim1 + 2], &c__1,
01032 &x[j + 1], &c__1);
01033 csumj.r = z__1.r, csumj.i = z__1.i;
01034 }
01035 }
01036 } else {
01037
01038
01039
01040 if (upper) {
01041
01042 i__3 = *kd, i__4 = j - 1;
01043 jlen = min(i__3,i__4);
01044 i__3 = jlen;
01045 for (i__ = 1; i__ <= i__3; ++i__) {
01046 d_cnjg(&z__4, &ab[*kd + i__ - jlen + j * ab_dim1])
01047 ;
01048 z__3.r = z__4.r * uscal.r - z__4.i * uscal.i,
01049 z__3.i = z__4.r * uscal.i + z__4.i *
01050 uscal.r;
01051 i__4 = j - jlen - 1 + i__;
01052 z__2.r = z__3.r * x[i__4].r - z__3.i * x[i__4].i,
01053 z__2.i = z__3.r * x[i__4].i + z__3.i * x[
01054 i__4].r;
01055 z__1.r = csumj.r + z__2.r, z__1.i = csumj.i +
01056 z__2.i;
01057 csumj.r = z__1.r, csumj.i = z__1.i;
01058
01059 }
01060 } else {
01061
01062 i__3 = *kd, i__4 = *n - j;
01063 jlen = min(i__3,i__4);
01064 i__3 = jlen;
01065 for (i__ = 1; i__ <= i__3; ++i__) {
01066 d_cnjg(&z__4, &ab[i__ + 1 + j * ab_dim1]);
01067 z__3.r = z__4.r * uscal.r - z__4.i * uscal.i,
01068 z__3.i = z__4.r * uscal.i + z__4.i *
01069 uscal.r;
01070 i__4 = j + i__;
01071 z__2.r = z__3.r * x[i__4].r - z__3.i * x[i__4].i,
01072 z__2.i = z__3.r * x[i__4].i + z__3.i * x[
01073 i__4].r;
01074 z__1.r = csumj.r + z__2.r, z__1.i = csumj.i +
01075 z__2.i;
01076 csumj.r = z__1.r, csumj.i = z__1.i;
01077
01078 }
01079 }
01080 }
01081
01082 z__1.r = tscal, z__1.i = 0.;
01083 if (uscal.r == z__1.r && uscal.i == z__1.i) {
01084
01085
01086
01087
01088 i__3 = j;
01089 i__4 = j;
01090 z__1.r = x[i__4].r - csumj.r, z__1.i = x[i__4].i -
01091 csumj.i;
01092 x[i__3].r = z__1.r, x[i__3].i = z__1.i;
01093 i__3 = j;
01094 xj = (d__1 = x[i__3].r, abs(d__1)) + (d__2 = d_imag(&x[j])
01095 , abs(d__2));
01096 if (nounit) {
01097
01098
01099
01100 d_cnjg(&z__2, &ab[maind + j * ab_dim1]);
01101 z__1.r = tscal * z__2.r, z__1.i = tscal * z__2.i;
01102 tjjs.r = z__1.r, tjjs.i = z__1.i;
01103 } else {
01104 tjjs.r = tscal, tjjs.i = 0.;
01105 if (tscal == 1.) {
01106 goto L210;
01107 }
01108 }
01109 tjj = (d__1 = tjjs.r, abs(d__1)) + (d__2 = d_imag(&tjjs),
01110 abs(d__2));
01111 if (tjj > smlnum) {
01112
01113
01114
01115 if (tjj < 1.) {
01116 if (xj > tjj * bignum) {
01117
01118
01119
01120 rec = 1. / xj;
01121 zdscal_(n, &rec, &x[1], &c__1);
01122 *scale *= rec;
01123 xmax *= rec;
01124 }
01125 }
01126 i__3 = j;
01127 zladiv_(&z__1, &x[j], &tjjs);
01128 x[i__3].r = z__1.r, x[i__3].i = z__1.i;
01129 } else if (tjj > 0.) {
01130
01131
01132
01133 if (xj > tjj * bignum) {
01134
01135
01136
01137 rec = tjj * bignum / xj;
01138 zdscal_(n, &rec, &x[1], &c__1);
01139 *scale *= rec;
01140 xmax *= rec;
01141 }
01142 i__3 = j;
01143 zladiv_(&z__1, &x[j], &tjjs);
01144 x[i__3].r = z__1.r, x[i__3].i = z__1.i;
01145 } else {
01146
01147
01148
01149
01150 i__3 = *n;
01151 for (i__ = 1; i__ <= i__3; ++i__) {
01152 i__4 = i__;
01153 x[i__4].r = 0., x[i__4].i = 0.;
01154
01155 }
01156 i__3 = j;
01157 x[i__3].r = 1., x[i__3].i = 0.;
01158 *scale = 0.;
01159 xmax = 0.;
01160 }
01161 L210:
01162 ;
01163 } else {
01164
01165
01166
01167
01168 i__3 = j;
01169 zladiv_(&z__2, &x[j], &tjjs);
01170 z__1.r = z__2.r - csumj.r, z__1.i = z__2.i - csumj.i;
01171 x[i__3].r = z__1.r, x[i__3].i = z__1.i;
01172 }
01173
01174 i__3 = j;
01175 d__3 = xmax, d__4 = (d__1 = x[i__3].r, abs(d__1)) + (d__2 =
01176 d_imag(&x[j]), abs(d__2));
01177 xmax = max(d__3,d__4);
01178
01179 }
01180 }
01181 *scale /= tscal;
01182 }
01183
01184
01185
01186 if (tscal != 1.) {
01187 d__1 = 1. / tscal;
01188 dscal_(n, &d__1, &cnorm[1], &c__1);
01189 }
01190
01191 return 0;
01192
01193
01194
01195 }