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