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