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