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_syrcond__(char *uplo, integer *n, real *a, integer *lda, real *
00021 af, integer *ldaf, integer *ipiv, integer *cmode, real *c__, integer *
00022 info, real *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 *);
00037 extern doublereal slamch_(char *);
00038 extern int xerbla_(char *, integer *);
00039 real ainvnm;
00040 char normin[1];
00041 real smlnum;
00042 extern int ssytrs_(char *, integer *, integer *, real *,
00043 integer *, integer *, real *, integer *, integer *);
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
00129
00130
00131
00132
00133
00134
00135 a_dim1 = *lda;
00136 a_offset = 1 + a_dim1;
00137 a -= a_offset;
00138 af_dim1 = *ldaf;
00139 af_offset = 1 + af_dim1;
00140 af -= af_offset;
00141 --ipiv;
00142 --c__;
00143 --work;
00144 --iwork;
00145
00146
00147 ret_val = 0.f;
00148
00149 *info = 0;
00150 if (*n < 0) {
00151 *info = -2;
00152 }
00153 if (*info != 0) {
00154 i__1 = -(*info);
00155 xerbla_("SLA_SYRCOND", &i__1);
00156 return ret_val;
00157 }
00158 if (*n == 0) {
00159 ret_val = 1.f;
00160 return ret_val;
00161 }
00162 up = FALSE_;
00163 if (lsame_(uplo, "U")) {
00164 up = TRUE_;
00165 }
00166
00167
00168
00169
00170 if (up) {
00171 i__1 = *n;
00172 for (i__ = 1; i__ <= i__1; ++i__) {
00173 tmp = 0.f;
00174 if (*cmode == 1) {
00175 i__2 = i__;
00176 for (j = 1; j <= i__2; ++j) {
00177 tmp += (r__1 = a[j + i__ * a_dim1] * c__[j], 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] * c__[j], dabs(r__1));
00182 }
00183 } else if (*cmode == 0) {
00184 i__2 = i__;
00185 for (j = 1; j <= i__2; ++j) {
00186 tmp += (r__1 = a[j + i__ * a_dim1], 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], dabs(r__1));
00191 }
00192 } else {
00193 i__2 = i__;
00194 for (j = 1; j <= i__2; ++j) {
00195 tmp += (r__1 = a[j + i__ * a_dim1] / c__[j], dabs(r__1));
00196 }
00197 i__2 = *n;
00198 for (j = i__ + 1; j <= i__2; ++j) {
00199 tmp += (r__1 = a[i__ + j * a_dim1] / c__[j], dabs(r__1));
00200 }
00201 }
00202 work[(*n << 1) + i__] = tmp;
00203 }
00204 } else {
00205 i__1 = *n;
00206 for (i__ = 1; i__ <= i__1; ++i__) {
00207 tmp = 0.f;
00208 if (*cmode == 1) {
00209 i__2 = i__;
00210 for (j = 1; j <= i__2; ++j) {
00211 tmp += (r__1 = a[i__ + j * a_dim1] * c__[j], 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] * c__[j], dabs(r__1));
00216 }
00217 } else if (*cmode == 0) {
00218 i__2 = i__;
00219 for (j = 1; j <= i__2; ++j) {
00220 tmp += (r__1 = a[i__ + j * a_dim1], 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], dabs(r__1));
00225 }
00226 } else {
00227 i__2 = i__;
00228 for (j = 1; j <= i__2; ++j) {
00229 tmp += (r__1 = a[i__ + j * a_dim1] / c__[j], dabs(r__1));
00230 }
00231 i__2 = *n;
00232 for (j = i__ + 1; j <= i__2; ++j) {
00233 tmp += (r__1 = a[j + i__ * a_dim1] / c__[j], dabs(r__1));
00234 }
00235 }
00236 work[(*n << 1) + i__] = tmp;
00237 }
00238 }
00239
00240
00241
00242 smlnum = slamch_("Safe minimum");
00243 ainvnm = 0.f;
00244 *(unsigned char *)normin = 'N';
00245 kase = 0;
00246 L10:
00247 slacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
00248 if (kase != 0) {
00249 if (kase == 2) {
00250
00251
00252
00253 i__1 = *n;
00254 for (i__ = 1; i__ <= i__1; ++i__) {
00255 work[i__] *= work[(*n << 1) + i__];
00256 }
00257 if (up) {
00258 ssytrs_("U", n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[
00259 1], n, info);
00260 } else {
00261 ssytrs_("L", n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[
00262 1], n, info);
00263 }
00264
00265
00266
00267 if (*cmode == 1) {
00268 i__1 = *n;
00269 for (i__ = 1; i__ <= i__1; ++i__) {
00270 work[i__] /= c__[i__];
00271 }
00272 } else if (*cmode == -1) {
00273 i__1 = *n;
00274 for (i__ = 1; i__ <= i__1; ++i__) {
00275 work[i__] *= c__[i__];
00276 }
00277 }
00278 } else {
00279
00280
00281
00282 if (*cmode == 1) {
00283 i__1 = *n;
00284 for (i__ = 1; i__ <= i__1; ++i__) {
00285 work[i__] /= c__[i__];
00286 }
00287 } else if (*cmode == -1) {
00288 i__1 = *n;
00289 for (i__ = 1; i__ <= i__1; ++i__) {
00290 work[i__] *= c__[i__];
00291 }
00292 }
00293 if (up) {
00294 ssytrs_("U", n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[
00295 1], n, info);
00296 } else {
00297 ssytrs_("L", n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[
00298 1], n, info);
00299 }
00300
00301
00302
00303 i__1 = *n;
00304 for (i__ = 1; i__ <= i__1; ++i__) {
00305 work[i__] *= work[(*n << 1) + i__];
00306 }
00307 }
00308
00309 goto L10;
00310 }
00311
00312
00313
00314 if (ainvnm != 0.f) {
00315 ret_val = 1.f / ainvnm;
00316 }
00317
00318 return ret_val;
00319
00320 }