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 complex c_b1 = {0.f,0.f};
00019 static complex c_b2 = {1.f,0.f};
00020
00021 int chet01_(char *uplo, integer *n, complex *a, integer *lda,
00022 complex *afac, integer *ldafac, integer *ipiv, complex *c__, integer
00023 *ldc, real *rwork, real *resid)
00024 {
00025
00026 integer a_dim1, a_offset, afac_dim1, afac_offset, c_dim1, c_offset, i__1,
00027 i__2, i__3, i__4, i__5;
00028 real r__1;
00029 complex q__1;
00030
00031
00032 double r_imag(complex *);
00033
00034
00035 integer i__, j;
00036 real eps;
00037 integer info;
00038 extern logical lsame_(char *, char *);
00039 real anorm;
00040 extern doublereal clanhe_(char *, char *, integer *, complex *, integer *,
00041 real *);
00042 extern int clavhe_(char *, char *, char *, integer *,
00043 integer *, complex *, integer *, integer *, complex *, integer *,
00044 integer *);
00045 extern doublereal slamch_(char *);
00046 extern int claset_(char *, integer *, integer *, complex
00047 *, complex *, 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 a_dim1 = *lda;
00128 a_offset = 1 + a_dim1;
00129 a -= a_offset;
00130 afac_dim1 = *ldafac;
00131 afac_offset = 1 + afac_dim1;
00132 afac -= afac_offset;
00133 --ipiv;
00134 c_dim1 = *ldc;
00135 c_offset = 1 + c_dim1;
00136 c__ -= c_offset;
00137 --rwork;
00138
00139
00140 if (*n <= 0) {
00141 *resid = 0.f;
00142 return 0;
00143 }
00144
00145
00146
00147 eps = slamch_("Epsilon");
00148 anorm = clanhe_("1", uplo, n, &a[a_offset], lda, &rwork[1]);
00149
00150
00151
00152
00153 i__1 = *n;
00154 for (j = 1; j <= i__1; ++j) {
00155 if (r_imag(&afac[j + j * afac_dim1]) != 0.f) {
00156 *resid = 1.f / eps;
00157 return 0;
00158 }
00159
00160 }
00161
00162
00163
00164 claset_("Full", n, n, &c_b1, &c_b2, &c__[c_offset], ldc);
00165
00166
00167
00168 clavhe_(uplo, "Conjugate", "Non-unit", n, n, &afac[afac_offset], ldafac, &
00169 ipiv[1], &c__[c_offset], ldc, &info);
00170
00171
00172
00173 clavhe_(uplo, "No transpose", "Unit", n, n, &afac[afac_offset], ldafac, &
00174 ipiv[1], &c__[c_offset], ldc, &info);
00175
00176
00177
00178 if (lsame_(uplo, "U")) {
00179 i__1 = *n;
00180 for (j = 1; j <= i__1; ++j) {
00181 i__2 = j - 1;
00182 for (i__ = 1; i__ <= i__2; ++i__) {
00183 i__3 = i__ + j * c_dim1;
00184 i__4 = i__ + j * c_dim1;
00185 i__5 = i__ + j * a_dim1;
00186 q__1.r = c__[i__4].r - a[i__5].r, q__1.i = c__[i__4].i - a[
00187 i__5].i;
00188 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00189
00190 }
00191 i__2 = j + j * c_dim1;
00192 i__3 = j + j * c_dim1;
00193 i__4 = j + j * a_dim1;
00194 r__1 = a[i__4].r;
00195 q__1.r = c__[i__3].r - r__1, q__1.i = c__[i__3].i;
00196 c__[i__2].r = q__1.r, c__[i__2].i = q__1.i;
00197
00198 }
00199 } else {
00200 i__1 = *n;
00201 for (j = 1; j <= i__1; ++j) {
00202 i__2 = j + j * c_dim1;
00203 i__3 = j + j * c_dim1;
00204 i__4 = j + j * a_dim1;
00205 r__1 = a[i__4].r;
00206 q__1.r = c__[i__3].r - r__1, q__1.i = c__[i__3].i;
00207 c__[i__2].r = q__1.r, c__[i__2].i = q__1.i;
00208 i__2 = *n;
00209 for (i__ = j + 1; i__ <= i__2; ++i__) {
00210 i__3 = i__ + j * c_dim1;
00211 i__4 = i__ + j * c_dim1;
00212 i__5 = i__ + j * a_dim1;
00213 q__1.r = c__[i__4].r - a[i__5].r, q__1.i = c__[i__4].i - a[
00214 i__5].i;
00215 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00216
00217 }
00218
00219 }
00220 }
00221
00222
00223
00224 *resid = clanhe_("1", uplo, n, &c__[c_offset], ldc, &rwork[1]);
00225
00226 if (anorm <= 0.f) {
00227 if (*resid != 0.f) {
00228 *resid = 1.f / eps;
00229 }
00230 } else {
00231 *resid = *resid / (real) (*n) / anorm / eps;
00232 }
00233
00234 return 0;
00235
00236
00237
00238 }