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_b10 = 0.f;
00019 static integer c__1 = 1;
00020 static real c_b42 = 1.f;
00021
00022 int ssyt21_(integer *itype, char *uplo, integer *n, integer *
00023 kband, real *a, integer *lda, real *d__, real *e, real *u, integer *
00024 ldu, real *v, integer *ldv, real *tau, real *work, real *result)
00025 {
00026
00027 integer a_dim1, a_offset, u_dim1, u_offset, v_dim1, v_offset, i__1, i__2,
00028 i__3;
00029 real r__1, r__2;
00030
00031
00032 integer j, jr;
00033 real ulp;
00034 integer jcol;
00035 real unfl;
00036 integer jrow;
00037 extern int ssyr_(char *, integer *, real *, real *,
00038 integer *, real *, integer *), ssyr2_(char *, integer *,
00039 real *, real *, integer *, real *, integer *, real *, integer *);
00040 extern logical lsame_(char *, char *);
00041 integer iinfo;
00042 extern int sgemm_(char *, char *, integer *, integer *,
00043 integer *, real *, real *, integer *, real *, integer *, real *,
00044 real *, integer *);
00045 real anorm;
00046 char cuplo[1];
00047 real vsave;
00048 logical lower;
00049 real wnorm;
00050 extern int sorm2l_(char *, char *, integer *, integer *,
00051 integer *, real *, integer *, real *, real *, integer *, real *,
00052 integer *), sorm2r_(char *, char *, integer *,
00053 integer *, integer *, real *, integer *, real *, real *, integer *
00054 , real *, integer *);
00055 extern doublereal slamch_(char *), slange_(char *, integer *,
00056 integer *, real *, integer *, real *);
00057 extern int slacpy_(char *, integer *, integer *, real *,
00058 integer *, real *, integer *), slaset_(char *, integer *,
00059 integer *, real *, real *, real *, integer *), slarfy_(
00060 char *, integer *, real *, integer *, real *, real *, integer *,
00061 real *);
00062 extern doublereal slansy_(char *, char *, integer *, real *, integer *,
00063 real *);
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
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 a_dim1 = *lda;
00213 a_offset = 1 + a_dim1;
00214 a -= a_offset;
00215 --d__;
00216 --e;
00217 u_dim1 = *ldu;
00218 u_offset = 1 + u_dim1;
00219 u -= u_offset;
00220 v_dim1 = *ldv;
00221 v_offset = 1 + v_dim1;
00222 v -= v_offset;
00223 --tau;
00224 --work;
00225 --result;
00226
00227
00228 result[1] = 0.f;
00229 if (*itype == 1) {
00230 result[2] = 0.f;
00231 }
00232 if (*n <= 0) {
00233 return 0;
00234 }
00235
00236 if (lsame_(uplo, "U")) {
00237 lower = FALSE_;
00238 *(unsigned char *)cuplo = 'U';
00239 } else {
00240 lower = TRUE_;
00241 *(unsigned char *)cuplo = 'L';
00242 }
00243
00244 unfl = slamch_("Safe minimum");
00245 ulp = slamch_("Epsilon") * slamch_("Base");
00246
00247
00248
00249 if (*itype < 1 || *itype > 3) {
00250 result[1] = 10.f / ulp;
00251 return 0;
00252 }
00253
00254
00255
00256
00257
00258 if (*itype == 3) {
00259 anorm = 1.f;
00260 } else {
00261
00262 r__1 = slansy_("1", cuplo, n, &a[a_offset], lda, &work[1]);
00263 anorm = dmax(r__1,unfl);
00264 }
00265
00266
00267
00268 if (*itype == 1) {
00269
00270
00271
00272 slaset_("Full", n, n, &c_b10, &c_b10, &work[1], n);
00273 slacpy_(cuplo, n, n, &a[a_offset], lda, &work[1], n);
00274
00275 i__1 = *n;
00276 for (j = 1; j <= i__1; ++j) {
00277 r__1 = -d__[j];
00278 ssyr_(cuplo, n, &r__1, &u[j * u_dim1 + 1], &c__1, &work[1], n);
00279
00280 }
00281
00282 if (*n > 1 && *kband == 1) {
00283 i__1 = *n - 1;
00284 for (j = 1; j <= i__1; ++j) {
00285 r__1 = -e[j];
00286 ssyr2_(cuplo, n, &r__1, &u[j * u_dim1 + 1], &c__1, &u[(j + 1)
00287 * u_dim1 + 1], &c__1, &work[1], n);
00288
00289 }
00290 }
00291
00292 i__1 = *n;
00293 wnorm = slansy_("1", cuplo, n, &work[1], n, &work[i__1 * i__1 + 1]);
00294
00295 } else if (*itype == 2) {
00296
00297
00298
00299 slaset_("Full", n, n, &c_b10, &c_b10, &work[1], n);
00300
00301 if (lower) {
00302
00303 i__1 = *n;
00304 work[i__1 * i__1] = d__[*n];
00305 for (j = *n - 1; j >= 1; --j) {
00306 if (*kband == 1) {
00307 work[(*n + 1) * (j - 1) + 2] = (1.f - tau[j]) * e[j];
00308 i__1 = *n;
00309 for (jr = j + 2; jr <= i__1; ++jr) {
00310 work[(j - 1) * *n + jr] = -tau[j] * e[j] * v[jr + j *
00311 v_dim1];
00312
00313 }
00314 }
00315
00316 vsave = v[j + 1 + j * v_dim1];
00317 v[j + 1 + j * v_dim1] = 1.f;
00318 i__1 = *n - j;
00319
00320 i__2 = *n;
00321 slarfy_("L", &i__1, &v[j + 1 + j * v_dim1], &c__1, &tau[j], &
00322 work[(*n + 1) * j + 1], n, &work[i__2 * i__2 + 1]);
00323 v[j + 1 + j * v_dim1] = vsave;
00324 work[(*n + 1) * (j - 1) + 1] = d__[j];
00325
00326 }
00327 } else {
00328 work[1] = d__[1];
00329 i__1 = *n - 1;
00330 for (j = 1; j <= i__1; ++j) {
00331 if (*kband == 1) {
00332 work[(*n + 1) * j] = (1.f - tau[j]) * e[j];
00333 i__2 = j - 1;
00334 for (jr = 1; jr <= i__2; ++jr) {
00335 work[j * *n + jr] = -tau[j] * e[j] * v[jr + (j + 1) *
00336 v_dim1];
00337
00338 }
00339 }
00340
00341 vsave = v[j + (j + 1) * v_dim1];
00342 v[j + (j + 1) * v_dim1] = 1.f;
00343
00344 i__2 = *n;
00345 slarfy_("U", &j, &v[(j + 1) * v_dim1 + 1], &c__1, &tau[j], &
00346 work[1], n, &work[i__2 * i__2 + 1]);
00347 v[j + (j + 1) * v_dim1] = vsave;
00348 work[(*n + 1) * j + 1] = d__[j + 1];
00349
00350 }
00351 }
00352
00353 i__1 = *n;
00354 for (jcol = 1; jcol <= i__1; ++jcol) {
00355 if (lower) {
00356 i__2 = *n;
00357 for (jrow = jcol; jrow <= i__2; ++jrow) {
00358 work[jrow + *n * (jcol - 1)] -= a[jrow + jcol * a_dim1];
00359
00360 }
00361 } else {
00362 i__2 = jcol;
00363 for (jrow = 1; jrow <= i__2; ++jrow) {
00364 work[jrow + *n * (jcol - 1)] -= a[jrow + jcol * a_dim1];
00365
00366 }
00367 }
00368
00369 }
00370
00371 i__1 = *n;
00372 wnorm = slansy_("1", cuplo, n, &work[1], n, &work[i__1 * i__1 + 1]);
00373
00374 } else if (*itype == 3) {
00375
00376
00377
00378 if (*n < 2) {
00379 return 0;
00380 }
00381 slacpy_(" ", n, n, &u[u_offset], ldu, &work[1], n);
00382 if (lower) {
00383 i__1 = *n - 1;
00384 i__2 = *n - 1;
00385
00386 i__3 = *n;
00387 sorm2r_("R", "T", n, &i__1, &i__2, &v[v_dim1 + 2], ldv, &tau[1], &
00388 work[*n + 1], n, &work[i__3 * i__3 + 1], &iinfo);
00389 } else {
00390 i__1 = *n - 1;
00391 i__2 = *n - 1;
00392
00393 i__3 = *n;
00394 sorm2l_("R", "T", n, &i__1, &i__2, &v[(v_dim1 << 1) + 1], ldv, &
00395 tau[1], &work[1], n, &work[i__3 * i__3 + 1], &iinfo);
00396 }
00397 if (iinfo != 0) {
00398 result[1] = 10.f / ulp;
00399 return 0;
00400 }
00401
00402 i__1 = *n;
00403 for (j = 1; j <= i__1; ++j) {
00404 work[(*n + 1) * (j - 1) + 1] += -1.f;
00405
00406 }
00407
00408
00409 i__1 = *n;
00410 wnorm = slange_("1", n, n, &work[1], n, &work[i__1 * i__1 + 1]);
00411 }
00412
00413 if (anorm > wnorm) {
00414 result[1] = wnorm / anorm / (*n * ulp);
00415 } else {
00416 if (anorm < 1.f) {
00417
00418 r__1 = wnorm, r__2 = *n * anorm;
00419 result[1] = dmin(r__1,r__2) / anorm / (*n * ulp);
00420 } else {
00421
00422 r__1 = wnorm / anorm, r__2 = (real) (*n);
00423 result[1] = dmin(r__1,r__2) / (*n * ulp);
00424 }
00425 }
00426
00427
00428
00429
00430
00431 if (*itype == 1) {
00432 sgemm_("N", "C", n, n, n, &c_b42, &u[u_offset], ldu, &u[u_offset],
00433 ldu, &c_b10, &work[1], n);
00434
00435 i__1 = *n;
00436 for (j = 1; j <= i__1; ++j) {
00437 work[(*n + 1) * (j - 1) + 1] += -1.f;
00438
00439 }
00440
00441
00442
00443 i__1 = *n;
00444 r__1 = slange_("1", n, n, &work[1], n, &work[i__1 * i__1 + 1]), r__2 = (real) (*n);
00445 result[2] = dmin(r__1,r__2) / (*n * ulp);
00446 }
00447
00448 return 0;
00449
00450
00451
00452 }