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_gbrcond_c__(char *trans, integer *n, integer *kl, integer *ku,
00021 complex *ab, integer *ldab, complex *afb, integer *ldafb, integer *
00022 ipiv, real *c__, logical *capply, integer *info, complex *work, real *
00023 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 real ret_val, r__1, r__2;
00028 complex q__1;
00029
00030
00031 double r_imag(complex *);
00032
00033
00034 integer i__, j, kd, ke;
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 cgbtrs_(char *, integer *, integer *, integer *, integer *,
00043 complex *, integer *, 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
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145 ab_dim1 = *ldab;
00146 ab_offset = 1 + ab_dim1;
00147 ab -= ab_offset;
00148 afb_dim1 = *ldafb;
00149 afb_offset = 1 + afb_dim1;
00150 afb -= afb_offset;
00151 --ipiv;
00152 --c__;
00153 --work;
00154 --rwork;
00155
00156
00157 ret_val = 0.f;
00158
00159 *info = 0;
00160 notrans = lsame_(trans, "N");
00161 if (! notrans && ! lsame_(trans, "T") && ! lsame_(
00162 trans, "C")) {
00163 *info = -1;
00164 } else if (*n < 0) {
00165 *info = -2;
00166 } else if (*kl < 0 || *kl > *n - 1) {
00167 *info = -3;
00168 } else if (*ku < 0 || *ku > *n - 1) {
00169 *info = -4;
00170 } else if (*ldab < *kl + *ku + 1) {
00171 *info = -6;
00172 } else if (*ldafb < (*kl << 1) + *ku + 1) {
00173 *info = -8;
00174 }
00175 if (*info != 0) {
00176 i__1 = -(*info);
00177 xerbla_("CLA_GBRCOND_C", &i__1);
00178 return ret_val;
00179 }
00180
00181
00182
00183 anorm = 0.f;
00184 kd = *ku + 1;
00185 ke = *kl + 1;
00186 if (notrans) {
00187 i__1 = *n;
00188 for (i__ = 1; i__ <= i__1; ++i__) {
00189 tmp = 0.f;
00190 if (*capply) {
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 tmp += ((r__1 = ab[i__2].r, dabs(r__1)) + (r__2 = r_imag(&
00199 ab[kd + i__ - j + j * ab_dim1]), dabs(r__2))) /
00200 c__[j];
00201 }
00202 } else {
00203
00204 i__3 = i__ - *kl;
00205
00206 i__4 = i__ + *ku;
00207 i__2 = min(i__4,*n);
00208 for (j = max(i__3,1); j <= i__2; ++j) {
00209 i__3 = kd + i__ - j + j * ab_dim1;
00210 tmp += (r__1 = ab[i__3].r, dabs(r__1)) + (r__2 = r_imag(&
00211 ab[kd + i__ - j + j * ab_dim1]), dabs(r__2));
00212 }
00213 }
00214 rwork[i__] = tmp;
00215 anorm = dmax(anorm,tmp);
00216 }
00217 } else {
00218 i__1 = *n;
00219 for (i__ = 1; i__ <= i__1; ++i__) {
00220 tmp = 0.f;
00221 if (*capply) {
00222
00223 i__2 = i__ - *kl;
00224
00225 i__4 = i__ + *ku;
00226 i__3 = min(i__4,*n);
00227 for (j = max(i__2,1); j <= i__3; ++j) {
00228 i__2 = ke - i__ + j + i__ * ab_dim1;
00229 tmp += ((r__1 = ab[i__2].r, dabs(r__1)) + (r__2 = r_imag(&
00230 ab[ke - i__ + j + i__ * ab_dim1]), dabs(r__2))) /
00231 c__[j];
00232 }
00233 } else {
00234
00235 i__3 = i__ - *kl;
00236
00237 i__4 = i__ + *ku;
00238 i__2 = min(i__4,*n);
00239 for (j = max(i__3,1); j <= i__2; ++j) {
00240 i__3 = ke - i__ + j + i__ * ab_dim1;
00241 tmp += (r__1 = ab[i__3].r, dabs(r__1)) + (r__2 = r_imag(&
00242 ab[ke - i__ + j + i__ * ab_dim1]), dabs(r__2));
00243 }
00244 }
00245 rwork[i__] = tmp;
00246 anorm = dmax(anorm,tmp);
00247 }
00248 }
00249
00250
00251
00252 if (*n == 0) {
00253 ret_val = 1.f;
00254 return ret_val;
00255 } else if (anorm == 0.f) {
00256 return ret_val;
00257 }
00258
00259
00260
00261 ainvnm = 0.f;
00262
00263 kase = 0;
00264 L10:
00265 clacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave);
00266 if (kase != 0) {
00267 if (kase == 2) {
00268
00269
00270
00271 i__1 = *n;
00272 for (i__ = 1; i__ <= i__1; ++i__) {
00273 i__2 = i__;
00274 i__3 = i__;
00275 i__4 = i__;
00276 q__1.r = rwork[i__4] * work[i__3].r, q__1.i = rwork[i__4] *
00277 work[i__3].i;
00278 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00279 }
00280
00281 if (notrans) {
00282 cgbtrs_("No transpose", n, kl, ku, &c__1, &afb[afb_offset],
00283 ldafb, &ipiv[1], &work[1], n, info);
00284 } else {
00285 cgbtrs_("Conjugate transpose", n, kl, ku, &c__1, &afb[
00286 afb_offset], ldafb, &ipiv[1], &work[1], n, info);
00287 }
00288
00289
00290
00291 if (*capply) {
00292 i__1 = *n;
00293 for (i__ = 1; i__ <= i__1; ++i__) {
00294 i__2 = i__;
00295 i__3 = i__;
00296 i__4 = i__;
00297 q__1.r = c__[i__4] * work[i__3].r, q__1.i = c__[i__4] *
00298 work[i__3].i;
00299 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00300 }
00301 }
00302 } else {
00303
00304
00305
00306 if (*capply) {
00307 i__1 = *n;
00308 for (i__ = 1; i__ <= i__1; ++i__) {
00309 i__2 = i__;
00310 i__3 = i__;
00311 i__4 = i__;
00312 q__1.r = c__[i__4] * work[i__3].r, q__1.i = c__[i__4] *
00313 work[i__3].i;
00314 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00315 }
00316 }
00317
00318 if (notrans) {
00319 cgbtrs_("Conjugate transpose", n, kl, ku, &c__1, &afb[
00320 afb_offset], ldafb, &ipiv[1], &work[1], n, info);
00321 } else {
00322 cgbtrs_("No transpose", n, kl, ku, &c__1, &afb[afb_offset],
00323 ldafb, &ipiv[1], &work[1], n, info);
00324 }
00325
00326
00327
00328 i__1 = *n;
00329 for (i__ = 1; i__ <= i__1; ++i__) {
00330 i__2 = i__;
00331 i__3 = i__;
00332 i__4 = i__;
00333 q__1.r = rwork[i__4] * work[i__3].r, q__1.i = rwork[i__4] *
00334 work[i__3].i;
00335 work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00336 }
00337 }
00338 goto L10;
00339 }
00340
00341
00342
00343 if (ainvnm != 0.f) {
00344 ret_val = 1.f / ainvnm;
00345 }
00346
00347 return ret_val;
00348
00349 }