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