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