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