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_gbrcond_x__(char *trans, integer *n, integer *kl, integer *ku,
00021 doublecomplex *ab, integer *ldab, doublecomplex *afb, integer *ldafb,
00022 integer *ipiv, doublecomplex *x, integer *info, doublecomplex *work,
00023 doublereal *rwork, ftnlen trans_len)
00024 {
00025
00026 integer ab_dim1, ab_offset, afb_dim1, afb_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, kd, ke;
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 zgbtrs_(char *, integer *, integer *, integer
00046 *, integer *, doublecomplex *, integer *, integer *,
00047 doublecomplex *, integer *, 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
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146 ab_dim1 = *ldab;
00147 ab_offset = 1 + ab_dim1;
00148 ab -= ab_offset;
00149 afb_dim1 = *ldafb;
00150 afb_offset = 1 + afb_dim1;
00151 afb -= afb_offset;
00152 --ipiv;
00153 --x;
00154 --work;
00155 --rwork;
00156
00157
00158 ret_val = 0.;
00159
00160 *info = 0;
00161 notrans = lsame_(trans, "N");
00162 if (! notrans && ! lsame_(trans, "T") && ! lsame_(
00163 trans, "C")) {
00164 *info = -1;
00165 } else if (*n < 0) {
00166 *info = -2;
00167 } else if (*kl < 0 || *kl > *n - 1) {
00168 *info = -3;
00169 } else if (*ku < 0 || *ku > *n - 1) {
00170 *info = -4;
00171 } else if (*ldab < *kl + *ku + 1) {
00172 *info = -6;
00173 } else if (*ldafb < (*kl << 1) + *ku + 1) {
00174 *info = -8;
00175 }
00176 if (*info != 0) {
00177 i__1 = -(*info);
00178 xerbla_("ZLA_GBRCOND_X", &i__1);
00179 return ret_val;
00180 }
00181
00182
00183
00184 kd = *ku + 1;
00185 ke = *kl + 1;
00186 anorm = 0.;
00187 if (notrans) {
00188 i__1 = *n;
00189 for (i__ = 1; i__ <= i__1; ++i__) {
00190 tmp = 0.;
00191
00192 i__2 = i__ - *kl;
00193
00194 i__4 = i__ + *ku;
00195 i__3 = min(i__4,*n);
00196 for (j = max(i__2,1); j <= i__3; ++j) {
00197 i__2 = kd + i__ - j + j * ab_dim1;
00198 i__4 = j;
00199 z__2.r = ab[i__2].r * x[i__4].r - ab[i__2].i * x[i__4].i,
00200 z__2.i = ab[i__2].r * x[i__4].i + ab[i__2].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 rwork[i__] = tmp;
00207 anorm = max(anorm,tmp);
00208 }
00209 } else {
00210 i__1 = *n;
00211 for (i__ = 1; i__ <= i__1; ++i__) {
00212 tmp = 0.;
00213
00214 i__3 = i__ - *kl;
00215
00216 i__4 = i__ + *ku;
00217 i__2 = min(i__4,*n);
00218 for (j = max(i__3,1); j <= i__2; ++j) {
00219 i__3 = ke - i__ + j + i__ * ab_dim1;
00220 i__4 = j;
00221 z__2.r = ab[i__3].r * x[i__4].r - ab[i__3].i * x[i__4].i,
00222 z__2.i = ab[i__3].r * x[i__4].i + ab[i__3].i * x[i__4]
00223 .r;
00224 z__1.r = z__2.r, z__1.i = z__2.i;
00225 tmp += (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&z__1),
00226 abs(d__2));
00227 }
00228 rwork[i__] = tmp;
00229 anorm = max(anorm,tmp);
00230 }
00231 }
00232
00233
00234
00235 if (*n == 0) {
00236 ret_val = 1.;
00237 return ret_val;
00238 } else if (anorm == 0.) {
00239 return ret_val;
00240 }
00241
00242
00243
00244 ainvnm = 0.;
00245
00246 kase = 0;
00247 L10:
00248 zlacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave);
00249 if (kase != 0) {
00250 if (kase == 2) {
00251
00252
00253
00254 i__1 = *n;
00255 for (i__ = 1; i__ <= i__1; ++i__) {
00256 i__2 = i__;
00257 i__3 = i__;
00258 i__4 = i__;
00259 z__1.r = rwork[i__4] * work[i__3].r, z__1.i = rwork[i__4] *
00260 work[i__3].i;
00261 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00262 }
00263
00264 if (notrans) {
00265 zgbtrs_("No transpose", n, kl, ku, &c__1, &afb[afb_offset],
00266 ldafb, &ipiv[1], &work[1], n, info);
00267 } else {
00268 zgbtrs_("Conjugate transpose", n, kl, ku, &c__1, &afb[
00269 afb_offset], ldafb, &ipiv[1], &work[1], n, info);
00270 }
00271
00272
00273
00274 i__1 = *n;
00275 for (i__ = 1; i__ <= i__1; ++i__) {
00276 i__2 = i__;
00277 z_div(&z__1, &work[i__], &x[i__]);
00278 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00279 }
00280 } else {
00281
00282
00283
00284 i__1 = *n;
00285 for (i__ = 1; i__ <= i__1; ++i__) {
00286 i__2 = i__;
00287 z_div(&z__1, &work[i__], &x[i__]);
00288 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00289 }
00290
00291 if (notrans) {
00292 zgbtrs_("Conjugate transpose", n, kl, ku, &c__1, &afb[
00293 afb_offset], ldafb, &ipiv[1], &work[1], n, info);
00294 } else {
00295 zgbtrs_("No transpose", n, kl, ku, &c__1, &afb[afb_offset],
00296 ldafb, &ipiv[1], &work[1], n, info);
00297 }
00298
00299
00300
00301 i__1 = *n;
00302 for (i__ = 1; i__ <= i__1; ++i__) {
00303 i__2 = i__;
00304 i__3 = i__;
00305 i__4 = i__;
00306 z__1.r = rwork[i__4] * work[i__3].r, z__1.i = rwork[i__4] *
00307 work[i__3].i;
00308 work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00309 }
00310 }
00311 goto L10;
00312 }
00313
00314
00315
00316 if (ainvnm != 0.) {
00317 ret_val = 1. / ainvnm;
00318 }
00319
00320 return ret_val;
00321
00322 }