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_x__(char *trans, integer *n, doublecomplex *a, integer
00021 *lda, doublecomplex *af, integer *ldaf, integer *ipiv, doublecomplex *
00022 x, integer *info, doublecomplex *work, doublereal *rwork, ftnlen
00023 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, z__2;
00029
00030
00031 double d_imag(doublecomplex *);
00032 void z_div(doublecomplex *, doublecomplex *, doublecomplex *);
00033
00034
00035 integer i__, j;
00036 doublereal tmp;
00037 integer kase;
00038 extern logical lsame_(char *, char *);
00039 integer isave[3];
00040 doublereal anorm;
00041 extern int zlacn2_(integer *, doublecomplex *,
00042 doublecomplex *, doublereal *, integer *, integer *), xerbla_(
00043 char *, integer *);
00044 doublereal ainvnm;
00045 extern int zgetrs_(char *, integer *, integer *,
00046 doublecomplex *, integer *, integer *, doublecomplex *, integer *,
00047 integer *);
00048 logical notrans;
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 --x;
00142 --work;
00143 --rwork;
00144
00145
00146 ret_val = 0.;
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 }
00156 if (*info != 0) {
00157 i__1 = -(*info);
00158 xerbla_("ZLA_GERCOND_X", &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 i__2 = *n;
00170 for (j = 1; j <= i__2; ++j) {
00171 i__3 = i__ + j * a_dim1;
00172 i__4 = j;
00173 z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4].i,
00174 z__2.i = a[i__3].r * x[i__4].i + a[i__3].i * x[i__4]
00175 .r;
00176 z__1.r = z__2.r, z__1.i = z__2.i;
00177 tmp += (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&z__1),
00178 abs(d__2));
00179 }
00180 rwork[i__] = tmp;
00181 anorm = max(anorm,tmp);
00182 }
00183 } else {
00184 i__1 = *n;
00185 for (i__ = 1; i__ <= i__1; ++i__) {
00186 tmp = 0.;
00187 i__2 = *n;
00188 for (j = 1; j <= i__2; ++j) {
00189 i__3 = j + i__ * a_dim1;
00190 i__4 = j;
00191 z__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[i__4].i,
00192 z__2.i = a[i__3].r * x[i__4].i + a[i__3].i * x[i__4]
00193 .r;
00194 z__1.r = z__2.r, z__1.i = z__2.i;
00195 tmp += (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&z__1),
00196 abs(d__2));
00197 }
00198 rwork[i__] = tmp;
00199 anorm = max(anorm,tmp);
00200 }
00201 }
00202
00203
00204
00205 if (*n == 0) {
00206 ret_val = 1.;
00207 return ret_val;
00208 } else if (anorm == 0.) {
00209 return ret_val;
00210 }
00211
00212
00213
00214 ainvnm = 0.;
00215
00216 kase = 0;
00217 L10:
00218 zlacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave);
00219 if (kase != 0) {
00220 if (kase == 2) {
00221
00222 i__1 = *n;
00223 for (i__ = 1; i__ <= i__1; ++i__) {
00224 i__2 = i__;
00225 i__3 = i__;
00226 i__4 = i__;
00227 z__1.r = rwork[i__4] * work[i__3].r, z__1.i = rwork[i__4] *
00228 work[i__3].i;
00229 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00230 }
00231
00232 if (notrans) {
00233 zgetrs_("No transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[
00234 1], &work[1], n, info);
00235 } else {
00236 zgetrs_("Conjugate transpose", n, &c__1, &af[af_offset], ldaf,
00237 &ipiv[1], &work[1], n, info);
00238 }
00239
00240
00241
00242 i__1 = *n;
00243 for (i__ = 1; i__ <= i__1; ++i__) {
00244 i__2 = i__;
00245 z_div(&z__1, &work[i__], &x[i__]);
00246 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00247 }
00248 } else {
00249
00250
00251
00252 i__1 = *n;
00253 for (i__ = 1; i__ <= i__1; ++i__) {
00254 i__2 = i__;
00255 z_div(&z__1, &work[i__], &x[i__]);
00256 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00257 }
00258
00259 if (notrans) {
00260 zgetrs_("Conjugate transpose", n, &c__1, &af[af_offset], ldaf,
00261 &ipiv[1], &work[1], n, info);
00262 } else {
00263 zgetrs_("No transpose", n, &c__1, &af[af_offset], ldaf, &ipiv[
00264 1], &work[1], n, info);
00265 }
00266
00267
00268
00269 i__1 = *n;
00270 for (i__ = 1; i__ <= i__1; ++i__) {
00271 i__2 = i__;
00272 i__3 = i__;
00273 i__4 = i__;
00274 z__1.r = rwork[i__4] * work[i__3].r, z__1.i = rwork[i__4] *
00275 work[i__3].i;
00276 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00277 }
00278 }
00279 goto L10;
00280 }
00281
00282
00283
00284 if (ainvnm != 0.) {
00285 ret_val = 1. / ainvnm;
00286 }
00287
00288 return ret_val;
00289
00290 }