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