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