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_b14 = 1.;
00020
00021 int dpbt01_(char *uplo, integer *n, integer *kd, doublereal *
00022 a, integer *lda, doublereal *afac, integer *ldafac, doublereal *rwork,
00023 doublereal *resid)
00024 {
00025
00026 integer a_dim1, a_offset, afac_dim1, afac_offset, i__1, i__2, i__3;
00027
00028
00029 integer i__, j, k;
00030 doublereal t;
00031 integer kc, ml, mu;
00032 doublereal eps;
00033 integer klen;
00034 extern doublereal ddot_(integer *, doublereal *, integer *, doublereal *,
00035 integer *);
00036 extern int dsyr_(char *, integer *, doublereal *,
00037 doublereal *, integer *, doublereal *, integer *), dscal_(
00038 integer *, doublereal *, doublereal *, integer *);
00039 extern logical lsame_(char *, char *);
00040 doublereal anorm;
00041 extern int dtrmv_(char *, char *, char *, integer *,
00042 doublereal *, integer *, doublereal *, integer *);
00043 extern doublereal dlamch_(char *), dlansb_(char *, char *,
00044 integer *, integer *, doublereal *, integer *, doublereal *);
00045
00046
00047
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 a_dim1 = *lda;
00127 a_offset = 1 + a_dim1;
00128 a -= a_offset;
00129 afac_dim1 = *ldafac;
00130 afac_offset = 1 + afac_dim1;
00131 afac -= afac_offset;
00132 --rwork;
00133
00134
00135 if (*n <= 0) {
00136 *resid = 0.;
00137 return 0;
00138 }
00139
00140
00141
00142 eps = dlamch_("Epsilon");
00143 anorm = dlansb_("1", uplo, n, kd, &a[a_offset], lda, &rwork[1]);
00144 if (anorm <= 0.) {
00145 *resid = 1. / eps;
00146 return 0;
00147 }
00148
00149
00150
00151 if (lsame_(uplo, "U")) {
00152 for (k = *n; k >= 1; --k) {
00153
00154 i__1 = 1, i__2 = *kd + 2 - k;
00155 kc = max(i__1,i__2);
00156 klen = *kd + 1 - kc;
00157
00158
00159
00160 i__1 = klen + 1;
00161 t = ddot_(&i__1, &afac[kc + k * afac_dim1], &c__1, &afac[kc + k *
00162 afac_dim1], &c__1);
00163 afac[*kd + 1 + k * afac_dim1] = t;
00164
00165
00166
00167 if (klen > 0) {
00168 i__1 = *ldafac - 1;
00169 dtrmv_("Upper", "Transpose", "Non-unit", &klen, &afac[*kd + 1
00170 + (k - klen) * afac_dim1], &i__1, &afac[kc + k *
00171 afac_dim1], &c__1);
00172 }
00173
00174
00175 }
00176
00177
00178
00179 } else {
00180 for (k = *n; k >= 1; --k) {
00181
00182 i__1 = *kd, i__2 = *n - k;
00183 klen = min(i__1,i__2);
00184
00185
00186
00187
00188 if (klen > 0) {
00189 i__1 = *ldafac - 1;
00190 dsyr_("Lower", &klen, &c_b14, &afac[k * afac_dim1 + 2], &c__1,
00191 &afac[(k + 1) * afac_dim1 + 1], &i__1);
00192 }
00193
00194
00195
00196 t = afac[k * afac_dim1 + 1];
00197 i__1 = klen + 1;
00198 dscal_(&i__1, &t, &afac[k * afac_dim1 + 1], &c__1);
00199
00200
00201 }
00202 }
00203
00204
00205
00206 if (lsame_(uplo, "U")) {
00207 i__1 = *n;
00208 for (j = 1; j <= i__1; ++j) {
00209
00210 i__2 = 1, i__3 = *kd + 2 - j;
00211 mu = max(i__2,i__3);
00212 i__2 = *kd + 1;
00213 for (i__ = mu; i__ <= i__2; ++i__) {
00214 afac[i__ + j * afac_dim1] -= a[i__ + j * a_dim1];
00215
00216 }
00217
00218 }
00219 } else {
00220 i__1 = *n;
00221 for (j = 1; j <= i__1; ++j) {
00222
00223 i__2 = *kd + 1, i__3 = *n - j + 1;
00224 ml = min(i__2,i__3);
00225 i__2 = ml;
00226 for (i__ = 1; i__ <= i__2; ++i__) {
00227 afac[i__ + j * afac_dim1] -= a[i__ + j * a_dim1];
00228
00229 }
00230
00231 }
00232 }
00233
00234
00235
00236 *resid = dlansb_("I", uplo, n, kd, &afac[afac_offset], ldafac, &rwork[1]);
00237
00238 *resid = *resid / (doublereal) (*n) / anorm / eps;
00239
00240 return 0;
00241
00242
00243
00244 }