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
00020 doublereal zla_porcond_x__(char *uplo, integer *n, doublecomplex *a, integer *
00021 lda, doublecomplex *af, integer *ldaf, doublecomplex *x, integer *
00022 info, doublecomplex *work, doublereal *rwork, ftnlen uplo_len)
00023 {
00024
00025 integer a_dim1, a_offset, af_dim1, af_offset, i__1, i__2, i__3, i__4;
00026 doublereal ret_val, d__1, d__2;
00027 doublecomplex z__1, z__2;
00028
00029
00030 double d_imag(doublecomplex *);
00031 void z_div(doublecomplex *, doublecomplex *, doublecomplex *);
00032
00033
00034 integer i__, j;
00035 logical up;
00036 doublereal tmp;
00037 integer kase;
00038 extern logical lsame_(char *, char *);
00039 integer isave[3];
00040 doublereal anorm;
00041 extern int zlacn2_(integer *, doublecomplex *,
00042 doublecomplex *, doublereal *, integer *, integer *), xerbla_(
00043 char *, integer *);
00044 doublereal ainvnm;
00045 extern int zpotrs_(char *, integer *, integer *,
00046 doublecomplex *, integer *, doublecomplex *, integer *, integer *);
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
00120
00121
00122
00123
00124
00125 a_dim1 = *lda;
00126 a_offset = 1 + a_dim1;
00127 a -= a_offset;
00128 af_dim1 = *ldaf;
00129 af_offset = 1 + af_dim1;
00130 af -= af_offset;
00131 --x;
00132 --work;
00133 --rwork;
00134
00135
00136 ret_val = 0.;
00137
00138 *info = 0;
00139 if (*n < 0) {
00140 *info = -2;
00141 }
00142 if (*info != 0) {
00143 i__1 = -(*info);
00144 xerbla_("ZLA_PORCOND_X", &i__1);
00145 return ret_val;
00146 }
00147 up = FALSE_;
00148 if (lsame_(uplo, "U")) {
00149 up = TRUE_;
00150 }
00151
00152
00153
00154 anorm = 0.;
00155 if (up) {
00156 i__1 = *n;
00157 for (i__ = 1; i__ <= i__1; ++i__) {
00158 tmp = 0.;
00159 i__2 = i__;
00160 for (j = 1; j <= i__2; ++j) {
00161 i__3 = j + i__ * a_dim1;
00162 i__4 = j;
00163 z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4].i,
00164 z__2.i = a[i__3].r * x[i__4].i + a[i__3].i * x[i__4]
00165 .r;
00166 z__1.r = z__2.r, z__1.i = z__2.i;
00167 tmp += (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&z__1),
00168 abs(d__2));
00169 }
00170 i__2 = *n;
00171 for (j = i__ + 1; j <= i__2; ++j) {
00172 i__3 = i__ + j * a_dim1;
00173 i__4 = j;
00174 z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4].i,
00175 z__2.i = a[i__3].r * x[i__4].i + a[i__3].i * x[i__4]
00176 .r;
00177 z__1.r = z__2.r, z__1.i = z__2.i;
00178 tmp += (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&z__1),
00179 abs(d__2));
00180 }
00181 rwork[i__] = tmp;
00182 anorm = max(anorm,tmp);
00183 }
00184 } else {
00185 i__1 = *n;
00186 for (i__ = 1; i__ <= i__1; ++i__) {
00187 tmp = 0.;
00188 i__2 = i__;
00189 for (j = 1; j <= i__2; ++j) {
00190 i__3 = i__ + j * a_dim1;
00191 i__4 = j;
00192 z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4].i,
00193 z__2.i = a[i__3].r * x[i__4].i + a[i__3].i * x[i__4]
00194 .r;
00195 z__1.r = z__2.r, z__1.i = z__2.i;
00196 tmp += (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&z__1),
00197 abs(d__2));
00198 }
00199 i__2 = *n;
00200 for (j = i__ + 1; j <= i__2; ++j) {
00201 i__3 = j + i__ * a_dim1;
00202 i__4 = j;
00203 z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4].i,
00204 z__2.i = a[i__3].r * x[i__4].i + a[i__3].i * x[i__4]
00205 .r;
00206 z__1.r = z__2.r, z__1.i = z__2.i;
00207 tmp += (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&z__1),
00208 abs(d__2));
00209 }
00210 rwork[i__] = tmp;
00211 anorm = max(anorm,tmp);
00212 }
00213 }
00214
00215
00216
00217 if (*n == 0) {
00218 ret_val = 1.;
00219 return ret_val;
00220 } else if (anorm == 0.) {
00221 return ret_val;
00222 }
00223
00224
00225
00226 ainvnm = 0.;
00227
00228 kase = 0;
00229 L10:
00230 zlacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave);
00231 if (kase != 0) {
00232 if (kase == 2) {
00233
00234
00235
00236 i__1 = *n;
00237 for (i__ = 1; i__ <= i__1; ++i__) {
00238 i__2 = i__;
00239 i__3 = i__;
00240 i__4 = i__;
00241 z__1.r = rwork[i__4] * work[i__3].r, z__1.i = rwork[i__4] *
00242 work[i__3].i;
00243 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00244 }
00245
00246 if (up) {
00247 zpotrs_("U", n, &c__1, &af[af_offset], ldaf, &work[1], n,
00248 info);
00249 } else {
00250 zpotrs_("L", n, &c__1, &af[af_offset], ldaf, &work[1], n,
00251 info);
00252 }
00253
00254
00255
00256 i__1 = *n;
00257 for (i__ = 1; i__ <= i__1; ++i__) {
00258 i__2 = i__;
00259 z_div(&z__1, &work[i__], &x[i__]);
00260 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00261 }
00262 } else {
00263
00264
00265
00266 i__1 = *n;
00267 for (i__ = 1; i__ <= i__1; ++i__) {
00268 i__2 = i__;
00269 z_div(&z__1, &work[i__], &x[i__]);
00270 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00271 }
00272
00273 if (up) {
00274 zpotrs_("U", n, &c__1, &af[af_offset], ldaf, &work[1], n,
00275 info);
00276 } else {
00277 zpotrs_("L", n, &c__1, &af[af_offset], ldaf, &work[1], n,
00278 info);
00279 }
00280
00281
00282
00283 i__1 = *n;
00284 for (i__ = 1; i__ <= i__1; ++i__) {
00285 i__2 = i__;
00286 i__3 = i__;
00287 i__4 = i__;
00288 z__1.r = rwork[i__4] * work[i__3].r, z__1.i = rwork[i__4] *
00289 work[i__3].i;
00290 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00291 }
00292 }
00293 goto L10;
00294 }
00295
00296
00297
00298 if (ainvnm != 0.) {
00299 ret_val = 1. / ainvnm;
00300 }
00301
00302 return ret_val;
00303
00304 }