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