LAPACK 3.3.1
Linear Algebra PACKage

sgesvxx.f

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