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