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_gercond__(char *trans, 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 trans_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 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 dgetrs_(char *, integer *, integer *,
00040 doublereal *, integer *, integer *, doublereal *, integer *,
00041 integer *);
00042 logical notrans;
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
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 notrans = lsame_(trans, "N");
00153 if (! notrans && ! lsame_(trans, "T") && ! lsame_(
00154 trans, "C")) {
00155 *info = -1;
00156 } else if (*n < 0) {
00157 *info = -2;
00158 } else if (*lda < max(1,*n)) {
00159 *info = -4;
00160 } else if (*ldaf < max(1,*n)) {
00161 *info = -6;
00162 }
00163 if (*info != 0) {
00164 i__1 = -(*info);
00165 xerbla_("DLA_GERCOND", &i__1);
00166 return ret_val;
00167 }
00168 if (*n == 0) {
00169 ret_val = 1.;
00170 return ret_val;
00171 }
00172
00173
00174
00175
00176 if (notrans) {
00177 i__1 = *n;
00178 for (i__ = 1; i__ <= i__1; ++i__) {
00179 tmp = 0.;
00180 if (*cmode == 1) {
00181 i__2 = *n;
00182 for (j = 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 = *n;
00187 for (j = 1; j <= i__2; ++j) {
00188 tmp += (d__1 = a[i__ + j * a_dim1], abs(d__1));
00189 }
00190 } else {
00191 i__2 = *n;
00192 for (j = 1; j <= i__2; ++j) {
00193 tmp += (d__1 = a[i__ + j * a_dim1] / c__[j], abs(d__1));
00194 }
00195 }
00196 work[(*n << 1) + i__] = tmp;
00197 }
00198 } else {
00199 i__1 = *n;
00200 for (i__ = 1; i__ <= i__1; ++i__) {
00201 tmp = 0.;
00202 if (*cmode == 1) {
00203 i__2 = *n;
00204 for (j = 1; j <= i__2; ++j) {
00205 tmp += (d__1 = a[j + i__ * a_dim1] * c__[j], abs(d__1));
00206 }
00207 } else if (*cmode == 0) {
00208 i__2 = *n;
00209 for (j = 1; j <= i__2; ++j) {
00210 tmp += (d__1 = a[j + i__ * a_dim1], abs(d__1));
00211 }
00212 } else {
00213 i__2 = *n;
00214 for (j = 1; j <= i__2; ++j) {
00215 tmp += (d__1 = a[j + i__ * a_dim1] / c__[j], abs(d__1));
00216 }
00217 }
00218 work[(*n << 1) + i__] = tmp;
00219 }
00220 }
00221
00222
00223
00224 ainvnm = 0.;
00225 kase = 0;
00226 L10:
00227 dlacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
00228 if (kase != 0) {
00229 if (kase == 2) {
00230
00231
00232
00233 i__1 = *n;
00234 for (i__ = 1; i__ <= i__1; ++i__) {
00235 work[i__] *= work[(*n << 1) + i__];
00236 }
00237 if (notrans) {
00238 dgetrs_("No transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[
00239 1], &work[1], n, info);
00240 } else {
00241 dgetrs_("Transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[1],
00242 &work[1], n, info);
00243 }
00244
00245
00246
00247 if (*cmode == 1) {
00248 i__1 = *n;
00249 for (i__ = 1; i__ <= i__1; ++i__) {
00250 work[i__] /= c__[i__];
00251 }
00252 } else if (*cmode == -1) {
00253 i__1 = *n;
00254 for (i__ = 1; i__ <= i__1; ++i__) {
00255 work[i__] *= c__[i__];
00256 }
00257 }
00258 } else {
00259
00260
00261
00262 if (*cmode == 1) {
00263 i__1 = *n;
00264 for (i__ = 1; i__ <= i__1; ++i__) {
00265 work[i__] /= c__[i__];
00266 }
00267 } else if (*cmode == -1) {
00268 i__1 = *n;
00269 for (i__ = 1; i__ <= i__1; ++i__) {
00270 work[i__] *= c__[i__];
00271 }
00272 }
00273 if (notrans) {
00274 dgetrs_("Transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[1],
00275 &work[1], n, info);
00276 } else {
00277 dgetrs_("No transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[
00278 1], &work[1], n, info);
00279 }
00280
00281
00282
00283 i__1 = *n;
00284 for (i__ = 1; i__ <= i__1; ++i__) {
00285 work[i__] *= work[(*n << 1) + i__];
00286 }
00287 }
00288 goto L10;
00289 }
00290
00291
00292
00293 if (ainvnm != 0.) {
00294 ret_val = 1. / ainvnm;
00295 }
00296
00297 return ret_val;
00298
00299 }