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