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 real c_b17 = 1.f;
00020
00021 int cpbt01_(char *uplo, integer *n, integer *kd, complex *a,
00022 integer *lda, complex *afac, integer *ldafac, real *rwork, real *
00023 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 complex q__1;
00029
00030
00031 double r_imag(complex *);
00032
00033
00034 integer i__, j, k, kc, ml, mu;
00035 real akk, eps;
00036 extern int cher_(char *, integer *, real *, complex *,
00037 integer *, complex *, integer *);
00038 integer klen;
00039 extern VOID cdotc_(complex *, integer *, complex *, integer
00040 *, complex *, integer *);
00041 extern logical lsame_(char *, char *);
00042 real anorm;
00043 extern int ctrmv_(char *, char *, char *, integer *,
00044 complex *, integer *, complex *, integer *);
00045 extern doublereal clanhb_(char *, char *, integer *, integer *, complex *,
00046 integer *, real *), slamch_(char *);
00047 extern int csscal_(integer *, real *, complex *, integer
00048 *);
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.f;
00141 return 0;
00142 }
00143
00144
00145
00146 eps = slamch_("Epsilon");
00147 anorm = clanhb_("1", uplo, n, kd, &a[a_offset], lda, &rwork[1]);
00148 if (anorm <= 0.f) {
00149 *resid = 1.f / 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 (r_imag(&afac[*kd + 1 + j * afac_dim1]) != 0.f) {
00160 *resid = 1.f / eps;
00161 return 0;
00162 }
00163
00164 }
00165 } else {
00166 i__1 = *n;
00167 for (j = 1; j <= i__1; ++j) {
00168 if (r_imag(&afac[j * afac_dim1 + 1]) != 0.f) {
00169 *resid = 1.f / 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 cdotc_(&q__1, &i__1, &afac[kc + k * afac_dim1], &c__1, &afac[kc +
00189 k * afac_dim1], &c__1);
00190 akk = q__1.r;
00191 i__1 = *kd + 1 + k * afac_dim1;
00192 afac[i__1].r = akk, afac[i__1].i = 0.f;
00193
00194
00195
00196 if (klen > 0) {
00197 i__1 = *ldafac - 1;
00198 ctrmv_("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 cher_("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 csscal_(&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 q__1.r = afac[i__4].r - a[i__5].r, q__1.i = afac[i__4].i - a[
00248 i__5].i;
00249 afac[i__3].r = q__1.r, afac[i__3].i = q__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 q__1.r = afac[i__4].r - a[i__5].r, q__1.i = afac[i__4].i - a[
00266 i__5].i;
00267 afac[i__3].r = q__1.r, afac[i__3].i = q__1.i;
00268
00269 }
00270
00271 }
00272 }
00273
00274
00275
00276 *resid = clanhb_("1", uplo, n, kd, &afac[afac_offset], ldafac, &rwork[1]);
00277
00278 *resid = *resid / (real) (*n) / anorm / eps;
00279
00280 return 0;
00281
00282
00283
00284 }