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