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 doublecomplex c_b1 = {0.,0.};
00019 static doublecomplex c_b2 = {1.,0.};
00020
00021 int zhet01_(char *uplo, integer *n, doublecomplex *a,
00022 integer *lda, doublecomplex *afac, integer *ldafac, integer *ipiv,
00023 doublecomplex *c__, integer *ldc, doublereal *rwork, doublereal *
00024 resid)
00025 {
00026
00027 integer a_dim1, a_offset, afac_dim1, afac_offset, c_dim1, c_offset, i__1,
00028 i__2, i__3, i__4, i__5;
00029 doublereal d__1;
00030 doublecomplex z__1;
00031
00032
00033 double d_imag(doublecomplex *);
00034
00035
00036 integer i__, j;
00037 doublereal eps;
00038 integer info;
00039 extern logical lsame_(char *, char *);
00040 doublereal anorm;
00041 extern doublereal dlamch_(char *), zlanhe_(char *, char *,
00042 integer *, doublecomplex *, integer *, doublereal *);
00043 extern int zlavhe_(char *, char *, char *, integer *,
00044 integer *, doublecomplex *, integer *, integer *, doublecomplex *,
00045 integer *, integer *), zlaset_(char *,
00046 integer *, integer *, doublecomplex *, doublecomplex *,
00047 doublecomplex *, 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.;
00142 return 0;
00143 }
00144
00145
00146
00147 eps = dlamch_("Epsilon");
00148 anorm = zlanhe_("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 (d_imag(&afac[j + j * afac_dim1]) != 0.) {
00156 *resid = 1. / eps;
00157 return 0;
00158 }
00159
00160 }
00161
00162
00163
00164 zlaset_("Full", n, n, &c_b1, &c_b2, &c__[c_offset], ldc);
00165
00166
00167
00168 zlavhe_(uplo, "Conjugate", "Non-unit", n, n, &afac[afac_offset], ldafac, &
00169 ipiv[1], &c__[c_offset], ldc, &info);
00170
00171
00172
00173 zlavhe_(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 z__1.r = c__[i__4].r - a[i__5].r, z__1.i = c__[i__4].i - a[
00187 i__5].i;
00188 c__[i__3].r = z__1.r, c__[i__3].i = z__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 d__1 = a[i__4].r;
00195 z__1.r = c__[i__3].r - d__1, z__1.i = c__[i__3].i;
00196 c__[i__2].r = z__1.r, c__[i__2].i = z__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 d__1 = a[i__4].r;
00206 z__1.r = c__[i__3].r - d__1, z__1.i = c__[i__3].i;
00207 c__[i__2].r = z__1.r, c__[i__2].i = z__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 z__1.r = c__[i__4].r - a[i__5].r, z__1.i = c__[i__4].i - a[
00214 i__5].i;
00215 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00216
00217 }
00218
00219 }
00220 }
00221
00222
00223
00224 *resid = zlanhe_("1", uplo, n, &c__[c_offset], ldc, &rwork[1]);
00225
00226 if (anorm <= 0.) {
00227 if (*resid != 0.) {
00228 *resid = 1. / eps;
00229 }
00230 } else {
00231 *resid = *resid / (doublereal) (*n) / anorm / eps;
00232 }
00233
00234 return 0;
00235
00236
00237
00238 }