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


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