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 integer c__1 = 1;
00019 static doublereal c_b17 = 1.;
00020
00021 int zpbt01_(char *uplo, integer *n, integer *kd,
00022 doublecomplex *a, integer *lda, doublecomplex *afac, integer *ldafac,
00023 doublereal *rwork, doublereal *resid)
00024 {
00025
00026 integer a_dim1, a_offset, afac_dim1, afac_offset, i__1, i__2, i__3, i__4,
00027 i__5;
00028 doublecomplex z__1;
00029
00030
00031 double d_imag(doublecomplex *);
00032
00033
00034 integer i__, j, k, kc, ml, mu;
00035 doublereal akk, eps;
00036 integer klen;
00037 extern int zher_(char *, integer *, doublereal *,
00038 doublecomplex *, integer *, doublecomplex *, integer *);
00039 extern logical lsame_(char *, char *);
00040 doublereal anorm;
00041 extern VOID zdotc_(doublecomplex *, integer *,
00042 doublecomplex *, integer *, doublecomplex *, integer *);
00043 extern int ztrmv_(char *, char *, char *, integer *,
00044 doublecomplex *, integer *, doublecomplex *, integer *);
00045 extern doublereal dlamch_(char *), zlanhb_(char *, char *,
00046 integer *, integer *, doublecomplex *, integer *, doublereal *);
00047 extern int zdscal_(integer *, doublereal *,
00048 doublecomplex *, integer *);
00049
00050
00051
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 a_dim1 = *lda;
00131 a_offset = 1 + a_dim1;
00132 a -= a_offset;
00133 afac_dim1 = *ldafac;
00134 afac_offset = 1 + afac_dim1;
00135 afac -= afac_offset;
00136 --rwork;
00137
00138
00139 if (*n <= 0) {
00140 *resid = 0.;
00141 return 0;
00142 }
00143
00144
00145
00146 eps = dlamch_("Epsilon");
00147 anorm = zlanhb_("1", uplo, n, kd, &a[a_offset], lda, &rwork[1]);
00148 if (anorm <= 0.) {
00149 *resid = 1. / eps;
00150 return 0;
00151 }
00152
00153
00154
00155
00156 if (lsame_(uplo, "U")) {
00157 i__1 = *n;
00158 for (j = 1; j <= i__1; ++j) {
00159 if (d_imag(&afac[*kd + 1 + j * afac_dim1]) != 0.) {
00160 *resid = 1. / eps;
00161 return 0;
00162 }
00163
00164 }
00165 } else {
00166 i__1 = *n;
00167 for (j = 1; j <= i__1; ++j) {
00168 if (d_imag(&afac[j * afac_dim1 + 1]) != 0.) {
00169 *resid = 1. / eps;
00170 return 0;
00171 }
00172
00173 }
00174 }
00175
00176
00177
00178 if (lsame_(uplo, "U")) {
00179 for (k = *n; k >= 1; --k) {
00180
00181 i__1 = 1, i__2 = *kd + 2 - k;
00182 kc = max(i__1,i__2);
00183 klen = *kd + 1 - kc;
00184
00185
00186
00187 i__1 = klen + 1;
00188 zdotc_(&z__1, &i__1, &afac[kc + k * afac_dim1], &c__1, &afac[kc +
00189 k * afac_dim1], &c__1);
00190 akk = z__1.r;
00191 i__1 = *kd + 1 + k * afac_dim1;
00192 afac[i__1].r = akk, afac[i__1].i = 0.;
00193
00194
00195
00196 if (klen > 0) {
00197 i__1 = *ldafac - 1;
00198 ztrmv_("Upper", "Conjugate", "Non-unit", &klen, &afac[*kd + 1
00199 + (k - klen) * afac_dim1], &i__1, &afac[kc + k *
00200 afac_dim1], &c__1);
00201 }
00202
00203
00204 }
00205
00206
00207
00208 } else {
00209 for (k = *n; k >= 1; --k) {
00210
00211 i__1 = *kd, i__2 = *n - k;
00212 klen = min(i__1,i__2);
00213
00214
00215
00216
00217 if (klen > 0) {
00218 i__1 = *ldafac - 1;
00219 zher_("Lower", &klen, &c_b17, &afac[k * afac_dim1 + 2], &c__1,
00220 &afac[(k + 1) * afac_dim1 + 1], &i__1);
00221 }
00222
00223
00224
00225 i__1 = k * afac_dim1 + 1;
00226 akk = afac[i__1].r;
00227 i__1 = klen + 1;
00228 zdscal_(&i__1, &akk, &afac[k * afac_dim1 + 1], &c__1);
00229
00230
00231 }
00232 }
00233
00234
00235
00236 if (lsame_(uplo, "U")) {
00237 i__1 = *n;
00238 for (j = 1; j <= i__1; ++j) {
00239
00240 i__2 = 1, i__3 = *kd + 2 - j;
00241 mu = max(i__2,i__3);
00242 i__2 = *kd + 1;
00243 for (i__ = mu; i__ <= i__2; ++i__) {
00244 i__3 = i__ + j * afac_dim1;
00245 i__4 = i__ + j * afac_dim1;
00246 i__5 = i__ + j * a_dim1;
00247 z__1.r = afac[i__4].r - a[i__5].r, z__1.i = afac[i__4].i - a[
00248 i__5].i;
00249 afac[i__3].r = z__1.r, afac[i__3].i = z__1.i;
00250
00251 }
00252
00253 }
00254 } else {
00255 i__1 = *n;
00256 for (j = 1; j <= i__1; ++j) {
00257
00258 i__2 = *kd + 1, i__3 = *n - j + 1;
00259 ml = min(i__2,i__3);
00260 i__2 = ml;
00261 for (i__ = 1; i__ <= i__2; ++i__) {
00262 i__3 = i__ + j * afac_dim1;
00263 i__4 = i__ + j * afac_dim1;
00264 i__5 = i__ + j * a_dim1;
00265 z__1.r = afac[i__4].r - a[i__5].r, z__1.i = afac[i__4].i - a[
00266 i__5].i;
00267 afac[i__3].r = z__1.r, afac[i__3].i = z__1.i;
00268
00269 }
00270
00271 }
00272 }
00273
00274
00275
00276 *resid = zlanhb_("1", uplo, n, kd, &afac[afac_offset], ldafac, &rwork[1]);
00277
00278 *resid = *resid / (doublereal) (*n) / anorm / eps;
00279
00280 return 0;
00281
00282
00283
00284 }