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_gercond__(char *trans, 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 trans_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 real tmp;
00031 integer kase;
00032 extern logical lsame_(char *, char *);
00033 integer isave[3];
00034 extern int slacn2_(integer *, real *, real *, integer *,
00035 real *, integer *, integer *), xerbla_(char *, integer *);
00036 real ainvnm;
00037 extern int sgetrs_(char *, integer *, integer *, real *,
00038 integer *, integer *, real *, integer *, integer *);
00039 logical notrans;
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
00128
00129
00130
00131
00132
00133
00134 a_dim1 = *lda;
00135 a_offset = 1 + a_dim1;
00136 a -= a_offset;
00137 af_dim1 = *ldaf;
00138 af_offset = 1 + af_dim1;
00139 af -= af_offset;
00140 --ipiv;
00141 --c__;
00142 --work;
00143 --iwork;
00144
00145
00146 ret_val = 0.f;
00147
00148 *info = 0;
00149 notrans = lsame_(trans, "N");
00150 if (! notrans && ! lsame_(trans, "T") && ! lsame_(
00151 trans, "C")) {
00152 *info = -1;
00153 } else if (*n < 0) {
00154 *info = -2;
00155 } else if (*lda < max(1,*n)) {
00156 *info = -4;
00157 } else if (*ldaf < max(1,*n)) {
00158 *info = -6;
00159 }
00160 if (*info != 0) {
00161 i__1 = -(*info);
00162 xerbla_("SLA_GERCOND", &i__1);
00163 return ret_val;
00164 }
00165 if (*n == 0) {
00166 ret_val = 1.f;
00167 return ret_val;
00168 }
00169
00170
00171
00172
00173 if (notrans) {
00174 i__1 = *n;
00175 for (i__ = 1; i__ <= i__1; ++i__) {
00176 tmp = 0.f;
00177 if (*cmode == 1) {
00178 i__2 = *n;
00179 for (j = 1; j <= i__2; ++j) {
00180 tmp += (r__1 = a[i__ + j * a_dim1] * c__[j], dabs(r__1));
00181 }
00182 } else if (*cmode == 0) {
00183 i__2 = *n;
00184 for (j = 1; j <= i__2; ++j) {
00185 tmp += (r__1 = a[i__ + j * a_dim1], dabs(r__1));
00186 }
00187 } else {
00188 i__2 = *n;
00189 for (j = 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 = *n;
00201 for (j = 1; j <= i__2; ++j) {
00202 tmp += (r__1 = a[j + i__ * a_dim1] * c__[j], dabs(r__1));
00203 }
00204 } else if (*cmode == 0) {
00205 i__2 = *n;
00206 for (j = 1; j <= i__2; ++j) {
00207 tmp += (r__1 = a[j + i__ * a_dim1], dabs(r__1));
00208 }
00209 } else {
00210 i__2 = *n;
00211 for (j = 1; j <= i__2; ++j) {
00212 tmp += (r__1 = a[j + i__ * a_dim1] / c__[j], dabs(r__1));
00213 }
00214 }
00215 work[(*n << 1) + i__] = tmp;
00216 }
00217 }
00218
00219
00220
00221 ainvnm = 0.f;
00222 kase = 0;
00223 L10:
00224 slacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
00225 if (kase != 0) {
00226 if (kase == 2) {
00227
00228
00229
00230 i__1 = *n;
00231 for (i__ = 1; i__ <= i__1; ++i__) {
00232 work[i__] *= work[(*n << 1) + i__];
00233 }
00234 if (notrans) {
00235 sgetrs_("No transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[
00236 1], &work[1], n, info);
00237 } else {
00238 sgetrs_("Transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[1],
00239 &work[1], n, info);
00240 }
00241
00242
00243
00244 if (*cmode == 1) {
00245 i__1 = *n;
00246 for (i__ = 1; i__ <= i__1; ++i__) {
00247 work[i__] /= c__[i__];
00248 }
00249 } else if (*cmode == -1) {
00250 i__1 = *n;
00251 for (i__ = 1; i__ <= i__1; ++i__) {
00252 work[i__] *= c__[i__];
00253 }
00254 }
00255 } else {
00256
00257
00258
00259 if (*cmode == 1) {
00260 i__1 = *n;
00261 for (i__ = 1; i__ <= i__1; ++i__) {
00262 work[i__] /= c__[i__];
00263 }
00264 } else if (*cmode == -1) {
00265 i__1 = *n;
00266 for (i__ = 1; i__ <= i__1; ++i__) {
00267 work[i__] *= c__[i__];
00268 }
00269 }
00270 if (notrans) {
00271 sgetrs_("Transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[1],
00272 &work[1], n, info);
00273 } else {
00274 sgetrs_("No transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[
00275 1], &work[1], n, info);
00276 }
00277
00278
00279
00280 i__1 = *n;
00281 for (i__ = 1; i__ <= i__1; ++i__) {
00282 work[i__] *= work[(*n << 1) + i__];
00283 }
00284 }
00285 goto L10;
00286 }
00287
00288
00289
00290 if (ainvnm != 0.f) {
00291 ret_val = 1.f / ainvnm;
00292 }
00293
00294 return ret_val;
00295
00296 }