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


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