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