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 complex c_b1 = {0.f,0.f};
00019 static complex c_b2 = {1.f,0.f};
00020 static integer c__1 = 1;
00021
00022 int chpt21_(integer *itype, char *uplo, integer *n, integer *
00023 kband, complex *ap, real *d__, real *e, complex *u, integer *ldu,
00024 complex *vp, complex *tau, complex *work, real *rwork, real *result)
00025 {
00026
00027 integer u_dim1, u_offset, i__1, i__2, i__3, i__4, i__5, i__6;
00028 real r__1, r__2;
00029 complex q__1, q__2, q__3;
00030
00031
00032 integer j, jp, jr, jp1, lap;
00033 real ulp;
00034 extern int chpr_(char *, integer *, real *, complex *,
00035 integer *, complex *);
00036 real unfl;
00037 complex temp;
00038 extern int chpr2_(char *, integer *, complex *, complex *
00039 , integer *, complex *, integer *, complex *), cgemm_(
00040 char *, char *, integer *, integer *, integer *, complex *,
00041 complex *, integer *, complex *, integer *, complex *, complex *,
00042 integer *);
00043 extern VOID cdotc_(complex *, integer *, complex *, integer
00044 *, complex *, integer *);
00045 extern logical lsame_(char *, char *);
00046 integer iinfo;
00047 real anorm;
00048 extern int ccopy_(integer *, complex *, integer *,
00049 complex *, integer *), chpmv_(char *, integer *, complex *,
00050 complex *, complex *, integer *, complex *, complex *, integer *);
00051 char cuplo[1];
00052 complex vsave;
00053 extern int caxpy_(integer *, complex *, complex *,
00054 integer *, complex *, integer *);
00055 logical lower;
00056 real wnorm;
00057 extern doublereal clange_(char *, integer *, integer *, complex *,
00058 integer *, real *), clanhp_(char *, char *, integer *,
00059 complex *, real *), slamch_(char *);
00060 extern int clacpy_(char *, integer *, integer *, complex
00061 *, integer *, complex *, integer *), claset_(char *,
00062 integer *, integer *, complex *, complex *, complex *, integer *), cupmtr_(char *, char *, char *, integer *, integer *,
00063 complex *, complex *, complex *, integer *, complex *, integer *);
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
00231
00232
00233
00234
00235
00236
00237 --ap;
00238 --d__;
00239 --e;
00240 u_dim1 = *ldu;
00241 u_offset = 1 + u_dim1;
00242 u -= u_offset;
00243 --vp;
00244 --tau;
00245 --work;
00246 --rwork;
00247 --result;
00248
00249
00250 result[1] = 0.f;
00251 if (*itype == 1) {
00252 result[2] = 0.f;
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 = slamch_("Safe minimum");
00269 ulp = slamch_("Epsilon") * slamch_("Base");
00270
00271
00272
00273 if (*itype < 1 || *itype > 3) {
00274 result[1] = 10.f / ulp;
00275 return 0;
00276 }
00277
00278
00279
00280
00281
00282 if (*itype == 3) {
00283 anorm = 1.f;
00284 } else {
00285
00286 r__1 = clanhp_("1", cuplo, n, &ap[1], &rwork[1])
00287 ;
00288 anorm = dmax(r__1,unfl);
00289 }
00290
00291
00292
00293 if (*itype == 1) {
00294
00295
00296
00297 claset_("Full", n, n, &c_b1, &c_b1, &work[1], n);
00298 ccopy_(&lap, &ap[1], &c__1, &work[1], &c__1);
00299
00300 i__1 = *n;
00301 for (j = 1; j <= i__1; ++j) {
00302 r__1 = -d__[j];
00303 chpr_(cuplo, n, &r__1, &u[j * u_dim1 + 1], &c__1, &work[1]);
00304
00305 }
00306
00307 if (*n > 1 && *kband == 1) {
00308 i__1 = *n - 1;
00309 for (j = 1; j <= i__1; ++j) {
00310 i__2 = j;
00311 q__2.r = e[i__2], q__2.i = 0.f;
00312 q__1.r = -q__2.r, q__1.i = -q__2.i;
00313 chpr2_(cuplo, n, &q__1, &u[j * u_dim1 + 1], &c__1, &u[(j - 1)
00314 * u_dim1 + 1], &c__1, &work[1]);
00315
00316 }
00317 }
00318 wnorm = clanhp_("1", cuplo, n, &work[1], &rwork[1]);
00319
00320 } else if (*itype == 2) {
00321
00322
00323
00324 claset_("Full", n, n, &c_b1, &c_b1, &work[1], n);
00325
00326 if (lower) {
00327 i__1 = lap;
00328 i__2 = *n;
00329 work[i__1].r = d__[i__2], work[i__1].i = 0.f;
00330 for (j = *n - 1; j >= 1; --j) {
00331 jp = ((*n << 1) - j) * (j - 1) / 2;
00332 jp1 = jp + *n - j;
00333 if (*kband == 1) {
00334 i__1 = jp + j + 1;
00335 i__2 = j;
00336 q__2.r = 1.f - tau[i__2].r, q__2.i = 0.f - tau[i__2].i;
00337 i__3 = j;
00338 q__1.r = e[i__3] * q__2.r, q__1.i = e[i__3] * q__2.i;
00339 work[i__1].r = q__1.r, work[i__1].i = q__1.i;
00340 i__1 = *n;
00341 for (jr = j + 2; jr <= i__1; ++jr) {
00342 i__2 = jp + jr;
00343 i__3 = j;
00344 q__3.r = -tau[i__3].r, q__3.i = -tau[i__3].i;
00345 i__4 = j;
00346 q__2.r = e[i__4] * q__3.r, q__2.i = e[i__4] * q__3.i;
00347 i__5 = jp + jr;
00348 q__1.r = q__2.r * vp[i__5].r - q__2.i * vp[i__5].i,
00349 q__1.i = q__2.r * vp[i__5].i + q__2.i * vp[
00350 i__5].r;
00351 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00352
00353 }
00354 }
00355
00356 i__1 = j;
00357 if (tau[i__1].r != 0.f || tau[i__1].i != 0.f) {
00358 i__1 = jp + j + 1;
00359 vsave.r = vp[i__1].r, vsave.i = vp[i__1].i;
00360 i__1 = jp + j + 1;
00361 vp[i__1].r = 1.f, vp[i__1].i = 0.f;
00362 i__1 = *n - j;
00363 chpmv_("L", &i__1, &c_b2, &work[jp1 + j + 1], &vp[jp + j
00364 + 1], &c__1, &c_b1, &work[lap + 1], &c__1);
00365 i__1 = j;
00366 q__2.r = tau[i__1].r * -.5f, q__2.i = tau[i__1].i * -.5f;
00367 i__2 = *n - j;
00368 cdotc_(&q__3, &i__2, &work[lap + 1], &c__1, &vp[jp + j +
00369 1], &c__1);
00370 q__1.r = q__2.r * q__3.r - q__2.i * q__3.i, q__1.i =
00371 q__2.r * q__3.i + q__2.i * q__3.r;
00372 temp.r = q__1.r, temp.i = q__1.i;
00373 i__1 = *n - j;
00374 caxpy_(&i__1, &temp, &vp[jp + j + 1], &c__1, &work[lap +
00375 1], &c__1);
00376 i__1 = *n - j;
00377 i__2 = j;
00378 q__1.r = -tau[i__2].r, q__1.i = -tau[i__2].i;
00379 chpr2_("L", &i__1, &q__1, &vp[jp + j + 1], &c__1, &work[
00380 lap + 1], &c__1, &work[jp1 + j + 1]);
00381
00382 i__1 = jp + j + 1;
00383 vp[i__1].r = vsave.r, vp[i__1].i = vsave.i;
00384 }
00385 i__1 = jp + j;
00386 i__2 = j;
00387 work[i__1].r = d__[i__2], work[i__1].i = 0.f;
00388
00389 }
00390 } else {
00391 work[1].r = d__[1], work[1].i = 0.f;
00392 i__1 = *n - 1;
00393 for (j = 1; j <= i__1; ++j) {
00394 jp = j * (j - 1) / 2;
00395 jp1 = jp + j;
00396 if (*kband == 1) {
00397 i__2 = jp1 + j;
00398 i__3 = j;
00399 q__2.r = 1.f - tau[i__3].r, q__2.i = 0.f - tau[i__3].i;
00400 i__4 = j;
00401 q__1.r = e[i__4] * q__2.r, q__1.i = e[i__4] * q__2.i;
00402 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00403 i__2 = j - 1;
00404 for (jr = 1; jr <= i__2; ++jr) {
00405 i__3 = jp1 + jr;
00406 i__4 = j;
00407 q__3.r = -tau[i__4].r, q__3.i = -tau[i__4].i;
00408 i__5 = j;
00409 q__2.r = e[i__5] * q__3.r, q__2.i = e[i__5] * q__3.i;
00410 i__6 = jp1 + jr;
00411 q__1.r = q__2.r * vp[i__6].r - q__2.i * vp[i__6].i,
00412 q__1.i = q__2.r * vp[i__6].i + q__2.i * vp[
00413 i__6].r;
00414 work[i__3].r = q__1.r, work[i__3].i = q__1.i;
00415
00416 }
00417 }
00418
00419 i__2 = j;
00420 if (tau[i__2].r != 0.f || tau[i__2].i != 0.f) {
00421 i__2 = jp1 + j;
00422 vsave.r = vp[i__2].r, vsave.i = vp[i__2].i;
00423 i__2 = jp1 + j;
00424 vp[i__2].r = 1.f, vp[i__2].i = 0.f;
00425 chpmv_("U", &j, &c_b2, &work[1], &vp[jp1 + 1], &c__1, &
00426 c_b1, &work[lap + 1], &c__1);
00427 i__2 = j;
00428 q__2.r = tau[i__2].r * -.5f, q__2.i = tau[i__2].i * -.5f;
00429 cdotc_(&q__3, &j, &work[lap + 1], &c__1, &vp[jp1 + 1], &
00430 c__1);
00431 q__1.r = q__2.r * q__3.r - q__2.i * q__3.i, q__1.i =
00432 q__2.r * q__3.i + q__2.i * q__3.r;
00433 temp.r = q__1.r, temp.i = q__1.i;
00434 caxpy_(&j, &temp, &vp[jp1 + 1], &c__1, &work[lap + 1], &
00435 c__1);
00436 i__2 = j;
00437 q__1.r = -tau[i__2].r, q__1.i = -tau[i__2].i;
00438 chpr2_("U", &j, &q__1, &vp[jp1 + 1], &c__1, &work[lap + 1]
00439 , &c__1, &work[1]);
00440 i__2 = jp1 + j;
00441 vp[i__2].r = vsave.r, vp[i__2].i = vsave.i;
00442 }
00443 i__2 = jp1 + j + 1;
00444 i__3 = j + 1;
00445 work[i__2].r = d__[i__3], work[i__2].i = 0.f;
00446
00447 }
00448 }
00449
00450 i__1 = lap;
00451 for (j = 1; j <= i__1; ++j) {
00452 i__2 = j;
00453 i__3 = j;
00454 i__4 = j;
00455 q__1.r = work[i__3].r - ap[i__4].r, q__1.i = work[i__3].i - ap[
00456 i__4].i;
00457 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00458
00459 }
00460 wnorm = clanhp_("1", cuplo, n, &work[1], &rwork[1]);
00461
00462 } else if (*itype == 3) {
00463
00464
00465
00466 if (*n < 2) {
00467 return 0;
00468 }
00469 clacpy_(" ", n, n, &u[u_offset], ldu, &work[1], n);
00470
00471 i__1 = *n;
00472 cupmtr_("R", cuplo, "C", n, n, &vp[1], &tau[1], &work[1], n, &work[
00473 i__1 * i__1 + 1], &iinfo);
00474 if (iinfo != 0) {
00475 result[1] = 10.f / ulp;
00476 return 0;
00477 }
00478
00479 i__1 = *n;
00480 for (j = 1; j <= i__1; ++j) {
00481 i__2 = (*n + 1) * (j - 1) + 1;
00482 i__3 = (*n + 1) * (j - 1) + 1;
00483 q__1.r = work[i__3].r - 1.f, q__1.i = work[i__3].i - 0.f;
00484 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00485
00486 }
00487
00488 wnorm = clange_("1", n, n, &work[1], n, &rwork[1]);
00489 }
00490
00491 if (anorm > wnorm) {
00492 result[1] = wnorm / anorm / (*n * ulp);
00493 } else {
00494 if (anorm < 1.f) {
00495
00496 r__1 = wnorm, r__2 = *n * anorm;
00497 result[1] = dmin(r__1,r__2) / anorm / (*n * ulp);
00498 } else {
00499
00500 r__1 = wnorm / anorm, r__2 = (real) (*n);
00501 result[1] = dmin(r__1,r__2) / (*n * ulp);
00502 }
00503 }
00504
00505
00506
00507
00508
00509 if (*itype == 1) {
00510 cgemm_("N", "C", n, n, n, &c_b2, &u[u_offset], ldu, &u[u_offset], ldu,
00511 &c_b1, &work[1], n);
00512
00513 i__1 = *n;
00514 for (j = 1; j <= i__1; ++j) {
00515 i__2 = (*n + 1) * (j - 1) + 1;
00516 i__3 = (*n + 1) * (j - 1) + 1;
00517 q__1.r = work[i__3].r - 1.f, q__1.i = work[i__3].i - 0.f;
00518 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00519
00520 }
00521
00522
00523 r__1 = clange_("1", n, n, &work[1], n, &rwork[1]), r__2 = (
00524 real) (*n);
00525 result[2] = dmin(r__1,r__2) / (*n * ulp);
00526 }
00527
00528 return 0;
00529
00530
00531
00532 }