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