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


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