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 doublecomplex c_b1 = {0.,0.};
00019 static doublecomplex c_b2 = {1.,0.};
00020 static integer c__1 = 1;
00021
00022 int zhbt21_(char *uplo, integer *n, integer *ka, integer *ks,
00023 doublecomplex *a, integer *lda, doublereal *d__, doublereal *e,
00024 doublecomplex *u, integer *ldu, doublecomplex *work, doublereal *
00025 rwork, doublereal *result)
00026 {
00027
00028 integer a_dim1, a_offset, u_dim1, u_offset, i__1, i__2, i__3, i__4;
00029 doublereal d__1, d__2;
00030 doublecomplex z__1, z__2;
00031
00032
00033 integer j, jc, jr, ika;
00034 doublereal ulp, unfl;
00035 extern int zhpr_(char *, integer *, doublereal *,
00036 doublecomplex *, integer *, doublecomplex *), zhpr2_(char
00037 *, integer *, doublecomplex *, doublecomplex *, integer *,
00038 doublecomplex *, integer *, doublecomplex *);
00039 extern logical lsame_(char *, char *);
00040 doublereal anorm;
00041 extern int zgemm_(char *, char *, integer *, integer *,
00042 integer *, doublecomplex *, doublecomplex *, integer *,
00043 doublecomplex *, integer *, doublecomplex *, doublecomplex *,
00044 integer *);
00045 char cuplo[1];
00046 logical lower;
00047 doublereal wnorm;
00048 extern doublereal dlamch_(char *), zlanhb_(char *, char *,
00049 integer *, integer *, doublecomplex *, integer *, doublereal *), zlange_(char *, integer *, integer *,
00050 doublecomplex *, integer *, doublereal *), zlanhp_(char *,
00051 char *, integer *, doublecomplex *, doublereal *)
00052 ;
00053
00054
00055
00056
00057
00058
00059
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 a_dim1 = *lda;
00155 a_offset = 1 + a_dim1;
00156 a -= a_offset;
00157 --d__;
00158 --e;
00159 u_dim1 = *ldu;
00160 u_offset = 1 + u_dim1;
00161 u -= u_offset;
00162 --work;
00163 --rwork;
00164 --result;
00165
00166
00167 result[1] = 0.;
00168 result[2] = 0.;
00169 if (*n <= 0) {
00170 return 0;
00171 }
00172
00173
00174
00175 i__3 = *n - 1;
00176 i__1 = 0, i__2 = min(i__3,*ka);
00177 ika = max(i__1,i__2);
00178
00179 if (lsame_(uplo, "U")) {
00180 lower = FALSE_;
00181 *(unsigned char *)cuplo = 'U';
00182 } else {
00183 lower = TRUE_;
00184 *(unsigned char *)cuplo = 'L';
00185 }
00186
00187 unfl = dlamch_("Safe minimum");
00188 ulp = dlamch_("Epsilon") * dlamch_("Base");
00189
00190
00191
00192
00193
00194
00195
00196
00197 d__1 = zlanhb_("1", cuplo, n, &ika, &a[a_offset], lda, &rwork[1]);
00198 anorm = max(d__1,unfl);
00199
00200
00201
00202
00203
00204 j = 0;
00205 i__1 = *n;
00206 for (jc = 1; jc <= i__1; ++jc) {
00207 if (lower) {
00208
00209 i__3 = ika + 1, i__4 = *n + 1 - jc;
00210 i__2 = min(i__3,i__4);
00211 for (jr = 1; jr <= i__2; ++jr) {
00212 ++j;
00213 i__3 = j;
00214 i__4 = jr + jc * a_dim1;
00215 work[i__3].r = a[i__4].r, work[i__3].i = a[i__4].i;
00216
00217 }
00218 i__2 = *n + 1 - jc;
00219 for (jr = ika + 2; jr <= i__2; ++jr) {
00220 ++j;
00221 i__3 = j;
00222 work[i__3].r = 0., work[i__3].i = 0.;
00223
00224 }
00225 } else {
00226 i__2 = jc;
00227 for (jr = ika + 2; jr <= i__2; ++jr) {
00228 ++j;
00229 i__3 = j;
00230 work[i__3].r = 0., work[i__3].i = 0.;
00231
00232 }
00233
00234 i__2 = ika, i__3 = jc - 1;
00235 for (jr = min(i__2,i__3); jr >= 0; --jr) {
00236 ++j;
00237 i__2 = j;
00238 i__3 = ika + 1 - jr + jc * a_dim1;
00239 work[i__2].r = a[i__3].r, work[i__2].i = a[i__3].i;
00240
00241 }
00242 }
00243
00244 }
00245
00246 i__1 = *n;
00247 for (j = 1; j <= i__1; ++j) {
00248 d__1 = -d__[j];
00249 zhpr_(cuplo, n, &d__1, &u[j * u_dim1 + 1], &c__1, &work[1])
00250 ;
00251
00252 }
00253
00254 if (*n > 1 && *ks == 1) {
00255 i__1 = *n - 1;
00256 for (j = 1; j <= i__1; ++j) {
00257 i__2 = j;
00258 z__2.r = e[i__2], z__2.i = 0.;
00259 z__1.r = -z__2.r, z__1.i = -z__2.i;
00260 zhpr2_(cuplo, n, &z__1, &u[j * u_dim1 + 1], &c__1, &u[(j + 1) *
00261 u_dim1 + 1], &c__1, &work[1]);
00262
00263 }
00264 }
00265 wnorm = zlanhp_("1", cuplo, n, &work[1], &rwork[1]);
00266
00267 if (anorm > wnorm) {
00268 result[1] = wnorm / anorm / (*n * ulp);
00269 } else {
00270 if (anorm < 1.) {
00271
00272 d__1 = wnorm, d__2 = *n * anorm;
00273 result[1] = min(d__1,d__2) / anorm / (*n * ulp);
00274 } else {
00275
00276 d__1 = wnorm / anorm, d__2 = (doublereal) (*n);
00277 result[1] = min(d__1,d__2) / (*n * ulp);
00278 }
00279 }
00280
00281
00282
00283
00284
00285 zgemm_("N", "C", n, n, n, &c_b2, &u[u_offset], ldu, &u[u_offset], ldu, &
00286 c_b1, &work[1], n);
00287
00288 i__1 = *n;
00289 for (j = 1; j <= i__1; ++j) {
00290 i__2 = (*n + 1) * (j - 1) + 1;
00291 i__3 = (*n + 1) * (j - 1) + 1;
00292 z__1.r = work[i__3].r - 1., z__1.i = work[i__3].i - 0.;
00293 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00294
00295 }
00296
00297
00298 d__1 = zlange_("1", n, n, &work[1], n, &rwork[1]), d__2 = (
00299 doublereal) (*n);
00300 result[2] = min(d__1,d__2) / (*n * ulp);
00301
00302 return 0;
00303
00304
00305
00306 }