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