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 integer c__1 = 1;
00020
00021 int zppt03_(char *uplo, integer *n, doublecomplex *a,
00022 doublecomplex *ainv, doublecomplex *work, integer *ldwork, doublereal
00023 *rwork, doublereal *rcond, doublereal *resid)
00024 {
00025
00026 integer work_dim1, work_offset, i__1, i__2, i__3;
00027 doublecomplex z__1;
00028
00029
00030 void d_cnjg(doublecomplex *, doublecomplex *);
00031
00032
00033 integer i__, j, jj;
00034 doublereal eps;
00035 extern logical lsame_(char *, char *);
00036 doublereal anorm;
00037 extern int zcopy_(integer *, doublecomplex *, integer *,
00038 doublecomplex *, integer *), zhpmv_(char *, integer *,
00039 doublecomplex *, doublecomplex *, doublecomplex *, integer *,
00040 doublecomplex *, doublecomplex *, integer *);
00041 extern doublereal dlamch_(char *), zlange_(char *, integer *,
00042 integer *, doublecomplex *, integer *, doublereal *);
00043 doublereal ainvnm;
00044 extern doublereal zlanhp_(char *, char *, integer *, doublecomplex *,
00045 doublereal *);
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 --a;
00117 --ainv;
00118 work_dim1 = *ldwork;
00119 work_offset = 1 + work_dim1;
00120 work -= work_offset;
00121 --rwork;
00122
00123
00124 if (*n <= 0) {
00125 *rcond = 1.;
00126 *resid = 0.;
00127 return 0;
00128 }
00129
00130
00131
00132 eps = dlamch_("Epsilon");
00133 anorm = zlanhp_("1", uplo, n, &a[1], &rwork[1]);
00134 ainvnm = zlanhp_("1", uplo, n, &ainv[1], &rwork[1]);
00135 if (anorm <= 0. || ainvnm <= 0.) {
00136 *rcond = 0.;
00137 *resid = 1. / eps;
00138 return 0;
00139 }
00140 *rcond = 1. / anorm / ainvnm;
00141
00142
00143
00144
00145
00146
00147 if (lsame_(uplo, "U")) {
00148
00149
00150
00151 jj = 1;
00152 i__1 = *n - 1;
00153 for (j = 1; j <= i__1; ++j) {
00154 zcopy_(&j, &ainv[jj], &c__1, &work[(j + 1) * work_dim1 + 1], &
00155 c__1);
00156 i__2 = j - 1;
00157 for (i__ = 1; i__ <= i__2; ++i__) {
00158 i__3 = j + (i__ + 1) * work_dim1;
00159 d_cnjg(&z__1, &ainv[jj + i__ - 1]);
00160 work[i__3].r = z__1.r, work[i__3].i = z__1.i;
00161
00162 }
00163 jj += j;
00164
00165 }
00166 jj = (*n - 1) * *n / 2 + 1;
00167 i__1 = *n - 1;
00168 for (i__ = 1; i__ <= i__1; ++i__) {
00169 i__2 = *n + (i__ + 1) * work_dim1;
00170 d_cnjg(&z__1, &ainv[jj + i__ - 1]);
00171 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00172
00173 }
00174
00175
00176
00177 i__1 = *n - 1;
00178 for (j = 1; j <= i__1; ++j) {
00179 z__1.r = -1., z__1.i = -0.;
00180 zhpmv_("Upper", n, &z__1, &a[1], &work[(j + 1) * work_dim1 + 1], &
00181 c__1, &c_b1, &work[j * work_dim1 + 1], &c__1);
00182
00183 }
00184 z__1.r = -1., z__1.i = -0.;
00185 zhpmv_("Upper", n, &z__1, &a[1], &ainv[jj], &c__1, &c_b1, &work[*n *
00186 work_dim1 + 1], &c__1);
00187
00188
00189
00190
00191
00192 } else {
00193
00194
00195
00196 i__1 = *n - 1;
00197 for (i__ = 1; i__ <= i__1; ++i__) {
00198 i__2 = i__ * work_dim1 + 1;
00199 d_cnjg(&z__1, &ainv[i__ + 1]);
00200 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00201
00202 }
00203 jj = *n + 1;
00204 i__1 = *n;
00205 for (j = 2; j <= i__1; ++j) {
00206 i__2 = *n - j + 1;
00207 zcopy_(&i__2, &ainv[jj], &c__1, &work[j + (j - 1) * work_dim1], &
00208 c__1);
00209 i__2 = *n - j;
00210 for (i__ = 1; i__ <= i__2; ++i__) {
00211 i__3 = j + (j + i__ - 1) * work_dim1;
00212 d_cnjg(&z__1, &ainv[jj + i__]);
00213 work[i__3].r = z__1.r, work[i__3].i = z__1.i;
00214
00215 }
00216 jj = jj + *n - j + 1;
00217
00218 }
00219
00220
00221
00222 for (j = *n; j >= 2; --j) {
00223 z__1.r = -1., z__1.i = -0.;
00224 zhpmv_("Lower", n, &z__1, &a[1], &work[(j - 1) * work_dim1 + 1], &
00225 c__1, &c_b1, &work[j * work_dim1 + 1], &c__1);
00226
00227 }
00228 z__1.r = -1., z__1.i = -0.;
00229 zhpmv_("Lower", n, &z__1, &a[1], &ainv[1], &c__1, &c_b1, &work[
00230 work_dim1 + 1], &c__1);
00231
00232 }
00233
00234
00235
00236 i__1 = *n;
00237 for (i__ = 1; i__ <= i__1; ++i__) {
00238 i__2 = i__ + i__ * work_dim1;
00239 i__3 = i__ + i__ * work_dim1;
00240 z__1.r = work[i__3].r + 1., z__1.i = work[i__3].i + 0.;
00241 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00242
00243 }
00244
00245
00246
00247 *resid = zlange_("1", n, n, &work[work_offset], ldwork, &rwork[1]);
00248
00249 *resid = *resid * *rcond / eps / (doublereal) (*n);
00250
00251 return 0;
00252
00253
00254
00255 }