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


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