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 dla_porcond__(char *uplo, integer *n, doublereal *a, integer *lda,
00021 doublereal *af, integer *ldaf, integer *cmode, doublereal *c__,
00022 integer *info, doublereal *work, integer *iwork, ftnlen uplo_len)
00023 {
00024
00025 integer a_dim1, a_offset, af_dim1, af_offset, i__1, i__2;
00026 doublereal ret_val, d__1;
00027
00028
00029 integer i__, j;
00030 logical up;
00031 doublereal tmp;
00032 integer kase;
00033 extern logical lsame_(char *, char *);
00034 integer isave[3];
00035 extern int dlacn2_(integer *, doublereal *, doublereal *,
00036 integer *, doublereal *, integer *, integer *), xerbla_(char *,
00037 integer *);
00038 doublereal ainvnm;
00039 extern int dpotrs_(char *, integer *, integer *,
00040 doublereal *, integer *, doublereal *, integer *, integer *);
00041
00042
00043
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
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 --iwork;
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_("DLA_PORCOND", &i__1);
00148 return ret_val;
00149 }
00150 if (*n == 0) {
00151 ret_val = 1.;
00152 return ret_val;
00153 }
00154 up = FALSE_;
00155 if (lsame_(uplo, "U")) {
00156 up = TRUE_;
00157 }
00158
00159
00160
00161
00162 if (up) {
00163 i__1 = *n;
00164 for (i__ = 1; i__ <= i__1; ++i__) {
00165 tmp = 0.;
00166 if (*cmode == 1) {
00167 i__2 = i__;
00168 for (j = 1; j <= i__2; ++j) {
00169 tmp += (d__1 = a[j + i__ * a_dim1] * c__[j], abs(d__1));
00170 }
00171 i__2 = *n;
00172 for (j = i__ + 1; j <= i__2; ++j) {
00173 tmp += (d__1 = a[i__ + j * a_dim1] * c__[j], abs(d__1));
00174 }
00175 } else if (*cmode == 0) {
00176 i__2 = i__;
00177 for (j = 1; j <= i__2; ++j) {
00178 tmp += (d__1 = a[j + i__ * a_dim1], abs(d__1));
00179 }
00180 i__2 = *n;
00181 for (j = i__ + 1; j <= i__2; ++j) {
00182 tmp += (d__1 = a[i__ + j * a_dim1], abs(d__1));
00183 }
00184 } else {
00185 i__2 = i__;
00186 for (j = 1; j <= i__2; ++j) {
00187 tmp += (d__1 = a[j + i__ * a_dim1] / c__[j], abs(d__1));
00188 }
00189 i__2 = *n;
00190 for (j = i__ + 1; j <= i__2; ++j) {
00191 tmp += (d__1 = a[i__ + j * a_dim1] / c__[j], abs(d__1));
00192 }
00193 }
00194 work[(*n << 1) + i__] = tmp;
00195 }
00196 } else {
00197 i__1 = *n;
00198 for (i__ = 1; i__ <= i__1; ++i__) {
00199 tmp = 0.;
00200 if (*cmode == 1) {
00201 i__2 = i__;
00202 for (j = 1; j <= i__2; ++j) {
00203 tmp += (d__1 = a[i__ + j * a_dim1] * c__[j], abs(d__1));
00204 }
00205 i__2 = *n;
00206 for (j = i__ + 1; j <= i__2; ++j) {
00207 tmp += (d__1 = a[j + i__ * a_dim1] * c__[j], abs(d__1));
00208 }
00209 } else if (*cmode == 0) {
00210 i__2 = i__;
00211 for (j = 1; j <= i__2; ++j) {
00212 tmp += (d__1 = a[i__ + j * a_dim1], abs(d__1));
00213 }
00214 i__2 = *n;
00215 for (j = i__ + 1; j <= i__2; ++j) {
00216 tmp += (d__1 = a[j + i__ * a_dim1], abs(d__1));
00217 }
00218 } else {
00219 i__2 = i__;
00220 for (j = 1; j <= i__2; ++j) {
00221 tmp += (d__1 = a[i__ + j * a_dim1] / c__[j], abs(d__1));
00222 }
00223 i__2 = *n;
00224 for (j = i__ + 1; j <= i__2; ++j) {
00225 tmp += (d__1 = a[j + i__ * a_dim1] / c__[j], abs(d__1));
00226 }
00227 }
00228 work[(*n << 1) + i__] = tmp;
00229 }
00230 }
00231
00232
00233
00234 ainvnm = 0.;
00235 kase = 0;
00236 L10:
00237 dlacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
00238 if (kase != 0) {
00239 if (kase == 2) {
00240
00241
00242
00243 i__1 = *n;
00244 for (i__ = 1; i__ <= i__1; ++i__) {
00245 work[i__] *= work[(*n << 1) + i__];
00246 }
00247 if (up) {
00248 dpotrs_("Upper", n, &c__1, &af[af_offset], ldaf, &work[1], n,
00249 info);
00250 } else {
00251 dpotrs_("Lower", n, &c__1, &af[af_offset], ldaf, &work[1], n,
00252 info);
00253 }
00254
00255
00256
00257 if (*cmode == 1) {
00258 i__1 = *n;
00259 for (i__ = 1; i__ <= i__1; ++i__) {
00260 work[i__] /= c__[i__];
00261 }
00262 } else if (*cmode == -1) {
00263 i__1 = *n;
00264 for (i__ = 1; i__ <= i__1; ++i__) {
00265 work[i__] *= c__[i__];
00266 }
00267 }
00268 } else {
00269
00270
00271
00272 if (*cmode == 1) {
00273 i__1 = *n;
00274 for (i__ = 1; i__ <= i__1; ++i__) {
00275 work[i__] /= c__[i__];
00276 }
00277 } else if (*cmode == -1) {
00278 i__1 = *n;
00279 for (i__ = 1; i__ <= i__1; ++i__) {
00280 work[i__] *= c__[i__];
00281 }
00282 }
00283 if (up) {
00284 dpotrs_("Upper", n, &c__1, &af[af_offset], ldaf, &work[1], n,
00285 info);
00286 } else {
00287 dpotrs_("Lower", n, &c__1, &af[af_offset], ldaf, &work[1], n,
00288 info);
00289 }
00290
00291
00292
00293 i__1 = *n;
00294 for (i__ = 1; i__ <= i__1; ++i__) {
00295 work[i__] *= work[(*n << 1) + i__];
00296 }
00297 }
00298 goto L10;
00299 }
00300
00301
00302
00303 if (ainvnm != 0.) {
00304 ret_val = 1. / ainvnm;
00305 }
00306
00307 return ret_val;
00308
00309 }