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