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__5 = 5;
00019 static integer c__2 = 2;
00020 static integer c__1 = 1;
00021 static integer c__4 = 4;
00022 static doublereal c_b93 = 2.;
00023
00024 int zlattp_(integer *imat, char *uplo, char *trans, char *
00025 diag, integer *iseed, integer *n, doublecomplex *ap, doublecomplex *b,
00026 doublecomplex *work, doublereal *rwork, integer *info)
00027 {
00028
00029 integer i__1, i__2, i__3, i__4, i__5;
00030 doublereal d__1, d__2;
00031 doublecomplex z__1, z__2, z__3, z__4, z__5;
00032
00033
00034 int s_copy(char *, char *, ftnlen, ftnlen);
00035 void z_div(doublecomplex *, doublecomplex *, doublecomplex *);
00036 double pow_dd(doublereal *, doublereal *), sqrt(doublereal);
00037 void d_cnjg(doublecomplex *, doublecomplex *);
00038 double z_abs(doublecomplex *);
00039
00040
00041 doublereal c__;
00042 integer i__, j;
00043 doublecomplex s;
00044 doublereal t, x, y, z__;
00045 integer jc;
00046 doublecomplex ra;
00047 integer jj;
00048 doublecomplex rb;
00049 integer jl, kl, jr, ku, iy, jx;
00050 doublereal ulp, sfac;
00051 integer mode;
00052 char path[3], dist[1];
00053 doublereal unfl, rexp;
00054 char type__[1];
00055 doublereal texp;
00056 extern int zrot_(integer *, doublecomplex *, integer *,
00057 doublecomplex *, integer *, doublereal *, doublecomplex *);
00058 doublecomplex star1, plus1, plus2;
00059 doublereal bscal;
00060 extern logical lsame_(char *, char *);
00061 doublereal tscal;
00062 doublecomplex ctemp;
00063 doublereal anorm, bnorm, tleft;
00064 logical upper;
00065 extern int zrotg_(doublecomplex *, doublecomplex *,
00066 doublereal *, doublecomplex *), zlatb4_(char *, integer *,
00067 integer *, integer *, char *, integer *, integer *, doublereal *,
00068 integer *, doublereal *, char *), dlabad_(
00069 doublereal *, doublereal *);
00070 extern doublereal dlamch_(char *);
00071 char packit[1];
00072 extern int zdscal_(integer *, doublereal *,
00073 doublecomplex *, integer *);
00074 doublereal bignum, cndnum;
00075 extern int dlarnv_(integer *, integer *, integer *,
00076 doublereal *);
00077 extern integer izamax_(integer *, doublecomplex *, integer *);
00078 extern VOID zlarnd_(doublecomplex *, integer *,
00079 integer *);
00080 integer jcnext, jcount;
00081 extern int zlatms_(integer *, integer *, char *, integer
00082 *, char *, doublereal *, integer *, doublereal *, doublereal *,
00083 integer *, integer *, char *, doublecomplex *, integer *,
00084 doublecomplex *, integer *);
00085 doublereal smlnum;
00086 extern int zlarnv_(integer *, integer *, integer *,
00087 doublecomplex *);
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 --rwork;
00172 --work;
00173 --b;
00174 --ap;
00175 --iseed;
00176
00177
00178 s_copy(path, "Zomplex precision", (ftnlen)1, (ftnlen)17);
00179 s_copy(path + 1, "TP", (ftnlen)2, (ftnlen)2);
00180 unfl = dlamch_("Safe minimum");
00181 ulp = dlamch_("Epsilon") * dlamch_("Base");
00182 smlnum = unfl;
00183 bignum = (1. - ulp) / smlnum;
00184 dlabad_(&smlnum, &bignum);
00185 if (*imat >= 7 && *imat <= 10 || *imat == 18) {
00186 *(unsigned char *)diag = 'U';
00187 } else {
00188 *(unsigned char *)diag = 'N';
00189 }
00190 *info = 0;
00191
00192
00193
00194 if (*n <= 0) {
00195 return 0;
00196 }
00197
00198
00199
00200 upper = lsame_(uplo, "U");
00201 if (upper) {
00202 zlatb4_(path, imat, n, n, type__, &kl, &ku, &anorm, &mode, &cndnum,
00203 dist);
00204 *(unsigned char *)packit = 'C';
00205 } else {
00206 i__1 = -(*imat);
00207 zlatb4_(path, &i__1, n, n, type__, &kl, &ku, &anorm, &mode, &cndnum,
00208 dist);
00209 *(unsigned char *)packit = 'R';
00210 }
00211
00212
00213
00214 if (*imat <= 6) {
00215 zlatms_(n, n, dist, &iseed[1], type__, &rwork[1], &mode, &cndnum, &
00216 anorm, &kl, &ku, packit, &ap[1], n, &work[1], info);
00217
00218
00219
00220
00221
00222
00223 } else if (*imat == 7) {
00224 if (upper) {
00225 jc = 1;
00226 i__1 = *n;
00227 for (j = 1; j <= i__1; ++j) {
00228 i__2 = j - 1;
00229 for (i__ = 1; i__ <= i__2; ++i__) {
00230 i__3 = jc + i__ - 1;
00231 ap[i__3].r = 0., ap[i__3].i = 0.;
00232
00233 }
00234 i__2 = jc + j - 1;
00235 ap[i__2].r = (doublereal) j, ap[i__2].i = 0.;
00236 jc += j;
00237
00238 }
00239 } else {
00240 jc = 1;
00241 i__1 = *n;
00242 for (j = 1; j <= i__1; ++j) {
00243 i__2 = jc;
00244 ap[i__2].r = (doublereal) j, ap[i__2].i = 0.;
00245 i__2 = *n;
00246 for (i__ = j + 1; i__ <= i__2; ++i__) {
00247 i__3 = jc + i__ - j;
00248 ap[i__3].r = 0., ap[i__3].i = 0.;
00249
00250 }
00251 jc = jc + *n - j + 1;
00252
00253 }
00254 }
00255
00256
00257
00258
00259
00260
00261
00262 } else if (*imat <= 10) {
00263 if (upper) {
00264 jc = 0;
00265 i__1 = *n;
00266 for (j = 1; j <= i__1; ++j) {
00267 i__2 = j - 1;
00268 for (i__ = 1; i__ <= i__2; ++i__) {
00269 i__3 = jc + i__;
00270 ap[i__3].r = 0., ap[i__3].i = 0.;
00271
00272 }
00273 i__2 = jc + j;
00274 ap[i__2].r = (doublereal) j, ap[i__2].i = 0.;
00275 jc += j;
00276
00277 }
00278 } else {
00279 jc = 1;
00280 i__1 = *n;
00281 for (j = 1; j <= i__1; ++j) {
00282 i__2 = jc;
00283 ap[i__2].r = (doublereal) j, ap[i__2].i = 0.;
00284 i__2 = *n;
00285 for (i__ = j + 1; i__ <= i__2; ++i__) {
00286 i__3 = jc + i__ - j;
00287 ap[i__3].r = 0., ap[i__3].i = 0.;
00288
00289 }
00290 jc = jc + *n - j + 1;
00291
00292 }
00293 }
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353 zlarnd_(&z__2, &c__5, &iseed[1]);
00354 z__1.r = z__2.r * .25, z__1.i = z__2.i * .25;
00355 star1.r = z__1.r, star1.i = z__1.i;
00356 sfac = .5;
00357 zlarnd_(&z__2, &c__5, &iseed[1]);
00358 z__1.r = sfac * z__2.r, z__1.i = sfac * z__2.i;
00359 plus1.r = z__1.r, plus1.i = z__1.i;
00360 i__1 = *n;
00361 for (j = 1; j <= i__1; j += 2) {
00362 z_div(&z__1, &star1, &plus1);
00363 plus2.r = z__1.r, plus2.i = z__1.i;
00364 i__2 = j;
00365 work[i__2].r = plus1.r, work[i__2].i = plus1.i;
00366 i__2 = *n + j;
00367 work[i__2].r = star1.r, work[i__2].i = star1.i;
00368 if (j + 1 <= *n) {
00369 i__2 = j + 1;
00370 work[i__2].r = plus2.r, work[i__2].i = plus2.i;
00371 i__2 = *n + j + 1;
00372 work[i__2].r = 0., work[i__2].i = 0.;
00373 z_div(&z__1, &star1, &plus2);
00374 plus1.r = z__1.r, plus1.i = z__1.i;
00375 zlarnd_(&z__1, &c__2, &iseed[1]);
00376 rexp = z__1.r;
00377 if (rexp < 0.) {
00378 d__2 = 1. - rexp;
00379 d__1 = -pow_dd(&sfac, &d__2);
00380 zlarnd_(&z__2, &c__5, &iseed[1]);
00381 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
00382 star1.r = z__1.r, star1.i = z__1.i;
00383 } else {
00384 d__2 = rexp + 1.;
00385 d__1 = pow_dd(&sfac, &d__2);
00386 zlarnd_(&z__2, &c__5, &iseed[1]);
00387 z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
00388 star1.r = z__1.r, star1.i = z__1.i;
00389 }
00390 }
00391
00392 }
00393
00394 x = sqrt(cndnum) - 1. / sqrt(cndnum);
00395 if (*n > 2) {
00396 y = sqrt(2. / (doublereal) (*n - 2)) * x;
00397 } else {
00398 y = 0.;
00399 }
00400 z__ = x * x;
00401
00402 if (upper) {
00403
00404
00405
00406
00407 jc = 1;
00408 i__1 = *n;
00409 for (j = 2; j <= i__1; ++j) {
00410 i__2 = jc + 1;
00411 ap[i__2].r = y, ap[i__2].i = 0.;
00412 if (j > 2) {
00413 i__2 = jc + j - 1;
00414 i__3 = j - 2;
00415 ap[i__2].r = work[i__3].r, ap[i__2].i = work[i__3].i;
00416 }
00417 if (j > 3) {
00418 i__2 = jc + j - 2;
00419 i__3 = *n + j - 3;
00420 ap[i__2].r = work[i__3].r, ap[i__2].i = work[i__3].i;
00421 }
00422 jc += j;
00423
00424 }
00425 jc -= *n;
00426 i__1 = jc + 1;
00427 ap[i__1].r = z__, ap[i__1].i = 0.;
00428 i__1 = *n - 1;
00429 for (j = 2; j <= i__1; ++j) {
00430 i__2 = jc + j;
00431 ap[i__2].r = y, ap[i__2].i = 0.;
00432
00433 }
00434 } else {
00435
00436
00437
00438
00439 i__1 = *n - 1;
00440 for (i__ = 2; i__ <= i__1; ++i__) {
00441 i__2 = i__;
00442 ap[i__2].r = y, ap[i__2].i = 0.;
00443
00444 }
00445 i__1 = *n;
00446 ap[i__1].r = z__, ap[i__1].i = 0.;
00447 jc = *n + 1;
00448 i__1 = *n - 1;
00449 for (j = 2; j <= i__1; ++j) {
00450 i__2 = jc + 1;
00451 i__3 = j - 1;
00452 ap[i__2].r = work[i__3].r, ap[i__2].i = work[i__3].i;
00453 if (j < *n - 1) {
00454 i__2 = jc + 2;
00455 i__3 = *n + j - 1;
00456 ap[i__2].r = work[i__3].r, ap[i__2].i = work[i__3].i;
00457 }
00458 i__2 = jc + *n - j;
00459 ap[i__2].r = y, ap[i__2].i = 0.;
00460 jc = jc + *n - j + 1;
00461
00462 }
00463 }
00464
00465
00466
00467 if (upper) {
00468 jc = 1;
00469 i__1 = *n - 1;
00470 for (j = 1; j <= i__1; ++j) {
00471 jcnext = jc + j;
00472 i__2 = jcnext + j - 1;
00473 ra.r = ap[i__2].r, ra.i = ap[i__2].i;
00474 rb.r = 2., rb.i = 0.;
00475 zrotg_(&ra, &rb, &c__, &s);
00476
00477
00478
00479 if (*n > j + 1) {
00480 jx = jcnext + j;
00481 i__2 = *n;
00482 for (i__ = j + 2; i__ <= i__2; ++i__) {
00483 i__3 = jx + j;
00484 z__2.r = c__ * ap[i__3].r, z__2.i = c__ * ap[i__3].i;
00485 i__4 = jx + j + 1;
00486 z__3.r = s.r * ap[i__4].r - s.i * ap[i__4].i, z__3.i =
00487 s.r * ap[i__4].i + s.i * ap[i__4].r;
00488 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00489 ctemp.r = z__1.r, ctemp.i = z__1.i;
00490 i__3 = jx + j + 1;
00491 d_cnjg(&z__4, &s);
00492 z__3.r = -z__4.r, z__3.i = -z__4.i;
00493 i__4 = jx + j;
00494 z__2.r = z__3.r * ap[i__4].r - z__3.i * ap[i__4].i,
00495 z__2.i = z__3.r * ap[i__4].i + z__3.i * ap[
00496 i__4].r;
00497 i__5 = jx + j + 1;
00498 z__5.r = c__ * ap[i__5].r, z__5.i = c__ * ap[i__5].i;
00499 z__1.r = z__2.r + z__5.r, z__1.i = z__2.i + z__5.i;
00500 ap[i__3].r = z__1.r, ap[i__3].i = z__1.i;
00501 i__3 = jx + j;
00502 ap[i__3].r = ctemp.r, ap[i__3].i = ctemp.i;
00503 jx += i__;
00504
00505 }
00506 }
00507
00508
00509
00510 if (j > 1) {
00511 i__2 = j - 1;
00512 d__1 = -c__;
00513 z__1.r = -s.r, z__1.i = -s.i;
00514 zrot_(&i__2, &ap[jcnext], &c__1, &ap[jc], &c__1, &d__1, &
00515 z__1);
00516 }
00517
00518
00519
00520 i__2 = jcnext + j - 1;
00521 i__3 = jcnext + j - 1;
00522 z__1.r = -ap[i__3].r, z__1.i = -ap[i__3].i;
00523 ap[i__2].r = z__1.r, ap[i__2].i = z__1.i;
00524 jc = jcnext;
00525
00526 }
00527 } else {
00528 jc = 1;
00529 i__1 = *n - 1;
00530 for (j = 1; j <= i__1; ++j) {
00531 jcnext = jc + *n - j + 1;
00532 i__2 = jc + 1;
00533 ra.r = ap[i__2].r, ra.i = ap[i__2].i;
00534 rb.r = 2., rb.i = 0.;
00535 zrotg_(&ra, &rb, &c__, &s);
00536 d_cnjg(&z__1, &s);
00537 s.r = z__1.r, s.i = z__1.i;
00538
00539
00540
00541 if (*n > j + 1) {
00542 i__2 = *n - j - 1;
00543 z__1.r = -s.r, z__1.i = -s.i;
00544 zrot_(&i__2, &ap[jcnext + 1], &c__1, &ap[jc + 2], &c__1, &
00545 c__, &z__1);
00546 }
00547
00548
00549
00550 if (j > 1) {
00551 jx = 1;
00552 i__2 = j - 1;
00553 for (i__ = 1; i__ <= i__2; ++i__) {
00554 d__1 = -c__;
00555 i__3 = jx + j - i__;
00556 z__2.r = d__1 * ap[i__3].r, z__2.i = d__1 * ap[i__3]
00557 .i;
00558 i__4 = jx + j - i__ + 1;
00559 z__3.r = s.r * ap[i__4].r - s.i * ap[i__4].i, z__3.i =
00560 s.r * ap[i__4].i + s.i * ap[i__4].r;
00561 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
00562 ctemp.r = z__1.r, ctemp.i = z__1.i;
00563 i__3 = jx + j - i__ + 1;
00564 d_cnjg(&z__4, &s);
00565 z__3.r = -z__4.r, z__3.i = -z__4.i;
00566 i__4 = jx + j - i__;
00567 z__2.r = z__3.r * ap[i__4].r - z__3.i * ap[i__4].i,
00568 z__2.i = z__3.r * ap[i__4].i + z__3.i * ap[
00569 i__4].r;
00570 i__5 = jx + j - i__ + 1;
00571 z__5.r = c__ * ap[i__5].r, z__5.i = c__ * ap[i__5].i;
00572 z__1.r = z__2.r - z__5.r, z__1.i = z__2.i - z__5.i;
00573 ap[i__3].r = z__1.r, ap[i__3].i = z__1.i;
00574 i__3 = jx + j - i__;
00575 ap[i__3].r = ctemp.r, ap[i__3].i = ctemp.i;
00576 jx = jx + *n - i__ + 1;
00577
00578 }
00579 }
00580
00581
00582
00583 i__2 = jc + 1;
00584 i__3 = jc + 1;
00585 z__1.r = -ap[i__3].r, z__1.i = -ap[i__3].i;
00586 ap[i__2].r = z__1.r, ap[i__2].i = z__1.i;
00587 jc = jcnext;
00588
00589 }
00590 }
00591
00592
00593
00594
00595
00596 } else if (*imat == 11) {
00597
00598
00599
00600
00601
00602 if (upper) {
00603 jc = 1;
00604 i__1 = *n;
00605 for (j = 1; j <= i__1; ++j) {
00606 i__2 = j - 1;
00607 zlarnv_(&c__4, &iseed[1], &i__2, &ap[jc]);
00608 i__2 = jc + j - 1;
00609 zlarnd_(&z__2, &c__5, &iseed[1]);
00610 z__1.r = z__2.r * 2., z__1.i = z__2.i * 2.;
00611 ap[i__2].r = z__1.r, ap[i__2].i = z__1.i;
00612 jc += j;
00613
00614 }
00615 } else {
00616 jc = 1;
00617 i__1 = *n;
00618 for (j = 1; j <= i__1; ++j) {
00619 if (j < *n) {
00620 i__2 = *n - j;
00621 zlarnv_(&c__4, &iseed[1], &i__2, &ap[jc + 1]);
00622 }
00623 i__2 = jc;
00624 zlarnd_(&z__2, &c__5, &iseed[1]);
00625 z__1.r = z__2.r * 2., z__1.i = z__2.i * 2.;
00626 ap[i__2].r = z__1.r, ap[i__2].i = z__1.i;
00627 jc = jc + *n - j + 1;
00628
00629 }
00630 }
00631
00632
00633
00634 zlarnv_(&c__2, &iseed[1], n, &b[1]);
00635 iy = izamax_(n, &b[1], &c__1);
00636 bnorm = z_abs(&b[iy]);
00637 bscal = bignum / max(1.,bnorm);
00638 zdscal_(n, &bscal, &b[1], &c__1);
00639
00640 } else if (*imat == 12) {
00641
00642
00643
00644
00645
00646 zlarnv_(&c__2, &iseed[1], n, &b[1]);
00647
00648 d__1 = 1., d__2 = (doublereal) (*n - 1);
00649 tscal = 1. / max(d__1,d__2);
00650 if (upper) {
00651 jc = 1;
00652 i__1 = *n;
00653 for (j = 1; j <= i__1; ++j) {
00654 i__2 = j - 1;
00655 zlarnv_(&c__4, &iseed[1], &i__2, &ap[jc]);
00656 i__2 = j - 1;
00657 zdscal_(&i__2, &tscal, &ap[jc], &c__1);
00658 i__2 = jc + j - 1;
00659 zlarnd_(&z__1, &c__5, &iseed[1]);
00660 ap[i__2].r = z__1.r, ap[i__2].i = z__1.i;
00661 jc += j;
00662
00663 }
00664 i__1 = *n * (*n + 1) / 2;
00665 i__2 = *n * (*n + 1) / 2;
00666 z__1.r = smlnum * ap[i__2].r, z__1.i = smlnum * ap[i__2].i;
00667 ap[i__1].r = z__1.r, ap[i__1].i = z__1.i;
00668 } else {
00669 jc = 1;
00670 i__1 = *n;
00671 for (j = 1; j <= i__1; ++j) {
00672 i__2 = *n - j;
00673 zlarnv_(&c__2, &iseed[1], &i__2, &ap[jc + 1]);
00674 i__2 = *n - j;
00675 zdscal_(&i__2, &tscal, &ap[jc + 1], &c__1);
00676 i__2 = jc;
00677 zlarnd_(&z__1, &c__5, &iseed[1]);
00678 ap[i__2].r = z__1.r, ap[i__2].i = z__1.i;
00679 jc = jc + *n - j + 1;
00680
00681 }
00682 z__1.r = smlnum * ap[1].r, z__1.i = smlnum * ap[1].i;
00683 ap[1].r = z__1.r, ap[1].i = z__1.i;
00684 }
00685
00686 } else if (*imat == 13) {
00687
00688
00689
00690
00691
00692 zlarnv_(&c__2, &iseed[1], n, &b[1]);
00693 if (upper) {
00694 jc = 1;
00695 i__1 = *n;
00696 for (j = 1; j <= i__1; ++j) {
00697 i__2 = j - 1;
00698 zlarnv_(&c__4, &iseed[1], &i__2, &ap[jc]);
00699 i__2 = jc + j - 1;
00700 zlarnd_(&z__1, &c__5, &iseed[1]);
00701 ap[i__2].r = z__1.r, ap[i__2].i = z__1.i;
00702 jc += j;
00703
00704 }
00705 i__1 = *n * (*n + 1) / 2;
00706 i__2 = *n * (*n + 1) / 2;
00707 z__1.r = smlnum * ap[i__2].r, z__1.i = smlnum * ap[i__2].i;
00708 ap[i__1].r = z__1.r, ap[i__1].i = z__1.i;
00709 } else {
00710 jc = 1;
00711 i__1 = *n;
00712 for (j = 1; j <= i__1; ++j) {
00713 i__2 = *n - j;
00714 zlarnv_(&c__4, &iseed[1], &i__2, &ap[jc + 1]);
00715 i__2 = jc;
00716 zlarnd_(&z__1, &c__5, &iseed[1]);
00717 ap[i__2].r = z__1.r, ap[i__2].i = z__1.i;
00718 jc = jc + *n - j + 1;
00719
00720 }
00721 z__1.r = smlnum * ap[1].r, z__1.i = smlnum * ap[1].i;
00722 ap[1].r = z__1.r, ap[1].i = z__1.i;
00723 }
00724
00725 } else if (*imat == 14) {
00726
00727
00728
00729
00730
00731 if (upper) {
00732 jcount = 1;
00733 jc = (*n - 1) * *n / 2 + 1;
00734 for (j = *n; j >= 1; --j) {
00735 i__1 = j - 1;
00736 for (i__ = 1; i__ <= i__1; ++i__) {
00737 i__2 = jc + i__ - 1;
00738 ap[i__2].r = 0., ap[i__2].i = 0.;
00739
00740 }
00741 if (jcount <= 2) {
00742 i__1 = jc + j - 1;
00743 zlarnd_(&z__2, &c__5, &iseed[1]);
00744 z__1.r = smlnum * z__2.r, z__1.i = smlnum * z__2.i;
00745 ap[i__1].r = z__1.r, ap[i__1].i = z__1.i;
00746 } else {
00747 i__1 = jc + j - 1;
00748 zlarnd_(&z__1, &c__5, &iseed[1]);
00749 ap[i__1].r = z__1.r, ap[i__1].i = z__1.i;
00750 }
00751 ++jcount;
00752 if (jcount > 4) {
00753 jcount = 1;
00754 }
00755 jc = jc - j + 1;
00756
00757 }
00758 } else {
00759 jcount = 1;
00760 jc = 1;
00761 i__1 = *n;
00762 for (j = 1; j <= i__1; ++j) {
00763 i__2 = *n;
00764 for (i__ = j + 1; i__ <= i__2; ++i__) {
00765 i__3 = jc + i__ - j;
00766 ap[i__3].r = 0., ap[i__3].i = 0.;
00767
00768 }
00769 if (jcount <= 2) {
00770 i__2 = jc;
00771 zlarnd_(&z__2, &c__5, &iseed[1]);
00772 z__1.r = smlnum * z__2.r, z__1.i = smlnum * z__2.i;
00773 ap[i__2].r = z__1.r, ap[i__2].i = z__1.i;
00774 } else {
00775 i__2 = jc;
00776 zlarnd_(&z__1, &c__5, &iseed[1]);
00777 ap[i__2].r = z__1.r, ap[i__2].i = z__1.i;
00778 }
00779 ++jcount;
00780 if (jcount > 4) {
00781 jcount = 1;
00782 }
00783 jc = jc + *n - j + 1;
00784
00785 }
00786 }
00787
00788
00789
00790 if (upper) {
00791 b[1].r = 0., b[1].i = 0.;
00792 for (i__ = *n; i__ >= 2; i__ += -2) {
00793 i__1 = i__;
00794 b[i__1].r = 0., b[i__1].i = 0.;
00795 i__1 = i__ - 1;
00796 zlarnd_(&z__2, &c__5, &iseed[1]);
00797 z__1.r = smlnum * z__2.r, z__1.i = smlnum * z__2.i;
00798 b[i__1].r = z__1.r, b[i__1].i = z__1.i;
00799
00800 }
00801 } else {
00802 i__1 = *n;
00803 b[i__1].r = 0., b[i__1].i = 0.;
00804 i__1 = *n - 1;
00805 for (i__ = 1; i__ <= i__1; i__ += 2) {
00806 i__2 = i__;
00807 b[i__2].r = 0., b[i__2].i = 0.;
00808 i__2 = i__ + 1;
00809 zlarnd_(&z__2, &c__5, &iseed[1]);
00810 z__1.r = smlnum * z__2.r, z__1.i = smlnum * z__2.i;
00811 b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00812
00813 }
00814 }
00815
00816 } else if (*imat == 15) {
00817
00818
00819
00820
00821
00822
00823 d__1 = 1., d__2 = (doublereal) (*n - 1);
00824 texp = 1. / max(d__1,d__2);
00825 tscal = pow_dd(&smlnum, &texp);
00826 zlarnv_(&c__4, &iseed[1], n, &b[1]);
00827 if (upper) {
00828 jc = 1;
00829 i__1 = *n;
00830 for (j = 1; j <= i__1; ++j) {
00831 i__2 = j - 2;
00832 for (i__ = 1; i__ <= i__2; ++i__) {
00833 i__3 = jc + i__ - 1;
00834 ap[i__3].r = 0., ap[i__3].i = 0.;
00835
00836 }
00837 if (j > 1) {
00838 i__2 = jc + j - 2;
00839 ap[i__2].r = -1., ap[i__2].i = -1.;
00840 }
00841 i__2 = jc + j - 1;
00842 zlarnd_(&z__2, &c__5, &iseed[1]);
00843 z__1.r = tscal * z__2.r, z__1.i = tscal * z__2.i;
00844 ap[i__2].r = z__1.r, ap[i__2].i = z__1.i;
00845 jc += j;
00846
00847 }
00848 i__1 = *n;
00849 b[i__1].r = 1., b[i__1].i = 1.;
00850 } else {
00851 jc = 1;
00852 i__1 = *n;
00853 for (j = 1; j <= i__1; ++j) {
00854 i__2 = *n;
00855 for (i__ = j + 2; i__ <= i__2; ++i__) {
00856 i__3 = jc + i__ - j;
00857 ap[i__3].r = 0., ap[i__3].i = 0.;
00858
00859 }
00860 if (j < *n) {
00861 i__2 = jc + 1;
00862 ap[i__2].r = -1., ap[i__2].i = -1.;
00863 }
00864 i__2 = jc;
00865 zlarnd_(&z__2, &c__5, &iseed[1]);
00866 z__1.r = tscal * z__2.r, z__1.i = tscal * z__2.i;
00867 ap[i__2].r = z__1.r, ap[i__2].i = z__1.i;
00868 jc = jc + *n - j + 1;
00869
00870 }
00871 b[1].r = 1., b[1].i = 1.;
00872 }
00873
00874 } else if (*imat == 16) {
00875
00876
00877
00878 iy = *n / 2 + 1;
00879 if (upper) {
00880 jc = 1;
00881 i__1 = *n;
00882 for (j = 1; j <= i__1; ++j) {
00883 zlarnv_(&c__4, &iseed[1], &j, &ap[jc]);
00884 if (j != iy) {
00885 i__2 = jc + j - 1;
00886 zlarnd_(&z__2, &c__5, &iseed[1]);
00887 z__1.r = z__2.r * 2., z__1.i = z__2.i * 2.;
00888 ap[i__2].r = z__1.r, ap[i__2].i = z__1.i;
00889 } else {
00890 i__2 = jc + j - 1;
00891 ap[i__2].r = 0., ap[i__2].i = 0.;
00892 }
00893 jc += j;
00894
00895 }
00896 } else {
00897 jc = 1;
00898 i__1 = *n;
00899 for (j = 1; j <= i__1; ++j) {
00900 i__2 = *n - j + 1;
00901 zlarnv_(&c__4, &iseed[1], &i__2, &ap[jc]);
00902 if (j != iy) {
00903 i__2 = jc;
00904 zlarnd_(&z__2, &c__5, &iseed[1]);
00905 z__1.r = z__2.r * 2., z__1.i = z__2.i * 2.;
00906 ap[i__2].r = z__1.r, ap[i__2].i = z__1.i;
00907 } else {
00908 i__2 = jc;
00909 ap[i__2].r = 0., ap[i__2].i = 0.;
00910 }
00911 jc = jc + *n - j + 1;
00912
00913 }
00914 }
00915 zlarnv_(&c__2, &iseed[1], n, &b[1]);
00916 zdscal_(n, &c_b93, &b[1], &c__1);
00917
00918 } else if (*imat == 17) {
00919
00920
00921
00922
00923
00924
00925 tscal = unfl / ulp;
00926 tscal = (1. - ulp) / tscal;
00927 i__1 = *n * (*n + 1) / 2;
00928 for (j = 1; j <= i__1; ++j) {
00929 i__2 = j;
00930 ap[i__2].r = 0., ap[i__2].i = 0.;
00931
00932 }
00933 texp = 1.;
00934 if (upper) {
00935 jc = (*n - 1) * *n / 2 + 1;
00936 for (j = *n; j >= 2; j += -2) {
00937 i__1 = jc;
00938 d__1 = -tscal / (doublereal) (*n + 1);
00939 ap[i__1].r = d__1, ap[i__1].i = 0.;
00940 i__1 = jc + j - 1;
00941 ap[i__1].r = 1., ap[i__1].i = 0.;
00942 i__1 = j;
00943 d__1 = texp * (1. - ulp);
00944 b[i__1].r = d__1, b[i__1].i = 0.;
00945 jc = jc - j + 1;
00946 i__1 = jc;
00947 d__1 = -(tscal / (doublereal) (*n + 1)) / (doublereal) (*n +
00948 2);
00949 ap[i__1].r = d__1, ap[i__1].i = 0.;
00950 i__1 = jc + j - 2;
00951 ap[i__1].r = 1., ap[i__1].i = 0.;
00952 i__1 = j - 1;
00953 d__1 = texp * (doublereal) (*n * *n + *n - 1);
00954 b[i__1].r = d__1, b[i__1].i = 0.;
00955 texp *= 2.;
00956 jc = jc - j + 2;
00957
00958 }
00959 d__1 = (doublereal) (*n + 1) / (doublereal) (*n + 2) * tscal;
00960 b[1].r = d__1, b[1].i = 0.;
00961 } else {
00962 jc = 1;
00963 i__1 = *n - 1;
00964 for (j = 1; j <= i__1; j += 2) {
00965 i__2 = jc + *n - j;
00966 d__1 = -tscal / (doublereal) (*n + 1);
00967 ap[i__2].r = d__1, ap[i__2].i = 0.;
00968 i__2 = jc;
00969 ap[i__2].r = 1., ap[i__2].i = 0.;
00970 i__2 = j;
00971 d__1 = texp * (1. - ulp);
00972 b[i__2].r = d__1, b[i__2].i = 0.;
00973 jc = jc + *n - j + 1;
00974 i__2 = jc + *n - j - 1;
00975 d__1 = -(tscal / (doublereal) (*n + 1)) / (doublereal) (*n +
00976 2);
00977 ap[i__2].r = d__1, ap[i__2].i = 0.;
00978 i__2 = jc;
00979 ap[i__2].r = 1., ap[i__2].i = 0.;
00980 i__2 = j + 1;
00981 d__1 = texp * (doublereal) (*n * *n + *n - 1);
00982 b[i__2].r = d__1, b[i__2].i = 0.;
00983 texp *= 2.;
00984 jc = jc + *n - j;
00985
00986 }
00987 i__1 = *n;
00988 d__1 = (doublereal) (*n + 1) / (doublereal) (*n + 2) * tscal;
00989 b[i__1].r = d__1, b[i__1].i = 0.;
00990 }
00991
00992 } else if (*imat == 18) {
00993
00994
00995
00996
00997
00998 if (upper) {
00999 jc = 1;
01000 i__1 = *n;
01001 for (j = 1; j <= i__1; ++j) {
01002 i__2 = j - 1;
01003 zlarnv_(&c__4, &iseed[1], &i__2, &ap[jc]);
01004 i__2 = jc + j - 1;
01005 ap[i__2].r = 0., ap[i__2].i = 0.;
01006 jc += j;
01007
01008 }
01009 } else {
01010 jc = 1;
01011 i__1 = *n;
01012 for (j = 1; j <= i__1; ++j) {
01013 if (j < *n) {
01014 i__2 = *n - j;
01015 zlarnv_(&c__4, &iseed[1], &i__2, &ap[jc + 1]);
01016 }
01017 i__2 = jc;
01018 ap[i__2].r = 0., ap[i__2].i = 0.;
01019 jc = jc + *n - j + 1;
01020
01021 }
01022 }
01023
01024
01025
01026 zlarnv_(&c__2, &iseed[1], n, &b[1]);
01027 iy = izamax_(n, &b[1], &c__1);
01028 bnorm = z_abs(&b[iy]);
01029 bscal = bignum / max(1.,bnorm);
01030 zdscal_(n, &bscal, &b[1], &c__1);
01031
01032 } else if (*imat == 19) {
01033
01034
01035
01036
01037
01038
01039
01040 d__1 = 1., d__2 = (doublereal) (*n - 1);
01041 tleft = bignum / max(d__1,d__2);
01042
01043 d__1 = 1., d__2 = (doublereal) (*n);
01044 tscal = bignum * ((doublereal) (*n - 1) / max(d__1,d__2));
01045 if (upper) {
01046 jc = 1;
01047 i__1 = *n;
01048 for (j = 1; j <= i__1; ++j) {
01049 zlarnv_(&c__5, &iseed[1], &j, &ap[jc]);
01050 dlarnv_(&c__1, &iseed[1], &j, &rwork[1]);
01051 i__2 = j;
01052 for (i__ = 1; i__ <= i__2; ++i__) {
01053 i__3 = jc + i__ - 1;
01054 i__4 = jc + i__ - 1;
01055 d__1 = tleft + rwork[i__] * tscal;
01056 z__1.r = d__1 * ap[i__4].r, z__1.i = d__1 * ap[i__4].i;
01057 ap[i__3].r = z__1.r, ap[i__3].i = z__1.i;
01058
01059 }
01060 jc += j;
01061
01062 }
01063 } else {
01064 jc = 1;
01065 i__1 = *n;
01066 for (j = 1; j <= i__1; ++j) {
01067 i__2 = *n - j + 1;
01068 zlarnv_(&c__5, &iseed[1], &i__2, &ap[jc]);
01069 i__2 = *n - j + 1;
01070 dlarnv_(&c__1, &iseed[1], &i__2, &rwork[1]);
01071 i__2 = *n;
01072 for (i__ = j; i__ <= i__2; ++i__) {
01073 i__3 = jc + i__ - j;
01074 i__4 = jc + i__ - j;
01075 d__1 = tleft + rwork[i__ - j + 1] * tscal;
01076 z__1.r = d__1 * ap[i__4].r, z__1.i = d__1 * ap[i__4].i;
01077 ap[i__3].r = z__1.r, ap[i__3].i = z__1.i;
01078
01079 }
01080 jc = jc + *n - j + 1;
01081
01082 }
01083 }
01084 zlarnv_(&c__2, &iseed[1], n, &b[1]);
01085 zdscal_(n, &c_b93, &b[1], &c__1);
01086 }
01087
01088
01089
01090
01091 if (! lsame_(trans, "N")) {
01092 if (upper) {
01093 jj = 1;
01094 jr = *n * (*n + 1) / 2;
01095 i__1 = *n / 2;
01096 for (j = 1; j <= i__1; ++j) {
01097 jl = jj;
01098 i__2 = *n - j;
01099 for (i__ = j; i__ <= i__2; ++i__) {
01100 i__3 = jr - i__ + j;
01101 t = ap[i__3].r;
01102 i__3 = jr - i__ + j;
01103 i__4 = jl;
01104 ap[i__3].r = ap[i__4].r, ap[i__3].i = ap[i__4].i;
01105 i__3 = jl;
01106 ap[i__3].r = t, ap[i__3].i = 0.;
01107 jl += i__;
01108
01109 }
01110 jj = jj + j + 1;
01111 jr -= *n - j + 1;
01112
01113 }
01114 } else {
01115 jl = 1;
01116 jj = *n * (*n + 1) / 2;
01117 i__1 = *n / 2;
01118 for (j = 1; j <= i__1; ++j) {
01119 jr = jj;
01120 i__2 = *n - j;
01121 for (i__ = j; i__ <= i__2; ++i__) {
01122 i__3 = jl + i__ - j;
01123 t = ap[i__3].r;
01124 i__3 = jl + i__ - j;
01125 i__4 = jr;
01126 ap[i__3].r = ap[i__4].r, ap[i__3].i = ap[i__4].i;
01127 i__3 = jr;
01128 ap[i__3].r = t, ap[i__3].i = 0.;
01129 jr -= i__;
01130
01131 }
01132 jl = jl + *n - j + 1;
01133 jj = jj - j - 1;
01134
01135 }
01136 }
01137 }
01138
01139 return 0;
01140
01141
01142
01143 }