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