LAPACK 3.3.0

zgbsvxx.f

Go to the documentation of this file.
00001       SUBROUTINE ZGBSVXX( 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, RWORK, INFO )
00006 *
00007 *     -- LAPACK driver routine (version 3.2.2)                          --
00008 *     -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and --
00009 *     -- Jason Riedy of Univ. of California Berkeley.                 --
00010 *     -- June 2010                                                    --
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       DOUBLE PRECISION   RCOND, RPVGRW
00022 *     ..
00023 *     .. Array Arguments ..
00024       INTEGER            IPIV( * )
00025       COMPLEX*16         AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ),
00026      $                   X( LDX , * ),WORK( * )
00027       DOUBLE PRECISION   R( * ), C( * ), PARAMS( * ), BERR( * ),
00028      $                   ERR_BNDS_NORM( NRHS, * ),
00029      $                   ERR_BNDS_COMP( NRHS, * ), RWORK( * )
00030 *     ..
00031 *
00032 *     Purpose
00033 *     =======
00034 *
00035 *     ZGBSVXX uses the LU factorization to compute the solution to a
00036 *     complex*16 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. ZGBSVXX 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 *     ZGBSVXX 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 *     ZGBSVXX 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 ZGBSVXX would itself produce.
00053 *
00054 *     Description
00055 *     ===========
00056 *
00057 *     The following steps are performed:
00058 *
00059 *     1. If FACT = 'E', double precision 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) COMPLEX*16 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) COMPLEX*16 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 ZGBTRF.  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 DGETRF; 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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) COMPLEX*16 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) COMPLEX*16 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) DOUBLE PRECISION
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) DOUBLE PRECISION
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 DGESVX, this quantity is
00275 *     returned in WORK(1).
00276 *
00277 *     BERR    (output) DOUBLE PRECISION 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) DOUBLE PRECISION 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) * dlamch('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) * dlamch('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) * dlamch('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) DOUBLE PRECISION 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) * dlamch('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) * dlamch('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) * dlamch('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) DOUBLE PRECISION 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.0D+0
00389 *            = 0.0 : No refinement is performed, and no error bounds are
00390 *                    computed.
00391 *            = 1.0 : Use the extra-precise refinement algorithm.
00392 *              (other values are reserved for future use)
00393 *
00394 *       PARAMS(LA_LINRX_ITHRESH_I = 2) : Maximum number of residual
00395 *            computations allowed for refinement.
00396 *         Default: 10
00397 *         Aggressive: Set to 100 to permit convergence using approximate
00398 *                     factorizations or factorizations other than LU. If
00399 *                     the factorization uses a technique other than
00400 *                     Gaussian elimination, the guarantees in
00401 *                     err_bnds_norm and err_bnds_comp may no longer be
00402 *                     trustworthy.
00403 *
00404 *       PARAMS(LA_LINRX_CWISE_I = 3) : Flag determining if the code
00405 *            will attempt to find a solution with small componentwise
00406 *            relative error in the double-precision algorithm.  Positive
00407 *            is true, 0.0 is false.
00408 *         Default: 1.0 (attempt componentwise convergence)
00409 *
00410 *     WORK    (workspace) COMPLEX*16 array, dimension (2*N)
00411 *
00412 *     RWORK   (workspace) DOUBLE PRECISION array, dimension (2*N)
00413 *
00414 *     INFO    (output) INTEGER
00415 *       = 0:  Successful exit. The solution to every right-hand side is
00416 *         guaranteed.
00417 *       < 0:  If INFO = -i, the i-th argument had an illegal value
00418 *       > 0 and <= N:  U(INFO,INFO) is exactly zero.  The factorization
00419 *         has been completed, but the factor U is exactly singular, so
00420 *         the solution and error bounds could not be computed. RCOND = 0
00421 *         is returned.
00422 *       = N+J: The solution corresponding to the Jth right-hand side is
00423 *         not guaranteed. The solutions corresponding to other right-
00424 *         hand sides K with K > J may not be guaranteed as well, but
00425 *         only the first such right-hand side is reported. If a small
00426 *         componentwise error is not requested (PARAMS(3) = 0.0) then
00427 *         the Jth right-hand side is the first with a normwise error
00428 *         bound that is not guaranteed (the smallest J such
00429 *         that ERR_BNDS_NORM(J,1) = 0.0). By default (PARAMS(3) = 1.0)
00430 *         the Jth right-hand side is the first with either a normwise or
00431 *         componentwise error bound that is not guaranteed (the smallest
00432 *         J such that either ERR_BNDS_NORM(J,1) = 0.0 or
00433 *         ERR_BNDS_COMP(J,1) = 0.0). See the definition of
00434 *         ERR_BNDS_NORM(:,1) and ERR_BNDS_COMP(:,1). To get information
00435 *         about all of the right-hand sides check ERR_BNDS_NORM or
00436 *         ERR_BNDS_COMP.
00437 *
00438 *     ==================================================================
00439 *
00440 *     .. Parameters ..
00441       DOUBLE PRECISION   ZERO, ONE
00442       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00443       INTEGER            FINAL_NRM_ERR_I, FINAL_CMP_ERR_I, BERR_I
00444       INTEGER            RCOND_I, NRM_RCOND_I, NRM_ERR_I, CMP_RCOND_I
00445       INTEGER            CMP_ERR_I, PIV_GROWTH_I
00446       PARAMETER          ( FINAL_NRM_ERR_I = 1, FINAL_CMP_ERR_I = 2,
00447      $                   BERR_I = 3 )
00448       PARAMETER          ( RCOND_I = 4, NRM_RCOND_I = 5, NRM_ERR_I = 6 )
00449       PARAMETER          ( CMP_RCOND_I = 7, CMP_ERR_I = 8,
00450      $                   PIV_GROWTH_I = 9 )
00451 *     ..
00452 *     .. Local Scalars ..
00453       LOGICAL            COLEQU, EQUIL, NOFACT, NOTRAN, ROWEQU
00454       INTEGER            INFEQU, I, J, KL, KU
00455       DOUBLE PRECISION   AMAX, BIGNUM, COLCND, RCMAX, RCMIN,
00456      $                   ROWCND, SMLNUM
00457 *     ..
00458 *     .. External Functions ..
00459       EXTERNAL           LSAME, DLAMCH, ZLA_GBRPVGRW
00460       LOGICAL            LSAME
00461       DOUBLE PRECISION   DLAMCH, ZLA_GBRPVGRW
00462 *     ..
00463 *     .. External Subroutines ..
00464       EXTERNAL           ZGBEQUB, ZGBTRF, ZGBTRS, ZLACPY, ZLAQGB,
00465      $                   XERBLA, ZLASCL2, ZGBRFSX
00466 *     ..
00467 *     .. Intrinsic Functions ..
00468       INTRINSIC          MAX, MIN
00469 *     ..
00470 *     .. Executable Statements ..
00471 *
00472       INFO = 0
00473       NOFACT = LSAME( FACT, 'N' )
00474       EQUIL = LSAME( FACT, 'E' )
00475       NOTRAN = LSAME( TRANS, 'N' )
00476       SMLNUM = DLAMCH( 'Safe minimum' )
00477       BIGNUM = ONE / SMLNUM
00478       IF( NOFACT .OR. EQUIL ) THEN
00479          EQUED = 'N'
00480          ROWEQU = .FALSE.
00481          COLEQU = .FALSE.
00482       ELSE
00483          ROWEQU = LSAME( EQUED, 'R' ) .OR. LSAME( EQUED, 'B' )
00484          COLEQU = LSAME( EQUED, 'C' ) .OR. LSAME( EQUED, 'B' )
00485       END IF
00486 *
00487 *     Default is failure.  If an input parameter is wrong or
00488 *     factorization fails, make everything look horrible.  Only the
00489 *     pivot growth is set here, the rest is initialized in ZGBRFSX.
00490 *
00491       RPVGRW = ZERO
00492 *
00493 *     Test the input parameters.  PARAMS is not tested until DGERFSX.
00494 *
00495       IF( .NOT.NOFACT .AND. .NOT.EQUIL .AND. .NOT.
00496      $     LSAME( FACT, 'F' ) ) THEN
00497          INFO = -1
00498       ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) .AND. .NOT.
00499      $        LSAME( TRANS, 'C' ) ) THEN
00500          INFO = -2
00501       ELSE IF( N.LT.0 ) THEN
00502          INFO = -3
00503       ELSE IF( KL.LT.0 ) THEN
00504          INFO = -4
00505       ELSE IF( KU.LT.0 ) THEN
00506          INFO = -5
00507       ELSE IF( NRHS.LT.0 ) THEN
00508          INFO = -6
00509       ELSE IF( LDAB.LT.KL+KU+1 ) THEN
00510          INFO = -8
00511       ELSE IF( LDAFB.LT.2*KL+KU+1 ) THEN
00512          INFO = -10
00513       ELSE IF( LSAME( FACT, 'F' ) .AND. .NOT.
00514      $        ( ROWEQU .OR. COLEQU .OR. LSAME( EQUED, 'N' ) ) ) THEN
00515          INFO = -12
00516       ELSE
00517          IF( ROWEQU ) THEN
00518             RCMIN = BIGNUM
00519             RCMAX = ZERO
00520             DO 10 J = 1, N
00521                RCMIN = MIN( RCMIN, R( J ) )
00522                RCMAX = MAX( RCMAX, R( J ) )
00523  10         CONTINUE
00524             IF( RCMIN.LE.ZERO ) THEN
00525                INFO = -13
00526             ELSE IF( N.GT.0 ) THEN
00527                ROWCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )
00528             ELSE
00529                ROWCND = ONE
00530             END IF
00531          END IF
00532          IF( COLEQU .AND. INFO.EQ.0 ) THEN
00533             RCMIN = BIGNUM
00534             RCMAX = ZERO
00535             DO 20 J = 1, N
00536                RCMIN = MIN( RCMIN, C( J ) )
00537                RCMAX = MAX( RCMAX, C( J ) )
00538  20         CONTINUE
00539             IF( RCMIN.LE.ZERO ) THEN
00540                INFO = -14
00541             ELSE IF( N.GT.0 ) THEN
00542                COLCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )
00543             ELSE
00544                COLCND = ONE
00545             END IF
00546          END IF
00547          IF( INFO.EQ.0 ) THEN
00548             IF( LDB.LT.MAX( 1, N ) ) THEN
00549                INFO = -15
00550             ELSE IF( LDX.LT.MAX( 1, N ) ) THEN
00551                INFO = -16
00552             END IF
00553          END IF
00554       END IF
00555 *
00556       IF( INFO.NE.0 ) THEN
00557          CALL XERBLA( 'ZGBSVXX', -INFO )
00558          RETURN
00559       END IF
00560 *
00561       IF( EQUIL ) THEN
00562 *
00563 *     Compute row and column scalings to equilibrate the matrix A.
00564 *
00565          CALL ZGBEQUB( N, N, KL, KU, AB, LDAB, R, C, ROWCND, COLCND,
00566      $        AMAX, INFEQU )
00567          IF( INFEQU.EQ.0 ) THEN
00568 *
00569 *     Equilibrate the matrix.
00570 *
00571             CALL ZLAQGB( N, N, KL, KU, AB, LDAB, R, C, ROWCND, COLCND,
00572      $           AMAX, EQUED )
00573             ROWEQU = LSAME( EQUED, 'R' ) .OR. LSAME( EQUED, 'B' )
00574             COLEQU = LSAME( EQUED, 'C' ) .OR. LSAME( EQUED, 'B' )
00575          END IF
00576 *
00577 *     If the scaling factors are not applied, set them to 1.0.
00578 *
00579          IF ( .NOT.ROWEQU ) THEN
00580             DO J = 1, N
00581                R( J ) = 1.0D+0
00582             END DO
00583          END IF
00584          IF ( .NOT.COLEQU ) THEN
00585             DO J = 1, N
00586                C( J ) = 1.0D+0
00587             END DO
00588          END IF
00589       END IF
00590 *
00591 *     Scale the right-hand side.
00592 *
00593       IF( NOTRAN ) THEN
00594          IF( ROWEQU ) CALL ZLASCL2( N, NRHS, R, B, LDB )
00595       ELSE
00596          IF( COLEQU ) CALL ZLASCL2( N, NRHS, C, B, LDB )
00597       END IF
00598 *
00599       IF( NOFACT .OR. EQUIL ) THEN
00600 *
00601 *        Compute the LU factorization of A.
00602 *
00603          DO 40, J = 1, N
00604             DO 30, I = KL+1, 2*KL+KU+1
00605                AFB( I, J ) = AB( I-KL, J )
00606  30         CONTINUE
00607  40      CONTINUE
00608          CALL ZGBTRF( N, N, KL, KU, AFB, LDAFB, IPIV, INFO )
00609 *
00610 *        Return if INFO is non-zero.
00611 *
00612          IF( INFO.GT.0 ) THEN
00613 *
00614 *           Pivot in column INFO is exactly 0
00615 *           Compute the reciprocal pivot growth factor of the
00616 *           leading rank-deficient INFO columns of A.
00617 *
00618             RPVGRW = ZLA_GBRPVGRW( N, KL, KU, INFO, AB, LDAB, AFB,
00619      $           LDAFB )
00620             RETURN
00621          END IF
00622       END IF
00623 *
00624 *     Compute the reciprocal pivot growth factor RPVGRW.
00625 *
00626       RPVGRW = ZLA_GBRPVGRW( N, KL, KU, N, AB, LDAB, AFB, LDAFB )
00627 *
00628 *     Compute the solution matrix X.
00629 *
00630       CALL ZLACPY( 'Full', N, NRHS, B, LDB, X, LDX )
00631       CALL ZGBTRS( TRANS, N, KL, KU, NRHS, AFB, LDAFB, IPIV, X, LDX,
00632      $     INFO )
00633 *
00634 *     Use iterative refinement to improve the computed solution and
00635 *     compute error bounds and backward error estimates for it.
00636 *
00637       CALL ZGBRFSX( TRANS, EQUED, N, KL, KU, NRHS, AB, LDAB, AFB, LDAFB,
00638      $     IPIV, R, C, B, LDB, X, LDX, RCOND, BERR,
00639      $     N_ERR_BNDS, ERR_BNDS_NORM, ERR_BNDS_COMP, NPARAMS, PARAMS,
00640      $     WORK, RWORK, INFO )
00641 
00642 *
00643 *     Scale solutions.
00644 *
00645       IF ( COLEQU .AND. NOTRAN ) THEN
00646          CALL ZLASCL2( N, NRHS, C, X, LDX )
00647       ELSE IF ( ROWEQU .AND. .NOT.NOTRAN ) THEN
00648          CALL ZLASCL2( N, NRHS, R, X, LDX )
00649       END IF
00650 *
00651       RETURN
00652 *
00653 *     End of ZGBSVXX
00654 *
00655       END
 All Files Functions