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 real c_b36 = .5f;
00020
00021 int clatbs_(char *uplo, char *trans, char *diag, char *
00022 normin, integer *n, integer *kd, complex *ab, integer *ldab, complex *
00023 x, real *scale, real *cnorm, integer *info)
00024 {
00025
00026 integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4, i__5;
00027 real r__1, r__2, r__3, r__4;
00028 complex q__1, q__2, q__3, q__4;
00029
00030
00031 double r_imag(complex *);
00032 void r_cnjg(complex *, complex *);
00033
00034
00035 integer i__, j;
00036 real xj, rec, tjj;
00037 integer jinc, jlen;
00038 real xbnd;
00039 integer imax;
00040 real tmax;
00041 complex tjjs;
00042 real xmax, grow;
00043 integer maind;
00044 extern VOID cdotc_(complex *, integer *, complex *, integer
00045 *, complex *, integer *);
00046 extern logical lsame_(char *, char *);
00047 extern int sscal_(integer *, real *, real *, integer *);
00048 real tscal;
00049 complex uscal;
00050 integer jlast;
00051 extern VOID cdotu_(complex *, integer *, complex *, integer
00052 *, complex *, integer *);
00053 complex csumj;
00054 extern int ctbsv_(char *, char *, char *, integer *,
00055 integer *, complex *, integer *, complex *, integer *), caxpy_(integer *, complex *, complex *, integer *
00056 , complex *, integer *);
00057 logical upper;
00058 extern int slabad_(real *, real *);
00059 extern integer icamax_(integer *, complex *, integer *);
00060 extern VOID cladiv_(complex *, complex *, complex *);
00061 extern doublereal slamch_(char *);
00062 extern int csscal_(integer *, real *, complex *, integer
00063 *), xerbla_(char *, integer *);
00064 real bignum;
00065 extern integer isamax_(integer *, real *, integer *);
00066 extern doublereal scasum_(integer *, complex *, integer *);
00067 logical notran;
00068 integer jfirst;
00069 real smlnum;
00070 logical nounit;
00071
00072
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 ab_dim1 = *ldab;
00255 ab_offset = 1 + ab_dim1;
00256 ab -= ab_offset;
00257 --x;
00258 --cnorm;
00259
00260
00261 *info = 0;
00262 upper = lsame_(uplo, "U");
00263 notran = lsame_(trans, "N");
00264 nounit = lsame_(diag, "N");
00265
00266
00267
00268 if (! upper && ! lsame_(uplo, "L")) {
00269 *info = -1;
00270 } else if (! notran && ! lsame_(trans, "T") && !
00271 lsame_(trans, "C")) {
00272 *info = -2;
00273 } else if (! nounit && ! lsame_(diag, "U")) {
00274 *info = -3;
00275 } else if (! lsame_(normin, "Y") && ! lsame_(normin,
00276 "N")) {
00277 *info = -4;
00278 } else if (*n < 0) {
00279 *info = -5;
00280 } else if (*kd < 0) {
00281 *info = -6;
00282 } else if (*ldab < *kd + 1) {
00283 *info = -8;
00284 }
00285 if (*info != 0) {
00286 i__1 = -(*info);
00287 xerbla_("CLATBS", &i__1);
00288 return 0;
00289 }
00290
00291
00292
00293 if (*n == 0) {
00294 return 0;
00295 }
00296
00297
00298
00299 smlnum = slamch_("Safe minimum");
00300 bignum = 1.f / smlnum;
00301 slabad_(&smlnum, &bignum);
00302 smlnum /= slamch_("Precision");
00303 bignum = 1.f / smlnum;
00304 *scale = 1.f;
00305
00306 if (lsame_(normin, "N")) {
00307
00308
00309
00310 if (upper) {
00311
00312
00313
00314 i__1 = *n;
00315 for (j = 1; j <= i__1; ++j) {
00316
00317 i__2 = *kd, i__3 = j - 1;
00318 jlen = min(i__2,i__3);
00319 cnorm[j] = scasum_(&jlen, &ab[*kd + 1 - jlen + j * ab_dim1], &
00320 c__1);
00321
00322 }
00323 } else {
00324
00325
00326
00327 i__1 = *n;
00328 for (j = 1; j <= i__1; ++j) {
00329
00330 i__2 = *kd, i__3 = *n - j;
00331 jlen = min(i__2,i__3);
00332 if (jlen > 0) {
00333 cnorm[j] = scasum_(&jlen, &ab[j * ab_dim1 + 2], &c__1);
00334 } else {
00335 cnorm[j] = 0.f;
00336 }
00337
00338 }
00339 }
00340 }
00341
00342
00343
00344
00345 imax = isamax_(n, &cnorm[1], &c__1);
00346 tmax = cnorm[imax];
00347 if (tmax <= bignum * .5f) {
00348 tscal = 1.f;
00349 } else {
00350 tscal = .5f / (smlnum * tmax);
00351 sscal_(n, &tscal, &cnorm[1], &c__1);
00352 }
00353
00354
00355
00356
00357 xmax = 0.f;
00358 i__1 = *n;
00359 for (j = 1; j <= i__1; ++j) {
00360
00361 i__2 = j;
00362 r__3 = xmax, r__4 = (r__1 = x[i__2].r / 2.f, dabs(r__1)) + (r__2 =
00363 r_imag(&x[j]) / 2.f, dabs(r__2));
00364 xmax = dmax(r__3,r__4);
00365
00366 }
00367 xbnd = xmax;
00368 if (notran) {
00369
00370
00371
00372 if (upper) {
00373 jfirst = *n;
00374 jlast = 1;
00375 jinc = -1;
00376 maind = *kd + 1;
00377 } else {
00378 jfirst = 1;
00379 jlast = *n;
00380 jinc = 1;
00381 maind = 1;
00382 }
00383
00384 if (tscal != 1.f) {
00385 grow = 0.f;
00386 goto L60;
00387 }
00388
00389 if (nounit) {
00390
00391
00392
00393
00394
00395
00396 grow = .5f / dmax(xbnd,smlnum);
00397 xbnd = grow;
00398 i__1 = jlast;
00399 i__2 = jinc;
00400 for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
00401
00402
00403
00404 if (grow <= smlnum) {
00405 goto L60;
00406 }
00407
00408 i__3 = maind + j * ab_dim1;
00409 tjjs.r = ab[i__3].r, tjjs.i = ab[i__3].i;
00410 tjj = (r__1 = tjjs.r, dabs(r__1)) + (r__2 = r_imag(&tjjs),
00411 dabs(r__2));
00412
00413 if (tjj >= smlnum) {
00414
00415
00416
00417
00418 r__1 = xbnd, r__2 = dmin(1.f,tjj) * grow;
00419 xbnd = dmin(r__1,r__2);
00420 } else {
00421
00422
00423
00424 xbnd = 0.f;
00425 }
00426
00427 if (tjj + cnorm[j] >= smlnum) {
00428
00429
00430
00431 grow *= tjj / (tjj + cnorm[j]);
00432 } else {
00433
00434
00435
00436 grow = 0.f;
00437 }
00438
00439 }
00440 grow = xbnd;
00441 } else {
00442
00443
00444
00445
00446
00447
00448 r__1 = 1.f, r__2 = .5f / dmax(xbnd,smlnum);
00449 grow = dmin(r__1,r__2);
00450 i__2 = jlast;
00451 i__1 = jinc;
00452 for (j = jfirst; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
00453
00454
00455
00456 if (grow <= smlnum) {
00457 goto L60;
00458 }
00459
00460
00461
00462 grow *= 1.f / (cnorm[j] + 1.f);
00463
00464 }
00465 }
00466 L60:
00467
00468 ;
00469 } else {
00470
00471
00472
00473 if (upper) {
00474 jfirst = 1;
00475 jlast = *n;
00476 jinc = 1;
00477 maind = *kd + 1;
00478 } else {
00479 jfirst = *n;
00480 jlast = 1;
00481 jinc = -1;
00482 maind = 1;
00483 }
00484
00485 if (tscal != 1.f) {
00486 grow = 0.f;
00487 goto L90;
00488 }
00489
00490 if (nounit) {
00491
00492
00493
00494
00495
00496
00497 grow = .5f / dmax(xbnd,smlnum);
00498 xbnd = grow;
00499 i__1 = jlast;
00500 i__2 = jinc;
00501 for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
00502
00503
00504
00505 if (grow <= smlnum) {
00506 goto L90;
00507 }
00508
00509
00510
00511 xj = cnorm[j] + 1.f;
00512
00513 r__1 = grow, r__2 = xbnd / xj;
00514 grow = dmin(r__1,r__2);
00515
00516 i__3 = maind + j * ab_dim1;
00517 tjjs.r = ab[i__3].r, tjjs.i = ab[i__3].i;
00518 tjj = (r__1 = tjjs.r, dabs(r__1)) + (r__2 = r_imag(&tjjs),
00519 dabs(r__2));
00520
00521 if (tjj >= smlnum) {
00522
00523
00524
00525 if (xj > tjj) {
00526 xbnd *= tjj / xj;
00527 }
00528 } else {
00529
00530
00531
00532 xbnd = 0.f;
00533 }
00534
00535 }
00536 grow = dmin(grow,xbnd);
00537 } else {
00538
00539
00540
00541
00542
00543
00544 r__1 = 1.f, r__2 = .5f / dmax(xbnd,smlnum);
00545 grow = dmin(r__1,r__2);
00546 i__2 = jlast;
00547 i__1 = jinc;
00548 for (j = jfirst; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
00549
00550
00551
00552 if (grow <= smlnum) {
00553 goto L90;
00554 }
00555
00556
00557
00558 xj = cnorm[j] + 1.f;
00559 grow /= xj;
00560
00561 }
00562 }
00563 L90:
00564 ;
00565 }
00566
00567 if (grow * tscal > smlnum) {
00568
00569
00570
00571
00572 ctbsv_(uplo, trans, diag, n, kd, &ab[ab_offset], ldab, &x[1], &c__1);
00573 } else {
00574
00575
00576
00577 if (xmax > bignum * .5f) {
00578
00579
00580
00581
00582 *scale = bignum * .5f / xmax;
00583 csscal_(n, scale, &x[1], &c__1);
00584 xmax = bignum;
00585 } else {
00586 xmax *= 2.f;
00587 }
00588
00589 if (notran) {
00590
00591
00592
00593 i__1 = jlast;
00594 i__2 = jinc;
00595 for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
00596
00597
00598
00599 i__3 = j;
00600 xj = (r__1 = x[i__3].r, dabs(r__1)) + (r__2 = r_imag(&x[j]),
00601 dabs(r__2));
00602 if (nounit) {
00603 i__3 = maind + j * ab_dim1;
00604 q__1.r = tscal * ab[i__3].r, q__1.i = tscal * ab[i__3].i;
00605 tjjs.r = q__1.r, tjjs.i = q__1.i;
00606 } else {
00607 tjjs.r = tscal, tjjs.i = 0.f;
00608 if (tscal == 1.f) {
00609 goto L105;
00610 }
00611 }
00612 tjj = (r__1 = tjjs.r, dabs(r__1)) + (r__2 = r_imag(&tjjs),
00613 dabs(r__2));
00614 if (tjj > smlnum) {
00615
00616
00617
00618 if (tjj < 1.f) {
00619 if (xj > tjj * bignum) {
00620
00621
00622
00623 rec = 1.f / xj;
00624 csscal_(n, &rec, &x[1], &c__1);
00625 *scale *= rec;
00626 xmax *= rec;
00627 }
00628 }
00629 i__3 = j;
00630 cladiv_(&q__1, &x[j], &tjjs);
00631 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
00632 i__3 = j;
00633 xj = (r__1 = x[i__3].r, dabs(r__1)) + (r__2 = r_imag(&x[j]
00634 ), dabs(r__2));
00635 } else if (tjj > 0.f) {
00636
00637
00638
00639 if (xj > tjj * bignum) {
00640
00641
00642
00643
00644 rec = tjj * bignum / xj;
00645 if (cnorm[j] > 1.f) {
00646
00647
00648
00649
00650 rec /= cnorm[j];
00651 }
00652 csscal_(n, &rec, &x[1], &c__1);
00653 *scale *= rec;
00654 xmax *= rec;
00655 }
00656 i__3 = j;
00657 cladiv_(&q__1, &x[j], &tjjs);
00658 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
00659 i__3 = j;
00660 xj = (r__1 = x[i__3].r, dabs(r__1)) + (r__2 = r_imag(&x[j]
00661 ), dabs(r__2));
00662 } else {
00663
00664
00665
00666
00667 i__3 = *n;
00668 for (i__ = 1; i__ <= i__3; ++i__) {
00669 i__4 = i__;
00670 x[i__4].r = 0.f, x[i__4].i = 0.f;
00671
00672 }
00673 i__3 = j;
00674 x[i__3].r = 1.f, x[i__3].i = 0.f;
00675 xj = 1.f;
00676 *scale = 0.f;
00677 xmax = 0.f;
00678 }
00679 L105:
00680
00681
00682
00683
00684 if (xj > 1.f) {
00685 rec = 1.f / xj;
00686 if (cnorm[j] > (bignum - xmax) * rec) {
00687
00688
00689
00690 rec *= .5f;
00691 csscal_(n, &rec, &x[1], &c__1);
00692 *scale *= rec;
00693 }
00694 } else if (xj * cnorm[j] > bignum - xmax) {
00695
00696
00697
00698 csscal_(n, &c_b36, &x[1], &c__1);
00699 *scale *= .5f;
00700 }
00701
00702 if (upper) {
00703 if (j > 1) {
00704
00705
00706
00707
00708
00709
00710 i__3 = *kd, i__4 = j - 1;
00711 jlen = min(i__3,i__4);
00712 i__3 = j;
00713 q__2.r = -x[i__3].r, q__2.i = -x[i__3].i;
00714 q__1.r = tscal * q__2.r, q__1.i = tscal * q__2.i;
00715 caxpy_(&jlen, &q__1, &ab[*kd + 1 - jlen + j * ab_dim1]
00716 , &c__1, &x[j - jlen], &c__1);
00717 i__3 = j - 1;
00718 i__ = icamax_(&i__3, &x[1], &c__1);
00719 i__3 = i__;
00720 xmax = (r__1 = x[i__3].r, dabs(r__1)) + (r__2 =
00721 r_imag(&x[i__]), dabs(r__2));
00722 }
00723 } else if (j < *n) {
00724
00725
00726
00727
00728
00729
00730 i__3 = *kd, i__4 = *n - j;
00731 jlen = min(i__3,i__4);
00732 if (jlen > 0) {
00733 i__3 = j;
00734 q__2.r = -x[i__3].r, q__2.i = -x[i__3].i;
00735 q__1.r = tscal * q__2.r, q__1.i = tscal * q__2.i;
00736 caxpy_(&jlen, &q__1, &ab[j * ab_dim1 + 2], &c__1, &x[
00737 j + 1], &c__1);
00738 }
00739 i__3 = *n - j;
00740 i__ = j + icamax_(&i__3, &x[j + 1], &c__1);
00741 i__3 = i__;
00742 xmax = (r__1 = x[i__3].r, dabs(r__1)) + (r__2 = r_imag(&x[
00743 i__]), dabs(r__2));
00744 }
00745
00746 }
00747
00748 } else if (lsame_(trans, "T")) {
00749
00750
00751
00752 i__2 = jlast;
00753 i__1 = jinc;
00754 for (j = jfirst; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
00755
00756
00757
00758
00759 i__3 = j;
00760 xj = (r__1 = x[i__3].r, dabs(r__1)) + (r__2 = r_imag(&x[j]),
00761 dabs(r__2));
00762 uscal.r = tscal, uscal.i = 0.f;
00763 rec = 1.f / dmax(xmax,1.f);
00764 if (cnorm[j] > (bignum - xj) * rec) {
00765
00766
00767
00768 rec *= .5f;
00769 if (nounit) {
00770 i__3 = maind + j * ab_dim1;
00771 q__1.r = tscal * ab[i__3].r, q__1.i = tscal * ab[i__3]
00772 .i;
00773 tjjs.r = q__1.r, tjjs.i = q__1.i;
00774 } else {
00775 tjjs.r = tscal, tjjs.i = 0.f;
00776 }
00777 tjj = (r__1 = tjjs.r, dabs(r__1)) + (r__2 = r_imag(&tjjs),
00778 dabs(r__2));
00779 if (tjj > 1.f) {
00780
00781
00782
00783
00784 r__1 = 1.f, r__2 = rec * tjj;
00785 rec = dmin(r__1,r__2);
00786 cladiv_(&q__1, &uscal, &tjjs);
00787 uscal.r = q__1.r, uscal.i = q__1.i;
00788 }
00789 if (rec < 1.f) {
00790 csscal_(n, &rec, &x[1], &c__1);
00791 *scale *= rec;
00792 xmax *= rec;
00793 }
00794 }
00795
00796 csumj.r = 0.f, csumj.i = 0.f;
00797 if (uscal.r == 1.f && uscal.i == 0.f) {
00798
00799
00800
00801
00802 if (upper) {
00803
00804 i__3 = *kd, i__4 = j - 1;
00805 jlen = min(i__3,i__4);
00806 cdotu_(&q__1, &jlen, &ab[*kd + 1 - jlen + j * ab_dim1]
00807 , &c__1, &x[j - jlen], &c__1);
00808 csumj.r = q__1.r, csumj.i = q__1.i;
00809 } else {
00810
00811 i__3 = *kd, i__4 = *n - j;
00812 jlen = min(i__3,i__4);
00813 if (jlen > 1) {
00814 cdotu_(&q__1, &jlen, &ab[j * ab_dim1 + 2], &c__1,
00815 &x[j + 1], &c__1);
00816 csumj.r = q__1.r, csumj.i = q__1.i;
00817 }
00818 }
00819 } else {
00820
00821
00822
00823 if (upper) {
00824
00825 i__3 = *kd, i__4 = j - 1;
00826 jlen = min(i__3,i__4);
00827 i__3 = jlen;
00828 for (i__ = 1; i__ <= i__3; ++i__) {
00829 i__4 = *kd + i__ - jlen + j * ab_dim1;
00830 q__3.r = ab[i__4].r * uscal.r - ab[i__4].i *
00831 uscal.i, q__3.i = ab[i__4].r * uscal.i +
00832 ab[i__4].i * uscal.r;
00833 i__5 = j - jlen - 1 + i__;
00834 q__2.r = q__3.r * x[i__5].r - q__3.i * x[i__5].i,
00835 q__2.i = q__3.r * x[i__5].i + q__3.i * x[
00836 i__5].r;
00837 q__1.r = csumj.r + q__2.r, q__1.i = csumj.i +
00838 q__2.i;
00839 csumj.r = q__1.r, csumj.i = q__1.i;
00840
00841 }
00842 } else {
00843
00844 i__3 = *kd, i__4 = *n - j;
00845 jlen = min(i__3,i__4);
00846 i__3 = jlen;
00847 for (i__ = 1; i__ <= i__3; ++i__) {
00848 i__4 = i__ + 1 + j * ab_dim1;
00849 q__3.r = ab[i__4].r * uscal.r - ab[i__4].i *
00850 uscal.i, q__3.i = ab[i__4].r * uscal.i +
00851 ab[i__4].i * uscal.r;
00852 i__5 = j + i__;
00853 q__2.r = q__3.r * x[i__5].r - q__3.i * x[i__5].i,
00854 q__2.i = q__3.r * x[i__5].i + q__3.i * x[
00855 i__5].r;
00856 q__1.r = csumj.r + q__2.r, q__1.i = csumj.i +
00857 q__2.i;
00858 csumj.r = q__1.r, csumj.i = q__1.i;
00859
00860 }
00861 }
00862 }
00863
00864 q__1.r = tscal, q__1.i = 0.f;
00865 if (uscal.r == q__1.r && uscal.i == q__1.i) {
00866
00867
00868
00869
00870 i__3 = j;
00871 i__4 = j;
00872 q__1.r = x[i__4].r - csumj.r, q__1.i = x[i__4].i -
00873 csumj.i;
00874 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
00875 i__3 = j;
00876 xj = (r__1 = x[i__3].r, dabs(r__1)) + (r__2 = r_imag(&x[j]
00877 ), dabs(r__2));
00878 if (nounit) {
00879
00880
00881
00882 i__3 = maind + j * ab_dim1;
00883 q__1.r = tscal * ab[i__3].r, q__1.i = tscal * ab[i__3]
00884 .i;
00885 tjjs.r = q__1.r, tjjs.i = q__1.i;
00886 } else {
00887 tjjs.r = tscal, tjjs.i = 0.f;
00888 if (tscal == 1.f) {
00889 goto L145;
00890 }
00891 }
00892 tjj = (r__1 = tjjs.r, dabs(r__1)) + (r__2 = r_imag(&tjjs),
00893 dabs(r__2));
00894 if (tjj > smlnum) {
00895
00896
00897
00898 if (tjj < 1.f) {
00899 if (xj > tjj * bignum) {
00900
00901
00902
00903 rec = 1.f / xj;
00904 csscal_(n, &rec, &x[1], &c__1);
00905 *scale *= rec;
00906 xmax *= rec;
00907 }
00908 }
00909 i__3 = j;
00910 cladiv_(&q__1, &x[j], &tjjs);
00911 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
00912 } else if (tjj > 0.f) {
00913
00914
00915
00916 if (xj > tjj * bignum) {
00917
00918
00919
00920 rec = tjj * bignum / xj;
00921 csscal_(n, &rec, &x[1], &c__1);
00922 *scale *= rec;
00923 xmax *= rec;
00924 }
00925 i__3 = j;
00926 cladiv_(&q__1, &x[j], &tjjs);
00927 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
00928 } else {
00929
00930
00931
00932
00933 i__3 = *n;
00934 for (i__ = 1; i__ <= i__3; ++i__) {
00935 i__4 = i__;
00936 x[i__4].r = 0.f, x[i__4].i = 0.f;
00937
00938 }
00939 i__3 = j;
00940 x[i__3].r = 1.f, x[i__3].i = 0.f;
00941 *scale = 0.f;
00942 xmax = 0.f;
00943 }
00944 L145:
00945 ;
00946 } else {
00947
00948
00949
00950
00951 i__3 = j;
00952 cladiv_(&q__2, &x[j], &tjjs);
00953 q__1.r = q__2.r - csumj.r, q__1.i = q__2.i - csumj.i;
00954 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
00955 }
00956
00957 i__3 = j;
00958 r__3 = xmax, r__4 = (r__1 = x[i__3].r, dabs(r__1)) + (r__2 =
00959 r_imag(&x[j]), dabs(r__2));
00960 xmax = dmax(r__3,r__4);
00961
00962 }
00963
00964 } else {
00965
00966
00967
00968 i__1 = jlast;
00969 i__2 = jinc;
00970 for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
00971
00972
00973
00974
00975 i__3 = j;
00976 xj = (r__1 = x[i__3].r, dabs(r__1)) + (r__2 = r_imag(&x[j]),
00977 dabs(r__2));
00978 uscal.r = tscal, uscal.i = 0.f;
00979 rec = 1.f / dmax(xmax,1.f);
00980 if (cnorm[j] > (bignum - xj) * rec) {
00981
00982
00983
00984 rec *= .5f;
00985 if (nounit) {
00986 r_cnjg(&q__2, &ab[maind + j * ab_dim1]);
00987 q__1.r = tscal * q__2.r, q__1.i = tscal * q__2.i;
00988 tjjs.r = q__1.r, tjjs.i = q__1.i;
00989 } else {
00990 tjjs.r = tscal, tjjs.i = 0.f;
00991 }
00992 tjj = (r__1 = tjjs.r, dabs(r__1)) + (r__2 = r_imag(&tjjs),
00993 dabs(r__2));
00994 if (tjj > 1.f) {
00995
00996
00997
00998
00999 r__1 = 1.f, r__2 = rec * tjj;
01000 rec = dmin(r__1,r__2);
01001 cladiv_(&q__1, &uscal, &tjjs);
01002 uscal.r = q__1.r, uscal.i = q__1.i;
01003 }
01004 if (rec < 1.f) {
01005 csscal_(n, &rec, &x[1], &c__1);
01006 *scale *= rec;
01007 xmax *= rec;
01008 }
01009 }
01010
01011 csumj.r = 0.f, csumj.i = 0.f;
01012 if (uscal.r == 1.f && uscal.i == 0.f) {
01013
01014
01015
01016
01017 if (upper) {
01018
01019 i__3 = *kd, i__4 = j - 1;
01020 jlen = min(i__3,i__4);
01021 cdotc_(&q__1, &jlen, &ab[*kd + 1 - jlen + j * ab_dim1]
01022 , &c__1, &x[j - jlen], &c__1);
01023 csumj.r = q__1.r, csumj.i = q__1.i;
01024 } else {
01025
01026 i__3 = *kd, i__4 = *n - j;
01027 jlen = min(i__3,i__4);
01028 if (jlen > 1) {
01029 cdotc_(&q__1, &jlen, &ab[j * ab_dim1 + 2], &c__1,
01030 &x[j + 1], &c__1);
01031 csumj.r = q__1.r, csumj.i = q__1.i;
01032 }
01033 }
01034 } else {
01035
01036
01037
01038 if (upper) {
01039
01040 i__3 = *kd, i__4 = j - 1;
01041 jlen = min(i__3,i__4);
01042 i__3 = jlen;
01043 for (i__ = 1; i__ <= i__3; ++i__) {
01044 r_cnjg(&q__4, &ab[*kd + i__ - jlen + j * ab_dim1])
01045 ;
01046 q__3.r = q__4.r * uscal.r - q__4.i * uscal.i,
01047 q__3.i = q__4.r * uscal.i + q__4.i *
01048 uscal.r;
01049 i__4 = j - jlen - 1 + i__;
01050 q__2.r = q__3.r * x[i__4].r - q__3.i * x[i__4].i,
01051 q__2.i = q__3.r * x[i__4].i + q__3.i * x[
01052 i__4].r;
01053 q__1.r = csumj.r + q__2.r, q__1.i = csumj.i +
01054 q__2.i;
01055 csumj.r = q__1.r, csumj.i = q__1.i;
01056
01057 }
01058 } else {
01059
01060 i__3 = *kd, i__4 = *n - j;
01061 jlen = min(i__3,i__4);
01062 i__3 = jlen;
01063 for (i__ = 1; i__ <= i__3; ++i__) {
01064 r_cnjg(&q__4, &ab[i__ + 1 + j * ab_dim1]);
01065 q__3.r = q__4.r * uscal.r - q__4.i * uscal.i,
01066 q__3.i = q__4.r * uscal.i + q__4.i *
01067 uscal.r;
01068 i__4 = j + i__;
01069 q__2.r = q__3.r * x[i__4].r - q__3.i * x[i__4].i,
01070 q__2.i = q__3.r * x[i__4].i + q__3.i * x[
01071 i__4].r;
01072 q__1.r = csumj.r + q__2.r, q__1.i = csumj.i +
01073 q__2.i;
01074 csumj.r = q__1.r, csumj.i = q__1.i;
01075
01076 }
01077 }
01078 }
01079
01080 q__1.r = tscal, q__1.i = 0.f;
01081 if (uscal.r == q__1.r && uscal.i == q__1.i) {
01082
01083
01084
01085
01086 i__3 = j;
01087 i__4 = j;
01088 q__1.r = x[i__4].r - csumj.r, q__1.i = x[i__4].i -
01089 csumj.i;
01090 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
01091 i__3 = j;
01092 xj = (r__1 = x[i__3].r, dabs(r__1)) + (r__2 = r_imag(&x[j]
01093 ), dabs(r__2));
01094 if (nounit) {
01095
01096
01097
01098 r_cnjg(&q__2, &ab[maind + j * ab_dim1]);
01099 q__1.r = tscal * q__2.r, q__1.i = tscal * q__2.i;
01100 tjjs.r = q__1.r, tjjs.i = q__1.i;
01101 } else {
01102 tjjs.r = tscal, tjjs.i = 0.f;
01103 if (tscal == 1.f) {
01104 goto L185;
01105 }
01106 }
01107 tjj = (r__1 = tjjs.r, dabs(r__1)) + (r__2 = r_imag(&tjjs),
01108 dabs(r__2));
01109 if (tjj > smlnum) {
01110
01111
01112
01113 if (tjj < 1.f) {
01114 if (xj > tjj * bignum) {
01115
01116
01117
01118 rec = 1.f / xj;
01119 csscal_(n, &rec, &x[1], &c__1);
01120 *scale *= rec;
01121 xmax *= rec;
01122 }
01123 }
01124 i__3 = j;
01125 cladiv_(&q__1, &x[j], &tjjs);
01126 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
01127 } else if (tjj > 0.f) {
01128
01129
01130
01131 if (xj > tjj * bignum) {
01132
01133
01134
01135 rec = tjj * bignum / xj;
01136 csscal_(n, &rec, &x[1], &c__1);
01137 *scale *= rec;
01138 xmax *= rec;
01139 }
01140 i__3 = j;
01141 cladiv_(&q__1, &x[j], &tjjs);
01142 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
01143 } else {
01144
01145
01146
01147
01148 i__3 = *n;
01149 for (i__ = 1; i__ <= i__3; ++i__) {
01150 i__4 = i__;
01151 x[i__4].r = 0.f, x[i__4].i = 0.f;
01152
01153 }
01154 i__3 = j;
01155 x[i__3].r = 1.f, x[i__3].i = 0.f;
01156 *scale = 0.f;
01157 xmax = 0.f;
01158 }
01159 L185:
01160 ;
01161 } else {
01162
01163
01164
01165
01166 i__3 = j;
01167 cladiv_(&q__2, &x[j], &tjjs);
01168 q__1.r = q__2.r - csumj.r, q__1.i = q__2.i - csumj.i;
01169 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
01170 }
01171
01172 i__3 = j;
01173 r__3 = xmax, r__4 = (r__1 = x[i__3].r, dabs(r__1)) + (r__2 =
01174 r_imag(&x[j]), dabs(r__2));
01175 xmax = dmax(r__3,r__4);
01176
01177 }
01178 }
01179 *scale /= tscal;
01180 }
01181
01182
01183
01184 if (tscal != 1.f) {
01185 r__1 = 1.f / tscal;
01186 sscal_(n, &r__1, &cnorm[1], &c__1);
01187 }
01188
01189 return 0;
01190
01191
01192
01193 }