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