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