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_hercond_c__(char *uplo, 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 uplo_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 logical up;
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 real ainvnm;
00043 extern int chetrs_(char *, integer *, integer *, complex
00044 *, integer *, integer *, complex *, integer *, integer *);
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 a_dim1 = *lda;
00131 a_offset = 1 + a_dim1;
00132 a -= a_offset;
00133 af_dim1 = *ldaf;
00134 af_offset = 1 + af_dim1;
00135 af -= af_offset;
00136 --ipiv;
00137 --c__;
00138 --work;
00139 --rwork;
00140
00141
00142 ret_val = 0.f;
00143
00144 *info = 0;
00145 if (*n < 0) {
00146 *info = -2;
00147 }
00148 if (*info != 0) {
00149 i__1 = -(*info);
00150 xerbla_("CLA_HERCOND_C", &i__1);
00151 return ret_val;
00152 }
00153 up = FALSE_;
00154 if (lsame_(uplo, "U")) {
00155 up = TRUE_;
00156 }
00157
00158
00159
00160 anorm = 0.f;
00161 if (up) {
00162 i__1 = *n;
00163 for (i__ = 1; i__ <= i__1; ++i__) {
00164 tmp = 0.f;
00165 if (*capply) {
00166 i__2 = i__;
00167 for (j = 1; j <= i__2; ++j) {
00168 i__3 = j + i__ * a_dim1;
00169 tmp += ((r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&
00170 a[j + i__ * a_dim1]), dabs(r__2))) / c__[j];
00171 }
00172 i__2 = *n;
00173 for (j = i__ + 1; j <= i__2; ++j) {
00174 i__3 = i__ + j * a_dim1;
00175 tmp += ((r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&
00176 a[i__ + j * a_dim1]), dabs(r__2))) / c__[j];
00177 }
00178 } else {
00179 i__2 = i__;
00180 for (j = 1; j <= i__2; ++j) {
00181 i__3 = j + i__ * a_dim1;
00182 tmp += (r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&a[
00183 j + i__ * a_dim1]), dabs(r__2));
00184 }
00185 i__2 = *n;
00186 for (j = i__ + 1; j <= i__2; ++j) {
00187 i__3 = i__ + j * a_dim1;
00188 tmp += (r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&a[
00189 i__ + j * a_dim1]), dabs(r__2));
00190 }
00191 }
00192 rwork[i__] = tmp;
00193 anorm = dmax(anorm,tmp);
00194 }
00195 } else {
00196 i__1 = *n;
00197 for (i__ = 1; i__ <= i__1; ++i__) {
00198 tmp = 0.f;
00199 if (*capply) {
00200 i__2 = i__;
00201 for (j = 1; j <= i__2; ++j) {
00202 i__3 = i__ + j * a_dim1;
00203 tmp += ((r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&
00204 a[i__ + j * a_dim1]), dabs(r__2))) / c__[j];
00205 }
00206 i__2 = *n;
00207 for (j = i__ + 1; j <= i__2; ++j) {
00208 i__3 = j + i__ * a_dim1;
00209 tmp += ((r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&
00210 a[j + i__ * a_dim1]), dabs(r__2))) / c__[j];
00211 }
00212 } else {
00213 i__2 = i__;
00214 for (j = 1; j <= i__2; ++j) {
00215 i__3 = i__ + j * a_dim1;
00216 tmp += (r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&a[
00217 i__ + j * a_dim1]), dabs(r__2));
00218 }
00219 i__2 = *n;
00220 for (j = i__ + 1; j <= i__2; ++j) {
00221 i__3 = j + i__ * a_dim1;
00222 tmp += (r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&a[
00223 j + i__ * a_dim1]), dabs(r__2));
00224 }
00225 }
00226 rwork[i__] = tmp;
00227 anorm = dmax(anorm,tmp);
00228 }
00229 }
00230
00231
00232
00233 if (*n == 0) {
00234 ret_val = 1.f;
00235 return ret_val;
00236 } else if (anorm == 0.f) {
00237 return ret_val;
00238 }
00239
00240
00241
00242 ainvnm = 0.f;
00243
00244 kase = 0;
00245 L10:
00246 clacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave);
00247 if (kase != 0) {
00248 if (kase == 2) {
00249
00250
00251
00252 i__1 = *n;
00253 for (i__ = 1; i__ <= i__1; ++i__) {
00254 i__2 = i__;
00255 i__3 = i__;
00256 i__4 = i__;
00257 q__1.r = rwork[i__4] * work[i__3].r, q__1.i = rwork[i__4] *
00258 work[i__3].i;
00259 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00260 }
00261
00262 if (up) {
00263 chetrs_("U", n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[
00264 1], n, info);
00265 } else {
00266 chetrs_("L", n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[
00267 1], n, info);
00268 }
00269
00270
00271
00272 if (*capply) {
00273 i__1 = *n;
00274 for (i__ = 1; i__ <= i__1; ++i__) {
00275 i__2 = i__;
00276 i__3 = i__;
00277 i__4 = i__;
00278 q__1.r = c__[i__4] * work[i__3].r, q__1.i = c__[i__4] *
00279 work[i__3].i;
00280 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00281 }
00282 }
00283 } else {
00284
00285
00286
00287 if (*capply) {
00288 i__1 = *n;
00289 for (i__ = 1; i__ <= i__1; ++i__) {
00290 i__2 = i__;
00291 i__3 = i__;
00292 i__4 = i__;
00293 q__1.r = c__[i__4] * work[i__3].r, q__1.i = c__[i__4] *
00294 work[i__3].i;
00295 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00296 }
00297 }
00298
00299 if (up) {
00300 chetrs_("U", n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[
00301 1], n, info);
00302 } else {
00303 chetrs_("L", n, &c__1, &af[af_offset], ldaf, &ipiv[1], &work[
00304 1], n, info);
00305 }
00306
00307
00308
00309 i__1 = *n;
00310 for (i__ = 1; i__ <= i__1; ++i__) {
00311 i__2 = i__;
00312 i__3 = i__;
00313 i__4 = i__;
00314 q__1.r = rwork[i__4] * work[i__3].r, q__1.i = rwork[i__4] *
00315 work[i__3].i;
00316 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00317 }
00318 }
00319 goto L10;
00320 }
00321
00322
00323
00324 if (ainvnm != 0.f) {
00325 ret_val = 1.f / ainvnm;
00326 }
00327
00328 return ret_val;
00329
00330 }