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 zgbcon_(char *norm, integer *n, integer *kl, integer *ku,
00021 doublecomplex *ab, integer *ldab, integer *ipiv, doublereal *anorm,
00022 doublereal *rcond, doublecomplex *work, doublereal *rwork, integer *
00023 info)
00024 {
00025
00026 integer ab_dim1, ab_offset, i__1, i__2, i__3;
00027 doublereal d__1, d__2;
00028 doublecomplex z__1, z__2;
00029
00030
00031 double d_imag(doublecomplex *);
00032
00033
00034 integer j;
00035 doublecomplex t;
00036 integer kd, lm, jp, ix, kase, kase1;
00037 doublereal scale;
00038 extern logical lsame_(char *, char *);
00039 integer isave[3];
00040 extern VOID zdotc_(doublecomplex *, integer *,
00041 doublecomplex *, integer *, doublecomplex *, integer *);
00042 logical lnoti;
00043 extern int zaxpy_(integer *, doublecomplex *,
00044 doublecomplex *, integer *, doublecomplex *, integer *), zlacn2_(
00045 integer *, doublecomplex *, doublecomplex *, doublereal *,
00046 integer *, integer *);
00047 extern doublereal dlamch_(char *);
00048 extern int xerbla_(char *, integer *);
00049 doublereal ainvnm;
00050 extern integer izamax_(integer *, doublecomplex *, integer *);
00051 logical onenrm;
00052 extern int zlatbs_(char *, char *, char *, char *,
00053 integer *, integer *, doublecomplex *, integer *, doublecomplex *,
00054 doublereal *, doublereal *, integer *), zdrscl_(integer *, doublereal *, doublecomplex *,
00055 integer *);
00056 char normin[1];
00057 doublereal 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.) {
00174 *info = -8;
00175 }
00176 if (*info != 0) {
00177 i__1 = -(*info);
00178 xerbla_("ZGBCON", &i__1);
00179 return 0;
00180 }
00181
00182
00183
00184 *rcond = 0.;
00185 if (*n == 0) {
00186 *rcond = 1.;
00187 return 0;
00188 } else if (*anorm == 0.) {
00189 return 0;
00190 }
00191
00192 smlnum = dlamch_("Safe minimum");
00193
00194
00195
00196 ainvnm = 0.;
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 zlacn2_(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 z__1.r = -t.r, z__1.i = -t.i;
00231 zaxpy_(&lm, &z__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 zlatbs_("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 zlatbs_("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 zdotc_(&z__2, &lm, &ab[kd + 1 + j * ab_dim1], &c__1, &
00261 work[j + 1], &c__1);
00262 z__1.r = work[i__2].r - z__2.r, z__1.i = work[i__2].i -
00263 z__2.i;
00264 work[i__1].r = z__1.r, work[i__1].i = z__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.) {
00285 ix = izamax_(n, &work[1], &c__1);
00286 i__1 = ix;
00287 if (scale < ((d__1 = work[i__1].r, abs(d__1)) + (d__2 = d_imag(&
00288 work[ix]), abs(d__2))) * smlnum || scale == 0.) {
00289 goto L40;
00290 }
00291 zdrscl_(n, &scale, &work[1], &c__1);
00292 }
00293 goto L10;
00294 }
00295
00296
00297
00298 if (ainvnm != 0.) {
00299 *rcond = 1. / ainvnm / *anorm;
00300 }
00301
00302 L40:
00303 return 0;
00304
00305
00306
00307 }