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