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_b20 = 1.;
00020
00021 int zpst01_(char *uplo, integer *n, doublecomplex *a,
00022 integer *lda, doublecomplex *afac, integer *ldafac, doublecomplex *
00023 perm, integer *ldperm, integer *piv, doublereal *rwork, doublereal *
00024 resid, integer *rank)
00025 {
00026
00027 integer a_dim1, a_offset, afac_dim1, afac_offset, perm_dim1, perm_offset,
00028 i__1, i__2, i__3, i__4, i__5;
00029 doublereal d__1;
00030 doublecomplex z__1;
00031
00032
00033 double d_imag(doublecomplex *);
00034 void d_cnjg(doublecomplex *, doublecomplex *);
00035
00036
00037 integer i__, j, k;
00038 doublecomplex tc;
00039 doublereal tr, eps;
00040 extern int zher_(char *, integer *, doublereal *,
00041 doublecomplex *, integer *, doublecomplex *, integer *);
00042 extern logical lsame_(char *, char *);
00043 doublereal anorm;
00044 extern int zscal_(integer *, doublecomplex *,
00045 doublecomplex *, integer *);
00046 extern VOID zdotc_(doublecomplex *, integer *,
00047 doublecomplex *, integer *, doublecomplex *, integer *);
00048 extern int ztrmv_(char *, char *, char *, integer *,
00049 doublecomplex *, integer *, doublecomplex *, integer *);
00050 extern doublereal dlamch_(char *), zlanhe_(char *, char *,
00051 integer *, doublecomplex *, integer *, doublereal *);
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
00128
00129
00130
00131
00132
00133
00134 a_dim1 = *lda;
00135 a_offset = 1 + a_dim1;
00136 a -= a_offset;
00137 afac_dim1 = *ldafac;
00138 afac_offset = 1 + afac_dim1;
00139 afac -= afac_offset;
00140 perm_dim1 = *ldperm;
00141 perm_offset = 1 + perm_dim1;
00142 perm -= perm_offset;
00143 --piv;
00144 --rwork;
00145
00146
00147 if (*n <= 0) {
00148 *resid = 0.;
00149 return 0;
00150 }
00151
00152
00153
00154 eps = dlamch_("Epsilon");
00155 anorm = zlanhe_("1", uplo, n, &a[a_offset], lda, &rwork[1]);
00156 if (anorm <= 0.) {
00157 *resid = 1. / eps;
00158 return 0;
00159 }
00160
00161
00162
00163
00164 i__1 = *n;
00165 for (j = 1; j <= i__1; ++j) {
00166 if (d_imag(&afac[j + j * afac_dim1]) != 0.) {
00167 *resid = 1. / eps;
00168 return 0;
00169 }
00170
00171 }
00172
00173
00174
00175 if (lsame_(uplo, "U")) {
00176
00177 if (*rank < *n) {
00178 i__1 = *n;
00179 for (j = *rank + 1; j <= i__1; ++j) {
00180 i__2 = j;
00181 for (i__ = *rank + 1; i__ <= i__2; ++i__) {
00182 i__3 = i__ + j * afac_dim1;
00183 afac[i__3].r = 0., afac[i__3].i = 0.;
00184
00185 }
00186
00187 }
00188 }
00189
00190 for (k = *n; k >= 1; --k) {
00191
00192
00193
00194 zdotc_(&z__1, &k, &afac[k * afac_dim1 + 1], &c__1, &afac[k *
00195 afac_dim1 + 1], &c__1);
00196 tr = z__1.r;
00197 i__1 = k + k * afac_dim1;
00198 afac[i__1].r = tr, afac[i__1].i = 0.;
00199
00200
00201
00202 i__1 = k - 1;
00203 ztrmv_("Upper", "Conjugate", "Non-unit", &i__1, &afac[afac_offset]
00204 , ldafac, &afac[k * afac_dim1 + 1], &c__1);
00205
00206
00207 }
00208
00209
00210
00211 } else {
00212
00213 if (*rank < *n) {
00214 i__1 = *n;
00215 for (j = *rank + 1; j <= i__1; ++j) {
00216 i__2 = *n;
00217 for (i__ = j; i__ <= i__2; ++i__) {
00218 i__3 = i__ + j * afac_dim1;
00219 afac[i__3].r = 0., afac[i__3].i = 0.;
00220
00221 }
00222
00223 }
00224 }
00225
00226 for (k = *n; k >= 1; --k) {
00227
00228
00229
00230 if (k + 1 <= *n) {
00231 i__1 = *n - k;
00232 zher_("Lower", &i__1, &c_b20, &afac[k + 1 + k * afac_dim1], &
00233 c__1, &afac[k + 1 + (k + 1) * afac_dim1], ldafac);
00234 }
00235
00236
00237
00238 i__1 = k + k * afac_dim1;
00239 tc.r = afac[i__1].r, tc.i = afac[i__1].i;
00240 i__1 = *n - k + 1;
00241 zscal_(&i__1, &tc, &afac[k + k * afac_dim1], &c__1);
00242
00243 }
00244
00245 }
00246
00247
00248
00249 if (lsame_(uplo, "U")) {
00250
00251 i__1 = *n;
00252 for (j = 1; j <= i__1; ++j) {
00253 i__2 = *n;
00254 for (i__ = 1; i__ <= i__2; ++i__) {
00255 if (piv[i__] <= piv[j]) {
00256 if (i__ <= j) {
00257 i__3 = piv[i__] + piv[j] * perm_dim1;
00258 i__4 = i__ + j * afac_dim1;
00259 perm[i__3].r = afac[i__4].r, perm[i__3].i = afac[i__4]
00260 .i;
00261 } else {
00262 i__3 = piv[i__] + piv[j] * perm_dim1;
00263 d_cnjg(&z__1, &afac[j + i__ * afac_dim1]);
00264 perm[i__3].r = z__1.r, perm[i__3].i = z__1.i;
00265 }
00266 }
00267
00268 }
00269
00270 }
00271
00272
00273 } else {
00274
00275 i__1 = *n;
00276 for (j = 1; j <= i__1; ++j) {
00277 i__2 = *n;
00278 for (i__ = 1; i__ <= i__2; ++i__) {
00279 if (piv[i__] >= piv[j]) {
00280 if (i__ >= j) {
00281 i__3 = piv[i__] + piv[j] * perm_dim1;
00282 i__4 = i__ + j * afac_dim1;
00283 perm[i__3].r = afac[i__4].r, perm[i__3].i = afac[i__4]
00284 .i;
00285 } else {
00286 i__3 = piv[i__] + piv[j] * perm_dim1;
00287 d_cnjg(&z__1, &afac[j + i__ * afac_dim1]);
00288 perm[i__3].r = z__1.r, perm[i__3].i = z__1.i;
00289 }
00290 }
00291
00292 }
00293
00294 }
00295
00296 }
00297
00298
00299
00300 if (lsame_(uplo, "U")) {
00301 i__1 = *n;
00302 for (j = 1; j <= i__1; ++j) {
00303 i__2 = j - 1;
00304 for (i__ = 1; i__ <= i__2; ++i__) {
00305 i__3 = i__ + j * perm_dim1;
00306 i__4 = i__ + j * perm_dim1;
00307 i__5 = i__ + j * a_dim1;
00308 z__1.r = perm[i__4].r - a[i__5].r, z__1.i = perm[i__4].i - a[
00309 i__5].i;
00310 perm[i__3].r = z__1.r, perm[i__3].i = z__1.i;
00311
00312 }
00313 i__2 = j + j * perm_dim1;
00314 i__3 = j + j * perm_dim1;
00315 i__4 = j + j * a_dim1;
00316 d__1 = a[i__4].r;
00317 z__1.r = perm[i__3].r - d__1, z__1.i = perm[i__3].i;
00318 perm[i__2].r = z__1.r, perm[i__2].i = z__1.i;
00319
00320 }
00321 } else {
00322 i__1 = *n;
00323 for (j = 1; j <= i__1; ++j) {
00324 i__2 = j + j * perm_dim1;
00325 i__3 = j + j * perm_dim1;
00326 i__4 = j + j * a_dim1;
00327 d__1 = a[i__4].r;
00328 z__1.r = perm[i__3].r - d__1, z__1.i = perm[i__3].i;
00329 perm[i__2].r = z__1.r, perm[i__2].i = z__1.i;
00330 i__2 = *n;
00331 for (i__ = j + 1; i__ <= i__2; ++i__) {
00332 i__3 = i__ + j * perm_dim1;
00333 i__4 = i__ + j * perm_dim1;
00334 i__5 = i__ + j * a_dim1;
00335 z__1.r = perm[i__4].r - a[i__5].r, z__1.i = perm[i__4].i - a[
00336 i__5].i;
00337 perm[i__3].r = z__1.r, perm[i__3].i = z__1.i;
00338
00339 }
00340
00341 }
00342 }
00343
00344
00345
00346
00347 *resid = zlanhe_("1", uplo, n, &perm[perm_offset], ldafac, &rwork[1]);
00348
00349 *resid = *resid / (doublereal) (*n) / anorm / eps;
00350
00351 return 0;
00352
00353
00354
00355 }