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 int sgbcon_(char *norm, integer *n, integer *kl, integer *ku,
00021 real *ab, integer *ldab, integer *ipiv, real *anorm, real *rcond,
00022 real *work, integer *iwork, integer *info)
00023 {
00024
00025 integer ab_dim1, ab_offset, i__1, i__2, i__3;
00026 real r__1;
00027
00028
00029 integer j;
00030 real t;
00031 integer kd, lm, jp, ix, kase;
00032 extern doublereal sdot_(integer *, real *, integer *, real *, integer *);
00033 integer kase1;
00034 real scale;
00035 extern logical lsame_(char *, char *);
00036 integer isave[3];
00037 logical lnoti;
00038 extern int srscl_(integer *, real *, real *, integer *),
00039 saxpy_(integer *, real *, real *, integer *, real *, integer *),
00040 slacn2_(integer *, real *, real *, integer *, real *, integer *,
00041 integer *);
00042 extern doublereal slamch_(char *);
00043 extern int xerbla_(char *, integer *);
00044 extern integer isamax_(integer *, real *, integer *);
00045 real ainvnm;
00046 extern int slatbs_(char *, char *, char *, char *,
00047 integer *, integer *, real *, integer *, real *, real *, real *,
00048 integer *);
00049 logical onenrm;
00050 char normin[1];
00051 real smlnum;
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 ab_dim1 = *ldab;
00144 ab_offset = 1 + ab_dim1;
00145 ab -= ab_offset;
00146 --ipiv;
00147 --work;
00148 --iwork;
00149
00150
00151 *info = 0;
00152 onenrm = *(unsigned char *)norm == '1' || lsame_(norm, "O");
00153 if (! onenrm && ! lsame_(norm, "I")) {
00154 *info = -1;
00155 } else if (*n < 0) {
00156 *info = -2;
00157 } else if (*kl < 0) {
00158 *info = -3;
00159 } else if (*ku < 0) {
00160 *info = -4;
00161 } else if (*ldab < (*kl << 1) + *ku + 1) {
00162 *info = -6;
00163 } else if (*anorm < 0.f) {
00164 *info = -8;
00165 }
00166 if (*info != 0) {
00167 i__1 = -(*info);
00168 xerbla_("SGBCON", &i__1);
00169 return 0;
00170 }
00171
00172
00173
00174 *rcond = 0.f;
00175 if (*n == 0) {
00176 *rcond = 1.f;
00177 return 0;
00178 } else if (*anorm == 0.f) {
00179 return 0;
00180 }
00181
00182 smlnum = slamch_("Safe minimum");
00183
00184
00185
00186 ainvnm = 0.f;
00187 *(unsigned char *)normin = 'N';
00188 if (onenrm) {
00189 kase1 = 1;
00190 } else {
00191 kase1 = 2;
00192 }
00193 kd = *kl + *ku + 1;
00194 lnoti = *kl > 0;
00195 kase = 0;
00196 L10:
00197 slacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
00198 if (kase != 0) {
00199 if (kase == kase1) {
00200
00201
00202
00203 if (lnoti) {
00204 i__1 = *n - 1;
00205 for (j = 1; j <= i__1; ++j) {
00206
00207 i__2 = *kl, i__3 = *n - j;
00208 lm = min(i__2,i__3);
00209 jp = ipiv[j];
00210 t = work[jp];
00211 if (jp != j) {
00212 work[jp] = work[j];
00213 work[j] = t;
00214 }
00215 r__1 = -t;
00216 saxpy_(&lm, &r__1, &ab[kd + 1 + j * ab_dim1], &c__1, &
00217 work[j + 1], &c__1);
00218
00219 }
00220 }
00221
00222
00223
00224 i__1 = *kl + *ku;
00225 slatbs_("Upper", "No transpose", "Non-unit", normin, n, &i__1, &
00226 ab[ab_offset], ldab, &work[1], &scale, &work[(*n << 1) +
00227 1], info);
00228 } else {
00229
00230
00231
00232 i__1 = *kl + *ku;
00233 slatbs_("Upper", "Transpose", "Non-unit", normin, n, &i__1, &ab[
00234 ab_offset], ldab, &work[1], &scale, &work[(*n << 1) + 1],
00235 info);
00236
00237
00238
00239 if (lnoti) {
00240 for (j = *n - 1; j >= 1; --j) {
00241
00242 i__1 = *kl, i__2 = *n - j;
00243 lm = min(i__1,i__2);
00244 work[j] -= sdot_(&lm, &ab[kd + 1 + j * ab_dim1], &c__1, &
00245 work[j + 1], &c__1);
00246 jp = ipiv[j];
00247 if (jp != j) {
00248 t = work[jp];
00249 work[jp] = work[j];
00250 work[j] = t;
00251 }
00252
00253 }
00254 }
00255 }
00256
00257
00258
00259 *(unsigned char *)normin = 'Y';
00260 if (scale != 1.f) {
00261 ix = isamax_(n, &work[1], &c__1);
00262 if (scale < (r__1 = work[ix], dabs(r__1)) * smlnum || scale ==
00263 0.f) {
00264 goto L40;
00265 }
00266 srscl_(n, &scale, &work[1], &c__1);
00267 }
00268 goto L10;
00269 }
00270
00271
00272
00273 if (ainvnm != 0.f) {
00274 *rcond = 1.f / ainvnm / *anorm;
00275 }
00276
00277 L40:
00278 return 0;
00279
00280
00281
00282 }