sgbrfsx.c
Go to the documentation of this file.
00001 /* sgbrfsx.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_n1 = -1;
00019 static integer c__0 = 0;
00020 static integer c__1 = 1;
00021 
00022 /* Subroutine */ int sgbrfsx_(char *trans, char *equed, integer *n, integer *
00023         kl, integer *ku, integer *nrhs, real *ab, integer *ldab, real *afb, 
00024         integer *ldafb, integer *ipiv, real *r__, real *c__, real *b, integer 
00025         *ldb, real *x, integer *ldx, real *rcond, real *berr, integer *
00026         n_err_bnds__, real *err_bnds_norm__, real *err_bnds_comp__, integer *
00027         nparams, real *params, real *work, integer *iwork, integer *info)
00028 {
00029     /* System generated locals */
00030     integer ab_dim1, ab_offset, afb_dim1, afb_offset, b_dim1, b_offset, 
00031             x_dim1, x_offset, err_bnds_norm_dim1, err_bnds_norm_offset, 
00032             err_bnds_comp_dim1, err_bnds_comp_offset, i__1;
00033     real r__1, r__2;
00034 
00035     /* Builtin functions */
00036     double sqrt(doublereal);
00037 
00038     /* Local variables */
00039     real illrcond_thresh__, unstable_thresh__, err_lbnd__;
00040     integer ref_type__;
00041     extern integer ilatrans_(char *);
00042     integer j;
00043     real rcond_tmp__;
00044     integer prec_type__, trans_type__;
00045     extern doublereal sla_gbrcond__(char *, integer *, integer *, integer *, 
00046             real *, integer *, real *, integer *, integer *, integer *, real *
00047             , integer *, real *, integer *, ftnlen);
00048     real cwise_wrong__;
00049     extern /* Subroutine */ int sla_gbrfsx_extended__(integer *, integer *, 
00050             integer *, integer *, integer *, integer *, real *, integer *, 
00051             real *, integer *, integer *, logical *, real *, real *, integer *
00052             , real *, integer *, real *, integer *, real *, real *, real *, 
00053             real *, real *, real *, real *, integer *, real *, real *, 
00054             logical *, integer *);
00055     char norm[1];
00056     logical ignore_cwise__;
00057     extern logical lsame_(char *, char *);
00058     real anorm;
00059     extern doublereal slangb_(char *, integer *, integer *, integer *, real *, 
00060              integer *, real *), slamch_(char *);
00061     extern /* Subroutine */ int sgbcon_(char *, integer *, integer *, integer 
00062             *, real *, integer *, integer *, real *, real *, real *, integer *
00063 , integer *), xerbla_(char *, integer *);
00064     logical colequ, notran, rowequ;
00065     extern integer ilaprec_(char *);
00066     integer ithresh, n_norms__;
00067     real rthresh;
00068 
00069 
00070 /*     -- LAPACK routine (version 3.2.1)                                 -- */
00071 /*     -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */
00072 /*     -- Jason Riedy of Univ. of California Berkeley.                 -- */
00073 /*     -- April 2009                                                   -- */
00074 
00075 /*     -- LAPACK is a software package provided by Univ. of Tennessee, -- */
00076 /*     -- Univ. of California Berkeley and NAG Ltd.                    -- */
00077 
00078 /*     .. */
00079 /*     .. Scalar Arguments .. */
00080 /*     .. */
00081 /*     .. Array Arguments .. */
00082 /*     .. */
00083 
00084 /*     Purpose */
00085 /*     ======= */
00086 
00087 /*     SGBRFSX improves the computed solution to a system of linear */
00088 /*     equations and provides error bounds and backward error estimates */
00089 /*     for the solution.  In addition to normwise error bound, the code */
00090 /*     provides maximum componentwise error bound if possible.  See */
00091 /*     comments for ERR_BNDS_NORM and ERR_BNDS_COMP for details of the */
00092 /*     error bounds. */
00093 
00094 /*     The original system of linear equations may have been equilibrated */
00095 /*     before calling this routine, as described by arguments EQUED, R */
00096 /*     and C below. In this case, the solution and error bounds returned */
00097 /*     are for the original unequilibrated system. */
00098 
00099 /*     Arguments */
00100 /*     ========= */
00101 
00102 /*     Some optional parameters are bundled in the PARAMS array.  These */
00103 /*     settings determine how refinement is performed, but often the */
00104 /*     defaults are acceptable.  If the defaults are acceptable, users */
00105 /*     can pass NPARAMS = 0 which prevents the source code from accessing */
00106 /*     the PARAMS argument. */
00107 
00108 /*     TRANS   (input) CHARACTER*1 */
00109 /*     Specifies the form of the system of equations: */
00110 /*       = 'N':  A * X = B     (No transpose) */
00111 /*       = 'T':  A**T * X = B  (Transpose) */
00112 /*       = 'C':  A**H * X = B  (Conjugate transpose = Transpose) */
00113 
00114 /*     EQUED   (input) CHARACTER*1 */
00115 /*     Specifies the form of equilibration that was done to A */
00116 /*     before calling this routine. This is needed to compute */
00117 /*     the solution and error bounds correctly. */
00118 /*       = 'N':  No equilibration */
00119 /*       = 'R':  Row equilibration, i.e., A has been premultiplied by */
00120 /*               diag(R). */
00121 /*       = 'C':  Column equilibration, i.e., A has been postmultiplied */
00122 /*               by diag(C). */
00123 /*       = 'B':  Both row and column equilibration, i.e., A has been */
00124 /*               replaced by diag(R) * A * diag(C). */
00125 /*               The right hand side B has been changed accordingly. */
00126 
00127 /*     N       (input) INTEGER */
00128 /*     The order of the matrix A.  N >= 0. */
00129 
00130 /*     KL      (input) INTEGER */
00131 /*     The number of subdiagonals within the band of A.  KL >= 0. */
00132 
00133 /*     KU      (input) INTEGER */
00134 /*     The number of superdiagonals within the band of A.  KU >= 0. */
00135 
00136 /*     NRHS    (input) INTEGER */
00137 /*     The number of right hand sides, i.e., the number of columns */
00138 /*     of the matrices B and X.  NRHS >= 0. */
00139 
00140 /*     AB      (input) DOUBLE PRECISION array, dimension (LDAB,N) */
00141 /*     The original band matrix A, stored in rows 1 to KL+KU+1. */
00142 /*     The j-th column of A is stored in the j-th column of the */
00143 /*     array AB as follows: */
00144 /*     AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(n,j+kl). */
00145 
00146 /*     LDAB    (input) INTEGER */
00147 /*     The leading dimension of the array AB.  LDAB >= KL+KU+1. */
00148 
00149 /*     AFB     (input) DOUBLE PRECISION array, dimension (LDAFB,N) */
00150 /*     Details of the LU factorization of the band matrix A, as */
00151 /*     computed by DGBTRF.  U is stored as an upper triangular band */
00152 /*     matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and */
00153 /*     the multipliers used during the factorization are stored in */
00154 /*     rows KL+KU+2 to 2*KL+KU+1. */
00155 
00156 /*     LDAFB   (input) INTEGER */
00157 /*     The leading dimension of the array AFB.  LDAFB >= 2*KL*KU+1. */
00158 
00159 /*     IPIV    (input) INTEGER array, dimension (N) */
00160 /*     The pivot indices from SGETRF; for 1<=i<=N, row i of the */
00161 /*     matrix was interchanged with row IPIV(i). */
00162 
00163 /*     R       (input or output) REAL array, dimension (N) */
00164 /*     The row scale factors for A.  If EQUED = 'R' or 'B', A is */
00165 /*     multiplied on the left by diag(R); if EQUED = 'N' or 'C', R */
00166 /*     is not accessed.  R is an input argument if FACT = 'F'; */
00167 /*     otherwise, R is an output argument.  If FACT = 'F' and */
00168 /*     EQUED = 'R' or 'B', each element of R must be positive. */
00169 /*     If R is output, each element of R is a power of the radix. */
00170 /*     If R is input, each element of R should be a power of the radix */
00171 /*     to ensure a reliable solution and error estimates. Scaling by */
00172 /*     powers of the radix does not cause rounding errors unless the */
00173 /*     result underflows or overflows. Rounding errors during scaling */
00174 /*     lead to refining with a matrix that is not equivalent to the */
00175 /*     input matrix, producing error estimates that may not be */
00176 /*     reliable. */
00177 
00178 /*     C       (input or output) REAL array, dimension (N) */
00179 /*     The column scale factors for A.  If EQUED = 'C' or 'B', A is */
00180 /*     multiplied on the right by diag(C); if EQUED = 'N' or 'R', C */
00181 /*     is not accessed.  C is an input argument if FACT = 'F'; */
00182 /*     otherwise, C is an output argument.  If FACT = 'F' and */
00183 /*     EQUED = 'C' or 'B', each element of C must be positive. */
00184 /*     If C is output, each element of C is a power of the radix. */
00185 /*     If C is input, each element of C should be a power of the radix */
00186 /*     to ensure a reliable solution and error estimates. Scaling by */
00187 /*     powers of the radix does not cause rounding errors unless the */
00188 /*     result underflows or overflows. Rounding errors during scaling */
00189 /*     lead to refining with a matrix that is not equivalent to the */
00190 /*     input matrix, producing error estimates that may not be */
00191 /*     reliable. */
00192 
00193 /*     B       (input) REAL array, dimension (LDB,NRHS) */
00194 /*     The right hand side matrix B. */
00195 
00196 /*     LDB     (input) INTEGER */
00197 /*     The leading dimension of the array B.  LDB >= max(1,N). */
00198 
00199 /*     X       (input/output) REAL array, dimension (LDX,NRHS) */
00200 /*     On entry, the solution matrix X, as computed by SGETRS. */
00201 /*     On exit, the improved solution matrix X. */
00202 
00203 /*     LDX     (input) INTEGER */
00204 /*     The leading dimension of the array X.  LDX >= max(1,N). */
00205 
00206 /*     RCOND   (output) REAL */
00207 /*     Reciprocal scaled condition number.  This is an estimate of the */
00208 /*     reciprocal Skeel condition number of the matrix A after */
00209 /*     equilibration (if done).  If this is less than the machine */
00210 /*     precision (in particular, if it is zero), the matrix is singular */
00211 /*     to working precision.  Note that the error may still be small even */
00212 /*     if this number is very small and the matrix appears ill- */
00213 /*     conditioned. */
00214 
00215 /*     BERR    (output) REAL array, dimension (NRHS) */
00216 /*     Componentwise relative backward error.  This is the */
00217 /*     componentwise relative backward error of each solution vector X(j) */
00218 /*     (i.e., the smallest relative change in any element of A or B that */
00219 /*     makes X(j) an exact solution). */
00220 
00221 /*     N_ERR_BNDS (input) INTEGER */
00222 /*     Number of error bounds to return for each right hand side */
00223 /*     and each type (normwise or componentwise).  See ERR_BNDS_NORM and */
00224 /*     ERR_BNDS_COMP below. */
00225 
00226 /*     ERR_BNDS_NORM  (output) REAL array, dimension (NRHS, N_ERR_BNDS) */
00227 /*     For each right-hand side, this array contains information about */
00228 /*     various error bounds and condition numbers corresponding to the */
00229 /*     normwise relative error, which is defined as follows: */
00230 
00231 /*     Normwise relative error in the ith solution vector: */
00232 /*             max_j (abs(XTRUE(j,i) - X(j,i))) */
00233 /*            ------------------------------ */
00234 /*                  max_j abs(X(j,i)) */
00235 
00236 /*     The array is indexed by the type of error information as described */
00237 /*     below. There currently are up to three pieces of information */
00238 /*     returned. */
00239 
00240 /*     The first index in ERR_BNDS_NORM(i,:) corresponds to the ith */
00241 /*     right-hand side. */
00242 
00243 /*     The second index in ERR_BNDS_NORM(:,err) contains the following */
00244 /*     three fields: */
00245 /*     err = 1 "Trust/don't trust" boolean. Trust the answer if the */
00246 /*              reciprocal condition number is less than the threshold */
00247 /*              sqrt(n) * slamch('Epsilon'). */
00248 
00249 /*     err = 2 "Guaranteed" error bound: The estimated forward error, */
00250 /*              almost certainly within a factor of 10 of the true error */
00251 /*              so long as the next entry is greater than the threshold */
00252 /*              sqrt(n) * slamch('Epsilon'). This error bound should only */
00253 /*              be trusted if the previous boolean is true. */
00254 
00255 /*     err = 3  Reciprocal condition number: Estimated normwise */
00256 /*              reciprocal condition number.  Compared with the threshold */
00257 /*              sqrt(n) * slamch('Epsilon') to determine if the error */
00258 /*              estimate is "guaranteed". These reciprocal condition */
00259 /*              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
00260 /*              appropriately scaled matrix Z. */
00261 /*              Let Z = S*A, where S scales each row by a power of the */
00262 /*              radix so all absolute row sums of Z are approximately 1. */
00263 
00264 /*     See Lapack Working Note 165 for further details and extra */
00265 /*     cautions. */
00266 
00267 /*     ERR_BNDS_COMP  (output) REAL array, dimension (NRHS, N_ERR_BNDS) */
00268 /*     For each right-hand side, this array contains information about */
00269 /*     various error bounds and condition numbers corresponding to the */
00270 /*     componentwise relative error, which is defined as follows: */
00271 
00272 /*     Componentwise relative error in the ith solution vector: */
00273 /*                    abs(XTRUE(j,i) - X(j,i)) */
00274 /*             max_j ---------------------- */
00275 /*                         abs(X(j,i)) */
00276 
00277 /*     The array is indexed by the right-hand side i (on which the */
00278 /*     componentwise relative error depends), and the type of error */
00279 /*     information as described below. There currently are up to three */
00280 /*     pieces of information returned for each right-hand side. If */
00281 /*     componentwise accuracy is not requested (PARAMS(3) = 0.0), then */
00282 /*     ERR_BNDS_COMP is not accessed.  If N_ERR_BNDS .LT. 3, then at most */
00283 /*     the first (:,N_ERR_BNDS) entries are returned. */
00284 
00285 /*     The first index in ERR_BNDS_COMP(i,:) corresponds to the ith */
00286 /*     right-hand side. */
00287 
00288 /*     The second index in ERR_BNDS_COMP(:,err) contains the following */
00289 /*     three fields: */
00290 /*     err = 1 "Trust/don't trust" boolean. Trust the answer if the */
00291 /*              reciprocal condition number is less than the threshold */
00292 /*              sqrt(n) * slamch('Epsilon'). */
00293 
00294 /*     err = 2 "Guaranteed" error bound: The estimated forward error, */
00295 /*              almost certainly within a factor of 10 of the true error */
00296 /*              so long as the next entry is greater than the threshold */
00297 /*              sqrt(n) * slamch('Epsilon'). This error bound should only */
00298 /*              be trusted if the previous boolean is true. */
00299 
00300 /*     err = 3  Reciprocal condition number: Estimated componentwise */
00301 /*              reciprocal condition number.  Compared with the threshold */
00302 /*              sqrt(n) * slamch('Epsilon') to determine if the error */
00303 /*              estimate is "guaranteed". These reciprocal condition */
00304 /*              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
00305 /*              appropriately scaled matrix Z. */
00306 /*              Let Z = S*(A*diag(x)), where x is the solution for the */
00307 /*              current right-hand side and S scales each row of */
00308 /*              A*diag(x) by a power of the radix so all absolute row */
00309 /*              sums of Z are approximately 1. */
00310 
00311 /*     See Lapack Working Note 165 for further details and extra */
00312 /*     cautions. */
00313 
00314 /*     NPARAMS (input) INTEGER */
00315 /*     Specifies the number of parameters set in PARAMS.  If .LE. 0, the */
00316 /*     PARAMS array is never referenced and default values are used. */
00317 
00318 /*     PARAMS  (input / output) REAL array, dimension NPARAMS */
00319 /*     Specifies algorithm parameters.  If an entry is .LT. 0.0, then */
00320 /*     that entry will be filled with default value used for that */
00321 /*     parameter.  Only positions up to NPARAMS are accessed; defaults */
00322 /*     are used for higher-numbered parameters. */
00323 
00324 /*       PARAMS(LA_LINRX_ITREF_I = 1) : Whether to perform iterative */
00325 /*            refinement or not. */
00326 /*         Default: 1.0 */
00327 /*            = 0.0 : No refinement is performed, and no error bounds are */
00328 /*                    computed. */
00329 /*            = 1.0 : Use the double-precision refinement algorithm, */
00330 /*                    possibly with doubled-single computations if the */
00331 /*                    compilation environment does not support DOUBLE */
00332 /*                    PRECISION. */
00333 /*              (other values are reserved for future use) */
00334 
00335 /*       PARAMS(LA_LINRX_ITHRESH_I = 2) : Maximum number of residual */
00336 /*            computations allowed for refinement. */
00337 /*         Default: 10 */
00338 /*         Aggressive: Set to 100 to permit convergence using approximate */
00339 /*                     factorizations or factorizations other than LU. If */
00340 /*                     the factorization uses a technique other than */
00341 /*                     Gaussian elimination, the guarantees in */
00342 /*                     err_bnds_norm and err_bnds_comp may no longer be */
00343 /*                     trustworthy. */
00344 
00345 /*       PARAMS(LA_LINRX_CWISE_I = 3) : Flag determining if the code */
00346 /*            will attempt to find a solution with small componentwise */
00347 /*            relative error in the double-precision algorithm.  Positive */
00348 /*            is true, 0.0 is false. */
00349 /*         Default: 1.0 (attempt componentwise convergence) */
00350 
00351 /*     WORK    (workspace) REAL array, dimension (4*N) */
00352 
00353 /*     IWORK   (workspace) INTEGER array, dimension (N) */
00354 
00355 /*     INFO    (output) INTEGER */
00356 /*       = 0:  Successful exit. The solution to every right-hand side is */
00357 /*         guaranteed. */
00358 /*       < 0:  If INFO = -i, the i-th argument had an illegal value */
00359 /*       > 0 and <= N:  U(INFO,INFO) is exactly zero.  The factorization */
00360 /*         has been completed, but the factor U is exactly singular, so */
00361 /*         the solution and error bounds could not be computed. RCOND = 0 */
00362 /*         is returned. */
00363 /*       = N+J: The solution corresponding to the Jth right-hand side is */
00364 /*         not guaranteed. The solutions corresponding to other right- */
00365 /*         hand sides K with K > J may not be guaranteed as well, but */
00366 /*         only the first such right-hand side is reported. If a small */
00367 /*         componentwise error is not requested (PARAMS(3) = 0.0) then */
00368 /*         the Jth right-hand side is the first with a normwise error */
00369 /*         bound that is not guaranteed (the smallest J such */
00370 /*         that ERR_BNDS_NORM(J,1) = 0.0). By default (PARAMS(3) = 1.0) */
00371 /*         the Jth right-hand side is the first with either a normwise or */
00372 /*         componentwise error bound that is not guaranteed (the smallest */
00373 /*         J such that either ERR_BNDS_NORM(J,1) = 0.0 or */
00374 /*         ERR_BNDS_COMP(J,1) = 0.0). See the definition of */
00375 /*         ERR_BNDS_NORM(:,1) and ERR_BNDS_COMP(:,1). To get information */
00376 /*         about all of the right-hand sides check ERR_BNDS_NORM or */
00377 /*         ERR_BNDS_COMP. */
00378 
00379 /*     ================================================================== */
00380 
00381 /*     .. Parameters .. */
00382 /*     .. */
00383 /*     .. Local Scalars .. */
00384 /*     .. */
00385 /*     .. External Subroutines .. */
00386 /*     .. */
00387 /*     .. Intrinsic Functions .. */
00388 /*     .. */
00389 /*     .. External Functions .. */
00390 /*     .. */
00391 /*     .. Executable Statements .. */
00392 
00393 /*     Check the input parameters. */
00394 
00395     /* Parameter adjustments */
00396     err_bnds_comp_dim1 = *nrhs;
00397     err_bnds_comp_offset = 1 + err_bnds_comp_dim1;
00398     err_bnds_comp__ -= err_bnds_comp_offset;
00399     err_bnds_norm_dim1 = *nrhs;
00400     err_bnds_norm_offset = 1 + err_bnds_norm_dim1;
00401     err_bnds_norm__ -= err_bnds_norm_offset;
00402     ab_dim1 = *ldab;
00403     ab_offset = 1 + ab_dim1;
00404     ab -= ab_offset;
00405     afb_dim1 = *ldafb;
00406     afb_offset = 1 + afb_dim1;
00407     afb -= afb_offset;
00408     --ipiv;
00409     --r__;
00410     --c__;
00411     b_dim1 = *ldb;
00412     b_offset = 1 + b_dim1;
00413     b -= b_offset;
00414     x_dim1 = *ldx;
00415     x_offset = 1 + x_dim1;
00416     x -= x_offset;
00417     --berr;
00418     --params;
00419     --work;
00420     --iwork;
00421 
00422     /* Function Body */
00423     *info = 0;
00424     trans_type__ = ilatrans_(trans);
00425     ref_type__ = 1;
00426     if (*nparams >= 1) {
00427         if (params[1] < 0.f) {
00428             params[1] = 1.f;
00429         } else {
00430             ref_type__ = params[1];
00431         }
00432     }
00433 
00434 /*     Set default parameters. */
00435 
00436     illrcond_thresh__ = (real) (*n) * slamch_("Epsilon");
00437     ithresh = 10;
00438     rthresh = .5f;
00439     unstable_thresh__ = .25f;
00440     ignore_cwise__ = FALSE_;
00441 
00442     if (*nparams >= 2) {
00443         if (params[2] < 0.f) {
00444             params[2] = (real) ithresh;
00445         } else {
00446             ithresh = (integer) params[2];
00447         }
00448     }
00449     if (*nparams >= 3) {
00450         if (params[3] < 0.f) {
00451             if (ignore_cwise__) {
00452                 params[3] = 0.f;
00453             } else {
00454                 params[3] = 1.f;
00455             }
00456         } else {
00457             ignore_cwise__ = params[3] == 0.f;
00458         }
00459     }
00460     if (ref_type__ == 0 || *n_err_bnds__ == 0) {
00461         n_norms__ = 0;
00462     } else if (ignore_cwise__) {
00463         n_norms__ = 1;
00464     } else {
00465         n_norms__ = 2;
00466     }
00467 
00468     notran = lsame_(trans, "N");
00469     rowequ = lsame_(equed, "R") || lsame_(equed, "B");
00470     colequ = lsame_(equed, "C") || lsame_(equed, "B");
00471 
00472 /*     Test input parameters. */
00473 
00474     if (trans_type__ == -1) {
00475         *info = -1;
00476     } else if (! rowequ && ! colequ && ! lsame_(equed, "N")) {
00477         *info = -2;
00478     } else if (*n < 0) {
00479         *info = -3;
00480     } else if (*kl < 0) {
00481         *info = -4;
00482     } else if (*ku < 0) {
00483         *info = -5;
00484     } else if (*nrhs < 0) {
00485         *info = -6;
00486     } else if (*ldab < *kl + *ku + 1) {
00487         *info = -8;
00488     } else if (*ldafb < (*kl << 1) + *ku + 1) {
00489         *info = -10;
00490     } else if (*ldb < max(1,*n)) {
00491         *info = -13;
00492     } else if (*ldx < max(1,*n)) {
00493         *info = -15;
00494     }
00495     if (*info != 0) {
00496         i__1 = -(*info);
00497         xerbla_("SGBRFSX", &i__1);
00498         return 0;
00499     }
00500 
00501 /*     Quick return if possible. */
00502 
00503     if (*n == 0 || *nrhs == 0) {
00504         *rcond = 1.f;
00505         i__1 = *nrhs;
00506         for (j = 1; j <= i__1; ++j) {
00507             berr[j] = 0.f;
00508             if (*n_err_bnds__ >= 1) {
00509                 err_bnds_norm__[j + err_bnds_norm_dim1] = 1.f;
00510                 err_bnds_comp__[j + err_bnds_comp_dim1] = 1.f;
00511             } else if (*n_err_bnds__ >= 2) {
00512                 err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 0.f;
00513                 err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 0.f;
00514             } else if (*n_err_bnds__ >= 3) {
00515                 err_bnds_norm__[j + err_bnds_norm_dim1 * 3] = 1.f;
00516                 err_bnds_comp__[j + err_bnds_comp_dim1 * 3] = 1.f;
00517             }
00518         }
00519         return 0;
00520     }
00521 
00522 /*     Default to failure. */
00523 
00524     *rcond = 0.f;
00525     i__1 = *nrhs;
00526     for (j = 1; j <= i__1; ++j) {
00527         berr[j] = 1.f;
00528         if (*n_err_bnds__ >= 1) {
00529             err_bnds_norm__[j + err_bnds_norm_dim1] = 1.f;
00530             err_bnds_comp__[j + err_bnds_comp_dim1] = 1.f;
00531         } else if (*n_err_bnds__ >= 2) {
00532             err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 1.f;
00533             err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 1.f;
00534         } else if (*n_err_bnds__ >= 3) {
00535             err_bnds_norm__[j + err_bnds_norm_dim1 * 3] = 0.f;
00536             err_bnds_comp__[j + err_bnds_comp_dim1 * 3] = 0.f;
00537         }
00538     }
00539 
00540 /*     Compute the norm of A and the reciprocal of the condition */
00541 /*     number of A. */
00542 
00543     if (notran) {
00544         *(unsigned char *)norm = 'I';
00545     } else {
00546         *(unsigned char *)norm = '1';
00547     }
00548     anorm = slangb_(norm, n, kl, ku, &ab[ab_offset], ldab, &work[1]);
00549     sgbcon_(norm, n, kl, ku, &afb[afb_offset], ldafb, &ipiv[1], &anorm, rcond, 
00550              &work[1], &iwork[1], info);
00551 
00552 /*     Perform refinement on each right-hand side */
00553 
00554     if (ref_type__ != 0) {
00555         prec_type__ = ilaprec_("D");
00556         if (notran) {
00557             sla_gbrfsx_extended__(&prec_type__, &trans_type__, n, kl, ku, 
00558                     nrhs, &ab[ab_offset], ldab, &afb[afb_offset], ldafb, &
00559                     ipiv[1], &colequ, &c__[1], &b[b_offset], ldb, &x[x_offset]
00560                     , ldx, &berr[1], &n_norms__, &err_bnds_norm__[
00561                     err_bnds_norm_offset], &err_bnds_comp__[
00562                     err_bnds_comp_offset], &work[*n + 1], &work[1], &work[(*n 
00563                     << 1) + 1], &work[1], rcond, &ithresh, &rthresh, &
00564                     unstable_thresh__, &ignore_cwise__, info);
00565         } else {
00566             sla_gbrfsx_extended__(&prec_type__, &trans_type__, n, kl, ku, 
00567                     nrhs, &ab[ab_offset], ldab, &afb[afb_offset], ldafb, &
00568                     ipiv[1], &rowequ, &r__[1], &b[b_offset], ldb, &x[x_offset]
00569                     , ldx, &berr[1], &n_norms__, &err_bnds_norm__[
00570                     err_bnds_norm_offset], &err_bnds_comp__[
00571                     err_bnds_comp_offset], &work[*n + 1], &work[1], &work[(*n 
00572                     << 1) + 1], &work[1], rcond, &ithresh, &rthresh, &
00573                     unstable_thresh__, &ignore_cwise__, info);
00574         }
00575     }
00576 /* Computing MAX */
00577     r__1 = 10.f, r__2 = sqrt((real) (*n));
00578     err_lbnd__ = dmax(r__1,r__2) * slamch_("Epsilon");
00579     if (*n_err_bnds__ >= 1 && n_norms__ >= 1) {
00580 
00581 /*     Compute scaled normwise condition number cond(A*C). */
00582 
00583         if (colequ && notran) {
00584             rcond_tmp__ = sla_gbrcond__(trans, n, kl, ku, &ab[ab_offset], 
00585                     ldab, &afb[afb_offset], ldafb, &ipiv[1], &c_n1, &c__[1], 
00586                     info, &work[1], &iwork[1], (ftnlen)1);
00587         } else if (rowequ && ! notran) {
00588             rcond_tmp__ = sla_gbrcond__(trans, n, kl, ku, &ab[ab_offset], 
00589                     ldab, &afb[afb_offset], ldafb, &ipiv[1], &c_n1, &r__[1], 
00590                     info, &work[1], &iwork[1], (ftnlen)1);
00591         } else {
00592             rcond_tmp__ = sla_gbrcond__(trans, n, kl, ku, &ab[ab_offset], 
00593                     ldab, &afb[afb_offset], ldafb, &ipiv[1], &c__0, &r__[1], 
00594                     info, &work[1], &iwork[1], (ftnlen)1);
00595         }
00596         i__1 = *nrhs;
00597         for (j = 1; j <= i__1; ++j) {
00598 
00599 /*     Cap the error at 1.0. */
00600 
00601             if (*n_err_bnds__ >= 2 && err_bnds_norm__[j + (err_bnds_norm_dim1 
00602                     << 1)] > 1.f) {
00603                 err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 1.f;
00604             }
00605 
00606 /*     Threshold the error (see LAWN). */
00607 
00608             if (rcond_tmp__ < illrcond_thresh__) {
00609                 err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 1.f;
00610                 err_bnds_norm__[j + err_bnds_norm_dim1] = 0.f;
00611                 if (*info <= *n) {
00612                     *info = *n + j;
00613                 }
00614             } else if (err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] < 
00615                     err_lbnd__) {
00616                 err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = err_lbnd__;
00617                 err_bnds_norm__[j + err_bnds_norm_dim1] = 1.f;
00618             }
00619 
00620 /*     Save the condition number. */
00621 
00622             if (*n_err_bnds__ >= 3) {
00623                 err_bnds_norm__[j + err_bnds_norm_dim1 * 3] = rcond_tmp__;
00624             }
00625         }
00626     }
00627     if (*n_err_bnds__ >= 1 && n_norms__ >= 2) {
00628 
00629 /*     Compute componentwise condition number cond(A*diag(Y(:,J))) for */
00630 /*     each right-hand side using the current solution as an estimate of */
00631 /*     the true solution.  If the componentwise error estimate is too */
00632 /*     large, then the solution is a lousy estimate of truth and the */
00633 /*     estimated RCOND may be too optimistic.  To avoid misleading users, */
00634 /*     the inverse condition number is set to 0.0 when the estimated */
00635 /*     cwise error is at least CWISE_WRONG. */
00636 
00637         cwise_wrong__ = sqrt(slamch_("Epsilon"));
00638         i__1 = *nrhs;
00639         for (j = 1; j <= i__1; ++j) {
00640             if (err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] < 
00641                     cwise_wrong__) {
00642                 rcond_tmp__ = sla_gbrcond__(trans, n, kl, ku, &ab[ab_offset], 
00643                         ldab, &afb[afb_offset], ldafb, &ipiv[1], &c__1, &x[j *
00644                          x_dim1 + 1], info, &work[1], &iwork[1], (ftnlen)1);
00645             } else {
00646                 rcond_tmp__ = 0.f;
00647             }
00648 
00649 /*     Cap the error at 1.0. */
00650 
00651             if (*n_err_bnds__ >= 2 && err_bnds_comp__[j + (err_bnds_comp_dim1 
00652                     << 1)] > 1.f) {
00653                 err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 1.f;
00654             }
00655 
00656 /*     Threshold the error (see LAWN). */
00657 
00658             if (rcond_tmp__ < illrcond_thresh__) {
00659                 err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 1.f;
00660                 err_bnds_comp__[j + err_bnds_comp_dim1] = 0.f;
00661                 if (params[3] == 1.f && *info < *n + j) {
00662                     *info = *n + j;
00663                 }
00664             } else if (err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] < 
00665                     err_lbnd__) {
00666                 err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = err_lbnd__;
00667                 err_bnds_comp__[j + err_bnds_comp_dim1] = 1.f;
00668             }
00669 
00670 /*     Save the condition number. */
00671 
00672             if (*n_err_bnds__ >= 3) {
00673                 err_bnds_comp__[j + err_bnds_comp_dim1 * 3] = rcond_tmp__;
00674             }
00675         }
00676     }
00677 
00678     return 0;
00679 
00680 /*     End of SGBRFSX */
00681 
00682 } /* sgbrfsx_ */


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