zgbsvx.c
Go to the documentation of this file.
00001 /* zgbsvx.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
00017 
00018 static integer c__1 = 1;
00019 
00020 /* Subroutine */ int zgbsvx_(char *fact, char *trans, integer *n, integer *kl, 
00021          integer *ku, integer *nrhs, doublecomplex *ab, integer *ldab, 
00022         doublecomplex *afb, integer *ldafb, integer *ipiv, char *equed, 
00023         doublereal *r__, doublereal *c__, doublecomplex *b, integer *ldb, 
00024         doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *ferr, 
00025         doublereal *berr, doublecomplex *work, doublereal *rwork, integer *
00026         info)
00027 {
00028     /* System generated locals */
00029     integer ab_dim1, ab_offset, afb_dim1, afb_offset, b_dim1, b_offset, 
00030             x_dim1, x_offset, i__1, i__2, i__3, i__4, i__5;
00031     doublereal d__1, d__2;
00032     doublecomplex z__1;
00033 
00034     /* Builtin functions */
00035     double z_abs(doublecomplex *);
00036 
00037     /* Local variables */
00038     integer i__, j, j1, j2;
00039     doublereal amax;
00040     char norm[1];
00041     extern logical lsame_(char *, char *);
00042     doublereal rcmin, rcmax, anorm;
00043     logical equil;
00044     extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *, 
00045             doublecomplex *, integer *);
00046     extern doublereal dlamch_(char *);
00047     doublereal colcnd;
00048     logical nofact;
00049     extern doublereal zlangb_(char *, integer *, integer *, integer *, 
00050             doublecomplex *, integer *, doublereal *);
00051     extern /* Subroutine */ int xerbla_(char *, integer *), zlaqgb_(
00052             integer *, integer *, integer *, integer *, doublecomplex *, 
00053             integer *, doublereal *, doublereal *, doublereal *, doublereal *, 
00054              doublereal *, char *);
00055     doublereal bignum;
00056     extern /* Subroutine */ int zgbcon_(char *, integer *, integer *, integer 
00057             *, doublecomplex *, integer *, integer *, doublereal *, 
00058             doublereal *, doublecomplex *, doublereal *, integer *);
00059     integer infequ;
00060     logical colequ;
00061     extern doublereal zlantb_(char *, char *, char *, integer *, integer *, 
00062             doublecomplex *, integer *, doublereal *);
00063     doublereal rowcnd;
00064     extern /* Subroutine */ int zgbequ_(integer *, integer *, integer *, 
00065             integer *, doublecomplex *, integer *, doublereal *, doublereal *, 
00066              doublereal *, doublereal *, doublereal *, integer *), zgbrfs_(
00067             char *, integer *, integer *, integer *, integer *, doublecomplex 
00068             *, integer *, doublecomplex *, integer *, integer *, 
00069             doublecomplex *, integer *, doublecomplex *, integer *, 
00070             doublereal *, doublereal *, doublecomplex *, doublereal *, 
00071             integer *), zgbtrf_(integer *, integer *, integer *, 
00072             integer *, doublecomplex *, integer *, integer *, integer *);
00073     logical notran;
00074     extern /* Subroutine */ int zlacpy_(char *, integer *, integer *, 
00075             doublecomplex *, integer *, doublecomplex *, integer *);
00076     doublereal smlnum;
00077     extern /* Subroutine */ int zgbtrs_(char *, integer *, integer *, integer 
00078             *, integer *, doublecomplex *, integer *, integer *, 
00079             doublecomplex *, integer *, integer *);
00080     logical rowequ;
00081     doublereal rpvgrw;
00082 
00083 
00084 /*  -- LAPACK driver routine (version 3.2) -- */
00085 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00086 /*     November 2006 */
00087 
00088 /*     .. Scalar Arguments .. */
00089 /*     .. */
00090 /*     .. Array Arguments .. */
00091 /*     .. */
00092 
00093 /*  Purpose */
00094 /*  ======= */
00095 
00096 /*  ZGBSVX uses the LU factorization to compute the solution to a complex */
00097 /*  system of linear equations A * X = B, A**T * X = B, or A**H * X = B, */
00098 /*  where A is a band matrix of order N with KL subdiagonals and KU */
00099 /*  superdiagonals, and X and B are N-by-NRHS matrices. */
00100 
00101 /*  Error bounds on the solution and a condition estimate are also */
00102 /*  provided. */
00103 
00104 /*  Description */
00105 /*  =========== */
00106 
00107 /*  The following steps are performed by this subroutine: */
00108 
00109 /*  1. If FACT = 'E', real scaling factors are computed to equilibrate */
00110 /*     the system: */
00111 /*        TRANS = 'N':  diag(R)*A*diag(C)     *inv(diag(C))*X = diag(R)*B */
00112 /*        TRANS = 'T': (diag(R)*A*diag(C))**T *inv(diag(R))*X = diag(C)*B */
00113 /*        TRANS = 'C': (diag(R)*A*diag(C))**H *inv(diag(R))*X = diag(C)*B */
00114 /*     Whether or not the system will be equilibrated depends on the */
00115 /*     scaling of the matrix A, but if equilibration is used, A is */
00116 /*     overwritten by diag(R)*A*diag(C) and B by diag(R)*B (if TRANS='N') */
00117 /*     or diag(C)*B (if TRANS = 'T' or 'C'). */
00118 
00119 /*  2. If FACT = 'N' or 'E', the LU decomposition is used to factor the */
00120 /*     matrix A (after equilibration if FACT = 'E') as */
00121 /*        A = L * U, */
00122 /*     where L is a product of permutation and unit lower triangular */
00123 /*     matrices with KL subdiagonals, and U is upper triangular with */
00124 /*     KL+KU superdiagonals. */
00125 
00126 /*  3. If some U(i,i)=0, so that U is exactly singular, then the routine */
00127 /*     returns with INFO = i. Otherwise, the factored form of A is used */
00128 /*     to estimate the condition number of the matrix A.  If the */
00129 /*     reciprocal of the condition number is less than machine precision, */
00130 /*     INFO = N+1 is returned as a warning, but the routine still goes on */
00131 /*     to solve for X and compute error bounds as described below. */
00132 
00133 /*  4. The system of equations is solved for X using the factored form */
00134 /*     of A. */
00135 
00136 /*  5. Iterative refinement is applied to improve the computed solution */
00137 /*     matrix and calculate error bounds and backward error estimates */
00138 /*     for it. */
00139 
00140 /*  6. If equilibration was used, the matrix X is premultiplied by */
00141 /*     diag(C) (if TRANS = 'N') or diag(R) (if TRANS = 'T' or 'C') so */
00142 /*     that it solves the original system before equilibration. */
00143 
00144 /*  Arguments */
00145 /*  ========= */
00146 
00147 /*  FACT    (input) CHARACTER*1 */
00148 /*          Specifies whether or not the factored form of the matrix A is */
00149 /*          supplied on entry, and if not, whether the matrix A should be */
00150 /*          equilibrated before it is factored. */
00151 /*          = 'F':  On entry, AFB and IPIV contain the factored form of */
00152 /*                  A.  If EQUED is not 'N', the matrix A has been */
00153 /*                  equilibrated with scaling factors given by R and C. */
00154 /*                  AB, AFB, and IPIV are not modified. */
00155 /*          = 'N':  The matrix A will be copied to AFB and factored. */
00156 /*          = 'E':  The matrix A will be equilibrated if necessary, then */
00157 /*                  copied to AFB and factored. */
00158 
00159 /*  TRANS   (input) CHARACTER*1 */
00160 /*          Specifies the form of the system of equations. */
00161 /*          = 'N':  A * X = B     (No transpose) */
00162 /*          = 'T':  A**T * X = B  (Transpose) */
00163 /*          = 'C':  A**H * X = B  (Conjugate transpose) */
00164 
00165 /*  N       (input) INTEGER */
00166 /*          The number of linear equations, i.e., the order of the */
00167 /*          matrix A.  N >= 0. */
00168 
00169 /*  KL      (input) INTEGER */
00170 /*          The number of subdiagonals within the band of A.  KL >= 0. */
00171 
00172 /*  KU      (input) INTEGER */
00173 /*          The number of superdiagonals within the band of A.  KU >= 0. */
00174 
00175 /*  NRHS    (input) INTEGER */
00176 /*          The number of right hand sides, i.e., the number of columns */
00177 /*          of the matrices B and X.  NRHS >= 0. */
00178 
00179 /*  AB      (input/output) COMPLEX*16 array, dimension (LDAB,N) */
00180 /*          On entry, the matrix A in band storage, in rows 1 to KL+KU+1. */
00181 /*          The j-th column of A is stored in the j-th column of the */
00182 /*          array AB as follows: */
00183 /*          AB(KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+kl) */
00184 
00185 /*          If FACT = 'F' and EQUED is not 'N', then A must have been */
00186 /*          equilibrated by the scaling factors in R and/or C.  AB is not */
00187 /*          modified if FACT = 'F' or 'N', or if FACT = 'E' and */
00188 /*          EQUED = 'N' on exit. */
00189 
00190 /*          On exit, if EQUED .ne. 'N', A is scaled as follows: */
00191 /*          EQUED = 'R':  A := diag(R) * A */
00192 /*          EQUED = 'C':  A := A * diag(C) */
00193 /*          EQUED = 'B':  A := diag(R) * A * diag(C). */
00194 
00195 /*  LDAB    (input) INTEGER */
00196 /*          The leading dimension of the array AB.  LDAB >= KL+KU+1. */
00197 
00198 /*  AFB     (input or output) COMPLEX*16 array, dimension (LDAFB,N) */
00199 /*          If FACT = 'F', then AFB is an input argument and on entry */
00200 /*          contains details of the LU factorization of the band matrix */
00201 /*          A, as computed by ZGBTRF.  U is stored as an upper triangular */
00202 /*          band matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, */
00203 /*          and the multipliers used during the factorization are stored */
00204 /*          in rows KL+KU+2 to 2*KL+KU+1.  If EQUED .ne. 'N', then AFB is */
00205 /*          the factored form of the equilibrated matrix A. */
00206 
00207 /*          If FACT = 'N', then AFB is an output argument and on exit */
00208 /*          returns details of the LU factorization of A. */
00209 
00210 /*          If FACT = 'E', then AFB is an output argument and on exit */
00211 /*          returns details of the LU factorization of the equilibrated */
00212 /*          matrix A (see the description of AB for the form of the */
00213 /*          equilibrated matrix). */
00214 
00215 /*  LDAFB   (input) INTEGER */
00216 /*          The leading dimension of the array AFB.  LDAFB >= 2*KL+KU+1. */
00217 
00218 /*  IPIV    (input or output) INTEGER array, dimension (N) */
00219 /*          If FACT = 'F', then IPIV is an input argument and on entry */
00220 /*          contains the pivot indices from the factorization A = L*U */
00221 /*          as computed by ZGBTRF; row i of the matrix was interchanged */
00222 /*          with row IPIV(i). */
00223 
00224 /*          If FACT = 'N', then IPIV is an output argument and on exit */
00225 /*          contains the pivot indices from the factorization A = L*U */
00226 /*          of the original matrix A. */
00227 
00228 /*          If FACT = 'E', then IPIV is an output argument and on exit */
00229 /*          contains the pivot indices from the factorization A = L*U */
00230 /*          of the equilibrated matrix A. */
00231 
00232 /*  EQUED   (input or output) CHARACTER*1 */
00233 /*          Specifies the form of equilibration that was done. */
00234 /*          = 'N':  No equilibration (always true if FACT = 'N'). */
00235 /*          = 'R':  Row equilibration, i.e., A has been premultiplied by */
00236 /*                  diag(R). */
00237 /*          = 'C':  Column equilibration, i.e., A has been postmultiplied */
00238 /*                  by diag(C). */
00239 /*          = 'B':  Both row and column equilibration, i.e., A has been */
00240 /*                  replaced by diag(R) * A * diag(C). */
00241 /*          EQUED is an input argument if FACT = 'F'; otherwise, it is an */
00242 /*          output argument. */
00243 
00244 /*  R       (input or output) DOUBLE PRECISION array, dimension (N) */
00245 /*          The row scale factors for A.  If EQUED = 'R' or 'B', A is */
00246 /*          multiplied on the left by diag(R); if EQUED = 'N' or 'C', R */
00247 /*          is not accessed.  R is an input argument if FACT = 'F'; */
00248 /*          otherwise, R is an output argument.  If FACT = 'F' and */
00249 /*          EQUED = 'R' or 'B', each element of R must be positive. */
00250 
00251 /*  C       (input or output) DOUBLE PRECISION array, dimension (N) */
00252 /*          The column scale factors for A.  If EQUED = 'C' or 'B', A is */
00253 /*          multiplied on the right by diag(C); if EQUED = 'N' or 'R', C */
00254 /*          is not accessed.  C is an input argument if FACT = 'F'; */
00255 /*          otherwise, C is an output argument.  If FACT = 'F' and */
00256 /*          EQUED = 'C' or 'B', each element of C must be positive. */
00257 
00258 /*  B       (input/output) COMPLEX*16 array, dimension (LDB,NRHS) */
00259 /*          On entry, the right hand side matrix B. */
00260 /*          On exit, */
00261 /*          if EQUED = 'N', B is not modified; */
00262 /*          if TRANS = 'N' and EQUED = 'R' or 'B', B is overwritten by */
00263 /*          diag(R)*B; */
00264 /*          if TRANS = 'T' or 'C' and EQUED = 'C' or 'B', B is */
00265 /*          overwritten by diag(C)*B. */
00266 
00267 /*  LDB     (input) INTEGER */
00268 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00269 
00270 /*  X       (output) COMPLEX*16 array, dimension (LDX,NRHS) */
00271 /*          If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X */
00272 /*          to the original system of equations.  Note that A and B are */
00273 /*          modified on exit if EQUED .ne. 'N', and the solution to the */
00274 /*          equilibrated system is inv(diag(C))*X if TRANS = 'N' and */
00275 /*          EQUED = 'C' or 'B', or inv(diag(R))*X if TRANS = 'T' or 'C' */
00276 /*          and EQUED = 'R' or 'B'. */
00277 
00278 /*  LDX     (input) INTEGER */
00279 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00280 
00281 /*  RCOND   (output) DOUBLE PRECISION */
00282 /*          The estimate of the reciprocal condition number of the matrix */
00283 /*          A after equilibration (if done).  If RCOND is less than the */
00284 /*          machine precision (in particular, if RCOND = 0), the matrix */
00285 /*          is singular to working precision.  This condition is */
00286 /*          indicated by a return code of INFO > 0. */
00287 
00288 /*  FERR    (output) DOUBLE PRECISION array, dimension (NRHS) */
00289 /*          The estimated forward error bound for each solution vector */
00290 /*          X(j) (the j-th column of the solution matrix X). */
00291 /*          If XTRUE is the true solution corresponding to X(j), FERR(j) */
00292 /*          is an estimated upper bound for the magnitude of the largest */
00293 /*          element in (X(j) - XTRUE) divided by the magnitude of the */
00294 /*          largest element in X(j).  The estimate is as reliable as */
00295 /*          the estimate for RCOND, and is almost always a slight */
00296 /*          overestimate of the true error. */
00297 
00298 /*  BERR    (output) DOUBLE PRECISION array, dimension (NRHS) */
00299 /*          The componentwise relative backward error of each solution */
00300 /*          vector X(j) (i.e., the smallest relative change in */
00301 /*          any element of A or B that makes X(j) an exact solution). */
00302 
00303 /*  WORK    (workspace) COMPLEX*16 array, dimension (2*N) */
00304 
00305 /*  RWORK   (workspace/output) DOUBLE PRECISION array, dimension (N) */
00306 /*          On exit, RWORK(1) contains the reciprocal pivot growth */
00307 /*          factor norm(A)/norm(U). The "max absolute element" norm is */
00308 /*          used. If RWORK(1) is much less than 1, then the stability */
00309 /*          of the LU factorization of the (equilibrated) matrix A */
00310 /*          could be poor. This also means that the solution X, condition */
00311 /*          estimator RCOND, and forward error bound FERR could be */
00312 /*          unreliable. If factorization fails with 0<INFO<=N, then */
00313 /*          RWORK(1) contains the reciprocal pivot growth factor for the */
00314 /*          leading INFO columns of A. */
00315 
00316 /*  INFO    (output) INTEGER */
00317 /*          = 0:  successful exit */
00318 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00319 /*          > 0:  if INFO = i, and i is */
00320 /*                <= N:  U(i,i) is exactly zero.  The factorization */
00321 /*                       has been completed, but the factor U is exactly */
00322 /*                       singular, so the solution and error bounds */
00323 /*                       could not be computed. RCOND = 0 is returned. */
00324 /*                = N+1: U is nonsingular, but RCOND is less than machine */
00325 /*                       precision, meaning that the matrix is singular */
00326 /*                       to working precision.  Nevertheless, the */
00327 /*                       solution and error bounds are computed because */
00328 /*                       there are a number of situations where the */
00329 /*                       computed solution can be more accurate than the */
00330 /*                       value of RCOND would suggest. */
00331 
00332 /*  ===================================================================== */
00333 /*  Moved setting of INFO = N+1 so INFO does not subsequently get */
00334 /*  overwritten.  Sven, 17 Mar 05. */
00335 /*  ===================================================================== */
00336 
00337 /*     .. Parameters .. */
00338 /*     .. */
00339 /*     .. Local Scalars .. */
00340 /*     .. */
00341 /*     .. External Functions .. */
00342 /*     .. */
00343 /*     .. External Subroutines .. */
00344 /*     .. */
00345 /*     .. Intrinsic Functions .. */
00346 /*     .. */
00347 /*     .. Executable Statements .. */
00348 
00349     /* Parameter adjustments */
00350     ab_dim1 = *ldab;
00351     ab_offset = 1 + ab_dim1;
00352     ab -= ab_offset;
00353     afb_dim1 = *ldafb;
00354     afb_offset = 1 + afb_dim1;
00355     afb -= afb_offset;
00356     --ipiv;
00357     --r__;
00358     --c__;
00359     b_dim1 = *ldb;
00360     b_offset = 1 + b_dim1;
00361     b -= b_offset;
00362     x_dim1 = *ldx;
00363     x_offset = 1 + x_dim1;
00364     x -= x_offset;
00365     --ferr;
00366     --berr;
00367     --work;
00368     --rwork;
00369 
00370     /* Function Body */
00371     *info = 0;
00372     nofact = lsame_(fact, "N");
00373     equil = lsame_(fact, "E");
00374     notran = lsame_(trans, "N");
00375     if (nofact || equil) {
00376         *(unsigned char *)equed = 'N';
00377         rowequ = FALSE_;
00378         colequ = FALSE_;
00379     } else {
00380         rowequ = lsame_(equed, "R") || lsame_(equed, 
00381                 "B");
00382         colequ = lsame_(equed, "C") || lsame_(equed, 
00383                 "B");
00384         smlnum = dlamch_("Safe minimum");
00385         bignum = 1. / smlnum;
00386     }
00387 
00388 /*     Test the input parameters. */
00389 
00390     if (! nofact && ! equil && ! lsame_(fact, "F")) {
00391         *info = -1;
00392     } else if (! notran && ! lsame_(trans, "T") && ! 
00393             lsame_(trans, "C")) {
00394         *info = -2;
00395     } else if (*n < 0) {
00396         *info = -3;
00397     } else if (*kl < 0) {
00398         *info = -4;
00399     } else if (*ku < 0) {
00400         *info = -5;
00401     } else if (*nrhs < 0) {
00402         *info = -6;
00403     } else if (*ldab < *kl + *ku + 1) {
00404         *info = -8;
00405     } else if (*ldafb < (*kl << 1) + *ku + 1) {
00406         *info = -10;
00407     } else if (lsame_(fact, "F") && ! (rowequ || colequ 
00408             || lsame_(equed, "N"))) {
00409         *info = -12;
00410     } else {
00411         if (rowequ) {
00412             rcmin = bignum;
00413             rcmax = 0.;
00414             i__1 = *n;
00415             for (j = 1; j <= i__1; ++j) {
00416 /* Computing MIN */
00417                 d__1 = rcmin, d__2 = r__[j];
00418                 rcmin = min(d__1,d__2);
00419 /* Computing MAX */
00420                 d__1 = rcmax, d__2 = r__[j];
00421                 rcmax = max(d__1,d__2);
00422 /* L10: */
00423             }
00424             if (rcmin <= 0.) {
00425                 *info = -13;
00426             } else if (*n > 0) {
00427                 rowcnd = max(rcmin,smlnum) / min(rcmax,bignum);
00428             } else {
00429                 rowcnd = 1.;
00430             }
00431         }
00432         if (colequ && *info == 0) {
00433             rcmin = bignum;
00434             rcmax = 0.;
00435             i__1 = *n;
00436             for (j = 1; j <= i__1; ++j) {
00437 /* Computing MIN */
00438                 d__1 = rcmin, d__2 = c__[j];
00439                 rcmin = min(d__1,d__2);
00440 /* Computing MAX */
00441                 d__1 = rcmax, d__2 = c__[j];
00442                 rcmax = max(d__1,d__2);
00443 /* L20: */
00444             }
00445             if (rcmin <= 0.) {
00446                 *info = -14;
00447             } else if (*n > 0) {
00448                 colcnd = max(rcmin,smlnum) / min(rcmax,bignum);
00449             } else {
00450                 colcnd = 1.;
00451             }
00452         }
00453         if (*info == 0) {
00454             if (*ldb < max(1,*n)) {
00455                 *info = -16;
00456             } else if (*ldx < max(1,*n)) {
00457                 *info = -18;
00458             }
00459         }
00460     }
00461 
00462     if (*info != 0) {
00463         i__1 = -(*info);
00464         xerbla_("ZGBSVX", &i__1);
00465         return 0;
00466     }
00467 
00468     if (equil) {
00469 
00470 /*        Compute row and column scalings to equilibrate the matrix A. */
00471 
00472         zgbequ_(n, n, kl, ku, &ab[ab_offset], ldab, &r__[1], &c__[1], &rowcnd, 
00473                  &colcnd, &amax, &infequ);
00474         if (infequ == 0) {
00475 
00476 /*           Equilibrate the matrix. */
00477 
00478             zlaqgb_(n, n, kl, ku, &ab[ab_offset], ldab, &r__[1], &c__[1], &
00479                     rowcnd, &colcnd, &amax, equed);
00480             rowequ = lsame_(equed, "R") || lsame_(equed, 
00481                      "B");
00482             colequ = lsame_(equed, "C") || lsame_(equed, 
00483                      "B");
00484         }
00485     }
00486 
00487 /*     Scale the right hand side. */
00488 
00489     if (notran) {
00490         if (rowequ) {
00491             i__1 = *nrhs;
00492             for (j = 1; j <= i__1; ++j) {
00493                 i__2 = *n;
00494                 for (i__ = 1; i__ <= i__2; ++i__) {
00495                     i__3 = i__ + j * b_dim1;
00496                     i__4 = i__;
00497                     i__5 = i__ + j * b_dim1;
00498                     z__1.r = r__[i__4] * b[i__5].r, z__1.i = r__[i__4] * b[
00499                             i__5].i;
00500                     b[i__3].r = z__1.r, b[i__3].i = z__1.i;
00501 /* L30: */
00502                 }
00503 /* L40: */
00504             }
00505         }
00506     } else if (colequ) {
00507         i__1 = *nrhs;
00508         for (j = 1; j <= i__1; ++j) {
00509             i__2 = *n;
00510             for (i__ = 1; i__ <= i__2; ++i__) {
00511                 i__3 = i__ + j * b_dim1;
00512                 i__4 = i__;
00513                 i__5 = i__ + j * b_dim1;
00514                 z__1.r = c__[i__4] * b[i__5].r, z__1.i = c__[i__4] * b[i__5]
00515                         .i;
00516                 b[i__3].r = z__1.r, b[i__3].i = z__1.i;
00517 /* L50: */
00518             }
00519 /* L60: */
00520         }
00521     }
00522 
00523     if (nofact || equil) {
00524 
00525 /*        Compute the LU factorization of the band matrix A. */
00526 
00527         i__1 = *n;
00528         for (j = 1; j <= i__1; ++j) {
00529 /* Computing MAX */
00530             i__2 = j - *ku;
00531             j1 = max(i__2,1);
00532 /* Computing MIN */
00533             i__2 = j + *kl;
00534             j2 = min(i__2,*n);
00535             i__2 = j2 - j1 + 1;
00536             zcopy_(&i__2, &ab[*ku + 1 - j + j1 + j * ab_dim1], &c__1, &afb[*
00537                     kl + *ku + 1 - j + j1 + j * afb_dim1], &c__1);
00538 /* L70: */
00539         }
00540 
00541         zgbtrf_(n, n, kl, ku, &afb[afb_offset], ldafb, &ipiv[1], info);
00542 
00543 /*        Return if INFO is non-zero. */
00544 
00545         if (*info > 0) {
00546 
00547 /*           Compute the reciprocal pivot growth factor of the */
00548 /*           leading rank-deficient INFO columns of A. */
00549 
00550             anorm = 0.;
00551             i__1 = *info;
00552             for (j = 1; j <= i__1; ++j) {
00553 /* Computing MAX */
00554                 i__2 = *ku + 2 - j;
00555 /* Computing MIN */
00556                 i__4 = *n + *ku + 1 - j, i__5 = *kl + *ku + 1;
00557                 i__3 = min(i__4,i__5);
00558                 for (i__ = max(i__2,1); i__ <= i__3; ++i__) {
00559 /* Computing MAX */
00560                     d__1 = anorm, d__2 = z_abs(&ab[i__ + j * ab_dim1]);
00561                     anorm = max(d__1,d__2);
00562 /* L80: */
00563                 }
00564 /* L90: */
00565             }
00566 /* Computing MIN */
00567             i__3 = *info - 1, i__2 = *kl + *ku;
00568             i__1 = min(i__3,i__2);
00569 /* Computing MAX */
00570             i__4 = 1, i__5 = *kl + *ku + 2 - *info;
00571             rpvgrw = zlantb_("M", "U", "N", info, &i__1, &afb[max(i__4, i__5)
00572                     + afb_dim1], ldafb, &rwork[1]);
00573             if (rpvgrw == 0.) {
00574                 rpvgrw = 1.;
00575             } else {
00576                 rpvgrw = anorm / rpvgrw;
00577             }
00578             rwork[1] = rpvgrw;
00579             *rcond = 0.;
00580             return 0;
00581         }
00582     }
00583 
00584 /*     Compute the norm of the matrix A and the */
00585 /*     reciprocal pivot growth factor RPVGRW. */
00586 
00587     if (notran) {
00588         *(unsigned char *)norm = '1';
00589     } else {
00590         *(unsigned char *)norm = 'I';
00591     }
00592     anorm = zlangb_(norm, n, kl, ku, &ab[ab_offset], ldab, &rwork[1]);
00593     i__1 = *kl + *ku;
00594     rpvgrw = zlantb_("M", "U", "N", n, &i__1, &afb[afb_offset], ldafb, &rwork[
00595             1]);
00596     if (rpvgrw == 0.) {
00597         rpvgrw = 1.;
00598     } else {
00599         rpvgrw = zlangb_("M", n, kl, ku, &ab[ab_offset], ldab, &rwork[1]) / rpvgrw;
00600     }
00601 
00602 /*     Compute the reciprocal of the condition number of A. */
00603 
00604     zgbcon_(norm, n, kl, ku, &afb[afb_offset], ldafb, &ipiv[1], &anorm, rcond, 
00605              &work[1], &rwork[1], info);
00606 
00607 /*     Compute the solution matrix X. */
00608 
00609     zlacpy_("Full", n, nrhs, &b[b_offset], ldb, &x[x_offset], ldx);
00610     zgbtrs_(trans, n, kl, ku, nrhs, &afb[afb_offset], ldafb, &ipiv[1], &x[
00611             x_offset], ldx, info);
00612 
00613 /*     Use iterative refinement to improve the computed solution and */
00614 /*     compute error bounds and backward error estimates for it. */
00615 
00616     zgbrfs_(trans, n, kl, ku, nrhs, &ab[ab_offset], ldab, &afb[afb_offset], 
00617             ldafb, &ipiv[1], &b[b_offset], ldb, &x[x_offset], ldx, &ferr[1], &
00618             berr[1], &work[1], &rwork[1], info);
00619 
00620 /*     Transform the solution matrix X to a solution of the original */
00621 /*     system. */
00622 
00623     if (notran) {
00624         if (colequ) {
00625             i__1 = *nrhs;
00626             for (j = 1; j <= i__1; ++j) {
00627                 i__3 = *n;
00628                 for (i__ = 1; i__ <= i__3; ++i__) {
00629                     i__2 = i__ + j * x_dim1;
00630                     i__4 = i__;
00631                     i__5 = i__ + j * x_dim1;
00632                     z__1.r = c__[i__4] * x[i__5].r, z__1.i = c__[i__4] * x[
00633                             i__5].i;
00634                     x[i__2].r = z__1.r, x[i__2].i = z__1.i;
00635 /* L100: */
00636                 }
00637 /* L110: */
00638             }
00639             i__1 = *nrhs;
00640             for (j = 1; j <= i__1; ++j) {
00641                 ferr[j] /= colcnd;
00642 /* L120: */
00643             }
00644         }
00645     } else if (rowequ) {
00646         i__1 = *nrhs;
00647         for (j = 1; j <= i__1; ++j) {
00648             i__3 = *n;
00649             for (i__ = 1; i__ <= i__3; ++i__) {
00650                 i__2 = i__ + j * x_dim1;
00651                 i__4 = i__;
00652                 i__5 = i__ + j * x_dim1;
00653                 z__1.r = r__[i__4] * x[i__5].r, z__1.i = r__[i__4] * x[i__5]
00654                         .i;
00655                 x[i__2].r = z__1.r, x[i__2].i = z__1.i;
00656 /* L130: */
00657             }
00658 /* L140: */
00659         }
00660         i__1 = *nrhs;
00661         for (j = 1; j <= i__1; ++j) {
00662             ferr[j] /= rowcnd;
00663 /* L150: */
00664         }
00665     }
00666 
00667 /*     Set INFO = N+1 if the matrix is singular to working precision. */
00668 
00669     if (*rcond < dlamch_("Epsilon")) {
00670         *info = *n + 1;
00671     }
00672 
00673     rwork[1] = rpvgrw;
00674     return 0;
00675 
00676 /*     End of ZGBSVX */
00677 
00678 } /* zgbsvx_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:30