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_b15 = 1.;
00020
00021 int zpot01_(char *uplo, integer *n, doublecomplex *a,
00022 integer *lda, doublecomplex *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, i__4,
00027 i__5;
00028 doublereal d__1;
00029 doublecomplex z__1;
00030
00031
00032 double d_imag(doublecomplex *);
00033
00034
00035 integer i__, j, k;
00036 doublecomplex tc;
00037 doublereal tr, eps;
00038 extern int zher_(char *, integer *, doublereal *,
00039 doublecomplex *, integer *, doublecomplex *, integer *);
00040 extern logical lsame_(char *, char *);
00041 doublereal anorm;
00042 extern int zscal_(integer *, doublecomplex *,
00043 doublecomplex *, integer *);
00044 extern VOID zdotc_(doublecomplex *, integer *,
00045 doublecomplex *, integer *, doublecomplex *, integer *);
00046 extern int ztrmv_(char *, char *, char *, integer *,
00047 doublecomplex *, integer *, doublecomplex *, integer *);
00048 extern doublereal dlamch_(char *), zlanhe_(char *, char *,
00049 integer *, doublecomplex *, integer *, doublereal *);
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 a_dim1 = *lda;
00122 a_offset = 1 + a_dim1;
00123 a -= a_offset;
00124 afac_dim1 = *ldafac;
00125 afac_offset = 1 + afac_dim1;
00126 afac -= afac_offset;
00127 --rwork;
00128
00129
00130 if (*n <= 0) {
00131 *resid = 0.;
00132 return 0;
00133 }
00134
00135
00136
00137 eps = dlamch_("Epsilon");
00138 anorm = zlanhe_("1", uplo, n, &a[a_offset], lda, &rwork[1]);
00139 if (anorm <= 0.) {
00140 *resid = 1. / eps;
00141 return 0;
00142 }
00143
00144
00145
00146
00147 i__1 = *n;
00148 for (j = 1; j <= i__1; ++j) {
00149 if (d_imag(&afac[j + j * afac_dim1]) != 0.) {
00150 *resid = 1. / eps;
00151 return 0;
00152 }
00153
00154 }
00155
00156
00157
00158 if (lsame_(uplo, "U")) {
00159 for (k = *n; k >= 1; --k) {
00160
00161
00162
00163 zdotc_(&z__1, &k, &afac[k * afac_dim1 + 1], &c__1, &afac[k *
00164 afac_dim1 + 1], &c__1);
00165 tr = z__1.r;
00166 i__1 = k + k * afac_dim1;
00167 afac[i__1].r = tr, afac[i__1].i = 0.;
00168
00169
00170
00171 i__1 = k - 1;
00172 ztrmv_("Upper", "Conjugate", "Non-unit", &i__1, &afac[afac_offset]
00173 , ldafac, &afac[k * afac_dim1 + 1], &c__1);
00174
00175
00176 }
00177
00178
00179
00180 } else {
00181 for (k = *n; k >= 1; --k) {
00182
00183
00184
00185
00186 if (k + 1 <= *n) {
00187 i__1 = *n - k;
00188 zher_("Lower", &i__1, &c_b15, &afac[k + 1 + k * afac_dim1], &
00189 c__1, &afac[k + 1 + (k + 1) * afac_dim1], ldafac);
00190 }
00191
00192
00193
00194 i__1 = k + k * afac_dim1;
00195 tc.r = afac[i__1].r, tc.i = afac[i__1].i;
00196 i__1 = *n - k + 1;
00197 zscal_(&i__1, &tc, &afac[k + k * afac_dim1], &c__1);
00198
00199
00200 }
00201 }
00202
00203
00204
00205 if (lsame_(uplo, "U")) {
00206 i__1 = *n;
00207 for (j = 1; j <= i__1; ++j) {
00208 i__2 = j - 1;
00209 for (i__ = 1; i__ <= i__2; ++i__) {
00210 i__3 = i__ + j * afac_dim1;
00211 i__4 = i__ + j * afac_dim1;
00212 i__5 = i__ + j * a_dim1;
00213 z__1.r = afac[i__4].r - a[i__5].r, z__1.i = afac[i__4].i - a[
00214 i__5].i;
00215 afac[i__3].r = z__1.r, afac[i__3].i = z__1.i;
00216
00217 }
00218 i__2 = j + j * afac_dim1;
00219 i__3 = j + j * afac_dim1;
00220 i__4 = j + j * a_dim1;
00221 d__1 = a[i__4].r;
00222 z__1.r = afac[i__3].r - d__1, z__1.i = afac[i__3].i;
00223 afac[i__2].r = z__1.r, afac[i__2].i = z__1.i;
00224
00225 }
00226 } else {
00227 i__1 = *n;
00228 for (j = 1; j <= i__1; ++j) {
00229 i__2 = j + j * afac_dim1;
00230 i__3 = j + j * afac_dim1;
00231 i__4 = j + j * a_dim1;
00232 d__1 = a[i__4].r;
00233 z__1.r = afac[i__3].r - d__1, z__1.i = afac[i__3].i;
00234 afac[i__2].r = z__1.r, afac[i__2].i = z__1.i;
00235 i__2 = *n;
00236 for (i__ = j + 1; i__ <= i__2; ++i__) {
00237 i__3 = i__ + j * afac_dim1;
00238 i__4 = i__ + j * afac_dim1;
00239 i__5 = i__ + j * a_dim1;
00240 z__1.r = afac[i__4].r - a[i__5].r, z__1.i = afac[i__4].i - a[
00241 i__5].i;
00242 afac[i__3].r = z__1.r, afac[i__3].i = z__1.i;
00243
00244 }
00245
00246 }
00247 }
00248
00249
00250
00251 *resid = zlanhe_("1", uplo, n, &afac[afac_offset], ldafac, &rwork[1]);
00252
00253 *resid = *resid / (doublereal) (*n) / anorm / eps;
00254
00255 return 0;
00256
00257
00258
00259 }