LAPACK 3.3.1
Linear Algebra PACKage

sgbsvxx.f

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