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 doublecomplex c_b1 = {0.,0.};
00019 static integer c__3 = 3;
00020
00021 int zlatm4_(integer *itype, integer *n, integer *nz1,
00022 integer *nz2, logical *rsign, doublereal *amagn, doublereal *rcond,
00023 doublereal *triang, integer *idist, integer *iseed, doublecomplex *a,
00024 integer *lda)
00025 {
00026
00027 integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
00028 doublereal d__1, d__2;
00029 doublecomplex z__1, z__2;
00030
00031
00032 double pow_dd(doublereal *, doublereal *), log(doublereal), exp(
00033 doublereal), z_abs(doublecomplex *);
00034
00035
00036 integer i__, k, jc, jd, jr, kbeg, isdb, kend, isde, klen;
00037 doublereal alpha;
00038 doublecomplex ctemp;
00039 extern doublereal dlaran_(integer *);
00040 extern VOID zlarnd_(doublecomplex *, integer *,
00041 integer *);
00042 extern int zlaset_(char *, integer *, integer *,
00043 doublecomplex *, doublecomplex *, doublecomplex *, integer *);
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
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 --iseed;
00165 a_dim1 = *lda;
00166 a_offset = 1 + a_dim1;
00167 a -= a_offset;
00168
00169
00170 if (*n <= 0) {
00171 return 0;
00172 }
00173 zlaset_("Full", n, n, &c_b1, &c_b1, &a[a_offset], lda);
00174
00175
00176
00177 if (iseed[4] % 2 != 1) {
00178 ++iseed[4];
00179 }
00180
00181
00182
00183
00184 if (*itype != 0) {
00185 if (abs(*itype) >= 4) {
00186
00187
00188 i__3 = *n, i__4 = *nz1 + 1;
00189 i__1 = 1, i__2 = min(i__3,i__4);
00190 kbeg = max(i__1,i__2);
00191
00192
00193 i__3 = *n, i__4 = *n - *nz2;
00194 i__1 = kbeg, i__2 = min(i__3,i__4);
00195 kend = max(i__1,i__2);
00196 klen = kend + 1 - kbeg;
00197 } else {
00198 kbeg = 1;
00199 kend = *n;
00200 klen = *n;
00201 }
00202 isdb = 1;
00203 isde = 0;
00204 switch (abs(*itype)) {
00205 case 1: goto L10;
00206 case 2: goto L30;
00207 case 3: goto L50;
00208 case 4: goto L80;
00209 case 5: goto L100;
00210 case 6: goto L120;
00211 case 7: goto L140;
00212 case 8: goto L160;
00213 case 9: goto L180;
00214 case 10: goto L200;
00215 }
00216
00217
00218
00219 L10:
00220 i__1 = *n;
00221 for (jd = 1; jd <= i__1; ++jd) {
00222 i__2 = jd + jd * a_dim1;
00223 a[i__2].r = 1., a[i__2].i = 0.;
00224
00225 }
00226 goto L220;
00227
00228
00229
00230 L30:
00231 i__1 = *n - 1;
00232 for (jd = 1; jd <= i__1; ++jd) {
00233 i__2 = jd + 1 + jd * a_dim1;
00234 a[i__2].r = 1., a[i__2].i = 0.;
00235
00236 }
00237 isdb = 1;
00238 isde = *n - 1;
00239 goto L220;
00240
00241
00242
00243
00244 L50:
00245 k = (*n - 1) / 2;
00246 i__1 = k;
00247 for (jd = 1; jd <= i__1; ++jd) {
00248 i__2 = jd + 1 + jd * a_dim1;
00249 a[i__2].r = 1., a[i__2].i = 0.;
00250
00251 }
00252 isdb = 1;
00253 isde = k;
00254 i__1 = (k << 1) + 1;
00255 for (jd = k + 2; jd <= i__1; ++jd) {
00256 i__2 = jd + jd * a_dim1;
00257 a[i__2].r = 1., a[i__2].i = 0.;
00258
00259 }
00260 goto L220;
00261
00262
00263
00264 L80:
00265 i__1 = kend;
00266 for (jd = kbeg; jd <= i__1; ++jd) {
00267 i__2 = jd + jd * a_dim1;
00268 i__3 = jd - *nz1;
00269 z__1.r = (doublereal) i__3, z__1.i = 0.;
00270 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
00271
00272 }
00273 goto L220;
00274
00275
00276
00277 L100:
00278 i__1 = kend;
00279 for (jd = kbeg + 1; jd <= i__1; ++jd) {
00280 i__2 = jd + jd * a_dim1;
00281 z__1.r = *rcond, z__1.i = 0.;
00282 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
00283
00284 }
00285 i__1 = kbeg + kbeg * a_dim1;
00286 a[i__1].r = 1., a[i__1].i = 0.;
00287 goto L220;
00288
00289
00290
00291 L120:
00292 i__1 = kend - 1;
00293 for (jd = kbeg; jd <= i__1; ++jd) {
00294 i__2 = jd + jd * a_dim1;
00295 a[i__2].r = 1., a[i__2].i = 0.;
00296
00297 }
00298 i__1 = kend + kend * a_dim1;
00299 z__1.r = *rcond, z__1.i = 0.;
00300 a[i__1].r = z__1.r, a[i__1].i = z__1.i;
00301 goto L220;
00302
00303
00304
00305 L140:
00306 i__1 = kbeg + kbeg * a_dim1;
00307 a[i__1].r = 1., a[i__1].i = 0.;
00308 if (klen > 1) {
00309 d__1 = 1. / (doublereal) (klen - 1);
00310 alpha = pow_dd(rcond, &d__1);
00311 i__1 = klen;
00312 for (i__ = 2; i__ <= i__1; ++i__) {
00313 i__2 = *nz1 + i__ + (*nz1 + i__) * a_dim1;
00314 d__2 = (doublereal) (i__ - 1);
00315 d__1 = pow_dd(&alpha, &d__2);
00316 z__1.r = d__1, z__1.i = 0.;
00317 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
00318
00319 }
00320 }
00321 goto L220;
00322
00323
00324
00325 L160:
00326 i__1 = kbeg + kbeg * a_dim1;
00327 a[i__1].r = 1., a[i__1].i = 0.;
00328 if (klen > 1) {
00329 alpha = (1. - *rcond) / (doublereal) (klen - 1);
00330 i__1 = klen;
00331 for (i__ = 2; i__ <= i__1; ++i__) {
00332 i__2 = *nz1 + i__ + (*nz1 + i__) * a_dim1;
00333 d__1 = (doublereal) (klen - i__) * alpha + *rcond;
00334 z__1.r = d__1, z__1.i = 0.;
00335 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
00336
00337 }
00338 }
00339 goto L220;
00340
00341
00342
00343 L180:
00344 alpha = log(*rcond);
00345 i__1 = kend;
00346 for (jd = kbeg; jd <= i__1; ++jd) {
00347 i__2 = jd + jd * a_dim1;
00348 d__1 = exp(alpha * dlaran_(&iseed[1]));
00349 a[i__2].r = d__1, a[i__2].i = 0.;
00350
00351 }
00352 goto L220;
00353
00354
00355
00356 L200:
00357 i__1 = kend;
00358 for (jd = kbeg; jd <= i__1; ++jd) {
00359 i__2 = jd + jd * a_dim1;
00360 zlarnd_(&z__1, idist, &iseed[1]);
00361 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
00362
00363 }
00364
00365 L220:
00366
00367
00368
00369 i__1 = kend;
00370 for (jd = kbeg; jd <= i__1; ++jd) {
00371 i__2 = jd + jd * a_dim1;
00372 i__3 = jd + jd * a_dim1;
00373 d__1 = *amagn * a[i__3].r;
00374 a[i__2].r = d__1, a[i__2].i = 0.;
00375
00376 }
00377 i__1 = isde;
00378 for (jd = isdb; jd <= i__1; ++jd) {
00379 i__2 = jd + 1 + jd * a_dim1;
00380 i__3 = jd + 1 + jd * a_dim1;
00381 d__1 = *amagn * a[i__3].r;
00382 a[i__2].r = d__1, a[i__2].i = 0.;
00383
00384 }
00385
00386
00387
00388
00389 if (*rsign) {
00390 i__1 = kend;
00391 for (jd = kbeg; jd <= i__1; ++jd) {
00392 i__2 = jd + jd * a_dim1;
00393 if (a[i__2].r != 0.) {
00394 zlarnd_(&z__1, &c__3, &iseed[1]);
00395 ctemp.r = z__1.r, ctemp.i = z__1.i;
00396 d__1 = z_abs(&ctemp);
00397 z__1.r = ctemp.r / d__1, z__1.i = ctemp.i / d__1;
00398 ctemp.r = z__1.r, ctemp.i = z__1.i;
00399 i__2 = jd + jd * a_dim1;
00400 i__3 = jd + jd * a_dim1;
00401 d__1 = a[i__3].r;
00402 z__1.r = d__1 * ctemp.r, z__1.i = d__1 * ctemp.i;
00403 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
00404 }
00405
00406 }
00407 i__1 = isde;
00408 for (jd = isdb; jd <= i__1; ++jd) {
00409 i__2 = jd + 1 + jd * a_dim1;
00410 if (a[i__2].r != 0.) {
00411 zlarnd_(&z__1, &c__3, &iseed[1]);
00412 ctemp.r = z__1.r, ctemp.i = z__1.i;
00413 d__1 = z_abs(&ctemp);
00414 z__1.r = ctemp.r / d__1, z__1.i = ctemp.i / d__1;
00415 ctemp.r = z__1.r, ctemp.i = z__1.i;
00416 i__2 = jd + 1 + jd * a_dim1;
00417 i__3 = jd + 1 + jd * a_dim1;
00418 d__1 = a[i__3].r;
00419 z__1.r = d__1 * ctemp.r, z__1.i = d__1 * ctemp.i;
00420 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
00421 }
00422
00423 }
00424 }
00425
00426
00427
00428 if (*itype < 0) {
00429 i__1 = (kbeg + kend - 1) / 2;
00430 for (jd = kbeg; jd <= i__1; ++jd) {
00431 i__2 = jd + jd * a_dim1;
00432 ctemp.r = a[i__2].r, ctemp.i = a[i__2].i;
00433 i__2 = jd + jd * a_dim1;
00434 i__3 = kbeg + kend - jd + (kbeg + kend - jd) * a_dim1;
00435 a[i__2].r = a[i__3].r, a[i__2].i = a[i__3].i;
00436 i__2 = kbeg + kend - jd + (kbeg + kend - jd) * a_dim1;
00437 a[i__2].r = ctemp.r, a[i__2].i = ctemp.i;
00438
00439 }
00440 i__1 = (*n - 1) / 2;
00441 for (jd = 1; jd <= i__1; ++jd) {
00442 i__2 = jd + 1 + jd * a_dim1;
00443 ctemp.r = a[i__2].r, ctemp.i = a[i__2].i;
00444 i__2 = jd + 1 + jd * a_dim1;
00445 i__3 = *n + 1 - jd + (*n - jd) * a_dim1;
00446 a[i__2].r = a[i__3].r, a[i__2].i = a[i__3].i;
00447 i__2 = *n + 1 - jd + (*n - jd) * a_dim1;
00448 a[i__2].r = ctemp.r, a[i__2].i = ctemp.i;
00449
00450 }
00451 }
00452
00453 }
00454
00455
00456
00457 if (*triang != 0.) {
00458 i__1 = *n;
00459 for (jc = 2; jc <= i__1; ++jc) {
00460 i__2 = jc - 1;
00461 for (jr = 1; jr <= i__2; ++jr) {
00462 i__3 = jr + jc * a_dim1;
00463 zlarnd_(&z__2, idist, &iseed[1]);
00464 z__1.r = *triang * z__2.r, z__1.i = *triang * z__2.i;
00465 a[i__3].r = z__1.r, a[i__3].i = z__1.i;
00466
00467 }
00468
00469 }
00470 }
00471
00472 return 0;
00473
00474
00475
00476 }