LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
dgbsvx.f
Go to the documentation of this file.
00001 *> \brief <b> DGBSVX computes the solution to system of linear equations A * X = B for GB matrices</b>
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download DGBSVX + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgbsvx.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgbsvx.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgbsvx.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE DGBSVX( FACT, TRANS, N, KL, KU, NRHS, AB, LDAB, AFB,
00022 *                          LDAFB, IPIV, EQUED, R, C, B, LDB, X, LDX,
00023 *                          RCOND, FERR, BERR, WORK, IWORK, INFO )
00024 * 
00025 *       .. Scalar Arguments ..
00026 *       CHARACTER          EQUED, FACT, TRANS
00027 *       INTEGER            INFO, KL, KU, LDAB, LDAFB, LDB, LDX, N, NRHS
00028 *       DOUBLE PRECISION   RCOND
00029 *       ..
00030 *       .. Array Arguments ..
00031 *       INTEGER            IPIV( * ), IWORK( * )
00032 *       DOUBLE PRECISION   AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ),
00033 *      $                   BERR( * ), C( * ), FERR( * ), R( * ),
00034 *      $                   WORK( * ), X( LDX, * )
00035 *       ..
00036 *  
00037 *
00038 *> \par Purpose:
00039 *  =============
00040 *>
00041 *> \verbatim
00042 *>
00043 *> DGBSVX uses the LU factorization to compute the solution to a real
00044 *> system of linear equations A * X = B, A**T * X = B, or A**H * X = B,
00045 *> where A is a band matrix of order N with KL subdiagonals and KU
00046 *> superdiagonals, and X and B are N-by-NRHS matrices.
00047 *>
00048 *> Error bounds on the solution and a condition estimate are also
00049 *> provided.
00050 *> \endverbatim
00051 *
00052 *> \par Description:
00053 *  =================
00054 *>
00055 *> \verbatim
00056 *>
00057 *> The following steps are performed by this subroutine:
00058 *>
00059 *> 1. If FACT = 'E', real scaling factors are computed to equilibrate
00060 *>    the system:
00061 *>       TRANS = 'N':  diag(R)*A*diag(C)     *inv(diag(C))*X = diag(R)*B
00062 *>       TRANS = 'T': (diag(R)*A*diag(C))**T *inv(diag(R))*X = diag(C)*B
00063 *>       TRANS = 'C': (diag(R)*A*diag(C))**H *inv(diag(R))*X = diag(C)*B
00064 *>    Whether or not the system will be equilibrated depends on the
00065 *>    scaling of the matrix A, but if equilibration is used, A is
00066 *>    overwritten by diag(R)*A*diag(C) and B by diag(R)*B (if TRANS='N')
00067 *>    or diag(C)*B (if TRANS = 'T' or 'C').
00068 *>
00069 *> 2. If FACT = 'N' or 'E', the LU decomposition is used to factor the
00070 *>    matrix A (after equilibration if FACT = 'E') as
00071 *>       A = L * U,
00072 *>    where L is a product of permutation and unit lower triangular
00073 *>    matrices with KL subdiagonals, and U is upper triangular with
00074 *>    KL+KU superdiagonals.
00075 *>
00076 *> 3. If some U(i,i)=0, so that U is exactly singular, then the routine
00077 *>    returns with INFO = i. Otherwise, the factored form of A is used
00078 *>    to estimate the condition number of the matrix A.  If the
00079 *>    reciprocal of the condition number is less than machine precision,
00080 *>    INFO = N+1 is returned as a warning, but the routine still goes on
00081 *>    to solve for X and compute error bounds as described below.
00082 *>
00083 *> 4. The system of equations is solved for X using the factored form
00084 *>    of A.
00085 *>
00086 *> 5. Iterative refinement is applied to improve the computed solution
00087 *>    matrix and calculate error bounds and backward error estimates
00088 *>    for it.
00089 *>
00090 *> 6. If equilibration was used, the matrix X is premultiplied by
00091 *>    diag(C) (if TRANS = 'N') or diag(R) (if TRANS = 'T' or 'C') so
00092 *>    that it solves the original system before equilibration.
00093 *> \endverbatim
00094 *
00095 *  Arguments:
00096 *  ==========
00097 *
00098 *> \param[in] FACT
00099 *> \verbatim
00100 *>          FACT is CHARACTER*1
00101 *>          Specifies whether or not the factored form of the matrix A is
00102 *>          supplied on entry, and if not, whether the matrix A should be
00103 *>          equilibrated before it is factored.
00104 *>          = 'F':  On entry, AFB and IPIV contain the factored form of
00105 *>                  A.  If EQUED is not 'N', the matrix A has been
00106 *>                  equilibrated with scaling factors given by R and C.
00107 *>                  AB, AFB, and IPIV are not modified.
00108 *>          = 'N':  The matrix A will be copied to AFB and factored.
00109 *>          = 'E':  The matrix A will be equilibrated if necessary, then
00110 *>                  copied to AFB and factored.
00111 *> \endverbatim
00112 *>
00113 *> \param[in] TRANS
00114 *> \verbatim
00115 *>          TRANS is CHARACTER*1
00116 *>          Specifies the form of the system of equations.
00117 *>          = 'N':  A * X = B     (No transpose)
00118 *>          = 'T':  A**T * X = B  (Transpose)
00119 *>          = 'C':  A**H * X = B  (Transpose)
00120 *> \endverbatim
00121 *>
00122 *> \param[in] N
00123 *> \verbatim
00124 *>          N is INTEGER
00125 *>          The number of linear equations, i.e., the order of the
00126 *>          matrix A.  N >= 0.
00127 *> \endverbatim
00128 *>
00129 *> \param[in] KL
00130 *> \verbatim
00131 *>          KL is INTEGER
00132 *>          The number of subdiagonals within the band of A.  KL >= 0.
00133 *> \endverbatim
00134 *>
00135 *> \param[in] KU
00136 *> \verbatim
00137 *>          KU is INTEGER
00138 *>          The number of superdiagonals within the band of A.  KU >= 0.
00139 *> \endverbatim
00140 *>
00141 *> \param[in] NRHS
00142 *> \verbatim
00143 *>          NRHS is INTEGER
00144 *>          The number of right hand sides, i.e., the number of columns
00145 *>          of the matrices B and X.  NRHS >= 0.
00146 *> \endverbatim
00147 *>
00148 *> \param[in,out] AB
00149 *> \verbatim
00150 *>          AB is DOUBLE PRECISION array, dimension (LDAB,N)
00151 *>          On entry, the matrix A in band storage, in rows 1 to KL+KU+1.
00152 *>          The j-th column of A is stored in the j-th column of the
00153 *>          array AB as follows:
00154 *>          AB(KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+kl)
00155 *>
00156 *>          If FACT = 'F' and EQUED is not 'N', then A must have been
00157 *>          equilibrated by the scaling factors in R and/or C.  AB is not
00158 *>          modified if FACT = 'F' or 'N', or if FACT = 'E' and
00159 *>          EQUED = 'N' on exit.
00160 *>
00161 *>          On exit, if EQUED .ne. 'N', A is scaled as follows:
00162 *>          EQUED = 'R':  A := diag(R) * A
00163 *>          EQUED = 'C':  A := A * diag(C)
00164 *>          EQUED = 'B':  A := diag(R) * A * diag(C).
00165 *> \endverbatim
00166 *>
00167 *> \param[in] LDAB
00168 *> \verbatim
00169 *>          LDAB is INTEGER
00170 *>          The leading dimension of the array AB.  LDAB >= KL+KU+1.
00171 *> \endverbatim
00172 *>
00173 *> \param[in,out] AFB
00174 *> \verbatim
00175 *>          AFB is DOUBLE PRECISION array, dimension (LDAFB,N)
00176 *>          If FACT = 'F', then AFB is an input argument and on entry
00177 *>          contains details of the LU factorization of the band matrix
00178 *>          A, as computed by DGBTRF.  U is stored as an upper triangular
00179 *>          band matrix with KL+KU superdiagonals in rows 1 to KL+KU+1,
00180 *>          and the multipliers used during the factorization are stored
00181 *>          in rows KL+KU+2 to 2*KL+KU+1.  If EQUED .ne. 'N', then AFB is
00182 *>          the factored form of the equilibrated matrix A.
00183 *>
00184 *>          If FACT = 'N', then AFB is an output argument and on exit
00185 *>          returns details of the LU factorization of A.
00186 *>
00187 *>          If FACT = 'E', then AFB is an output argument and on exit
00188 *>          returns details of the LU factorization of the equilibrated
00189 *>          matrix A (see the description of AB for the form of the
00190 *>          equilibrated matrix).
00191 *> \endverbatim
00192 *>
00193 *> \param[in] LDAFB
00194 *> \verbatim
00195 *>          LDAFB is INTEGER
00196 *>          The leading dimension of the array AFB.  LDAFB >= 2*KL+KU+1.
00197 *> \endverbatim
00198 *>
00199 *> \param[in,out] IPIV
00200 *> \verbatim
00201 *>          IPIV is INTEGER array, dimension (N)
00202 *>          If FACT = 'F', then IPIV is an input argument and on entry
00203 *>          contains the pivot indices from the factorization A = L*U
00204 *>          as computed by DGBTRF; row i of the matrix was interchanged
00205 *>          with row IPIV(i).
00206 *>
00207 *>          If FACT = 'N', then IPIV is an output argument and on exit
00208 *>          contains the pivot indices from the factorization A = L*U
00209 *>          of the original matrix A.
00210 *>
00211 *>          If FACT = 'E', then IPIV is an output argument and on exit
00212 *>          contains the pivot indices from the factorization A = L*U
00213 *>          of the equilibrated matrix A.
00214 *> \endverbatim
00215 *>
00216 *> \param[in,out] EQUED
00217 *> \verbatim
00218 *>          EQUED is CHARACTER*1
00219 *>          Specifies the form of equilibration that was done.
00220 *>          = 'N':  No equilibration (always true if FACT = 'N').
00221 *>          = 'R':  Row equilibration, i.e., A has been premultiplied by
00222 *>                  diag(R).
00223 *>          = 'C':  Column equilibration, i.e., A has been postmultiplied
00224 *>                  by diag(C).
00225 *>          = 'B':  Both row and column equilibration, i.e., A has been
00226 *>                  replaced by diag(R) * A * diag(C).
00227 *>          EQUED is an input argument if FACT = 'F'; otherwise, it is an
00228 *>          output argument.
00229 *> \endverbatim
00230 *>
00231 *> \param[in,out] R
00232 *> \verbatim
00233 *>          R is DOUBLE PRECISION array, dimension (N)
00234 *>          The row scale factors for A.  If EQUED = 'R' or 'B', A is
00235 *>          multiplied on the left by diag(R); if EQUED = 'N' or 'C', R
00236 *>          is not accessed.  R is an input argument if FACT = 'F';
00237 *>          otherwise, R is an output argument.  If FACT = 'F' and
00238 *>          EQUED = 'R' or 'B', each element of R must be positive.
00239 *> \endverbatim
00240 *>
00241 *> \param[in,out] C
00242 *> \verbatim
00243 *>          C is DOUBLE PRECISION array, dimension (N)
00244 *>          The column scale factors for A.  If EQUED = 'C' or 'B', A is
00245 *>          multiplied on the right by diag(C); if EQUED = 'N' or 'R', C
00246 *>          is not accessed.  C is an input argument if FACT = 'F';
00247 *>          otherwise, C is an output argument.  If FACT = 'F' and
00248 *>          EQUED = 'C' or 'B', each element of C must be positive.
00249 *> \endverbatim
00250 *>
00251 *> \param[in,out] B
00252 *> \verbatim
00253 *>          B is DOUBLE PRECISION array, dimension (LDB,NRHS)
00254 *>          On entry, the right hand side matrix B.
00255 *>          On exit,
00256 *>          if EQUED = 'N', B is not modified;
00257 *>          if TRANS = 'N' and EQUED = 'R' or 'B', B is overwritten by
00258 *>          diag(R)*B;
00259 *>          if TRANS = 'T' or 'C' and EQUED = 'C' or 'B', B is
00260 *>          overwritten by diag(C)*B.
00261 *> \endverbatim
00262 *>
00263 *> \param[in] LDB
00264 *> \verbatim
00265 *>          LDB is INTEGER
00266 *>          The leading dimension of the array B.  LDB >= max(1,N).
00267 *> \endverbatim
00268 *>
00269 *> \param[out] X
00270 *> \verbatim
00271 *>          X is DOUBLE PRECISION array, dimension (LDX,NRHS)
00272 *>          If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X
00273 *>          to the original system of equations.  Note that A and B are
00274 *>          modified on exit if EQUED .ne. 'N', and the solution to the
00275 *>          equilibrated system is inv(diag(C))*X if TRANS = 'N' and
00276 *>          EQUED = 'C' or 'B', or inv(diag(R))*X if TRANS = 'T' or 'C'
00277 *>          and EQUED = 'R' or 'B'.
00278 *> \endverbatim
00279 *>
00280 *> \param[in] LDX
00281 *> \verbatim
00282 *>          LDX is INTEGER
00283 *>          The leading dimension of the array X.  LDX >= max(1,N).
00284 *> \endverbatim
00285 *>
00286 *> \param[out] RCOND
00287 *> \verbatim
00288 *>          RCOND is DOUBLE PRECISION
00289 *>          The estimate of the reciprocal condition number of the matrix
00290 *>          A after equilibration (if done).  If RCOND is less than the
00291 *>          machine precision (in particular, if RCOND = 0), the matrix
00292 *>          is singular to working precision.  This condition is
00293 *>          indicated by a return code of INFO > 0.
00294 *> \endverbatim
00295 *>
00296 *> \param[out] FERR
00297 *> \verbatim
00298 *>          FERR is DOUBLE PRECISION array, dimension (NRHS)
00299 *>          The estimated forward error bound for each solution vector
00300 *>          X(j) (the j-th column of the solution matrix X).
00301 *>          If XTRUE is the true solution corresponding to X(j), FERR(j)
00302 *>          is an estimated upper bound for the magnitude of the largest
00303 *>          element in (X(j) - XTRUE) divided by the magnitude of the
00304 *>          largest element in X(j).  The estimate is as reliable as
00305 *>          the estimate for RCOND, and is almost always a slight
00306 *>          overestimate of the true error.
00307 *> \endverbatim
00308 *>
00309 *> \param[out] BERR
00310 *> \verbatim
00311 *>          BERR is DOUBLE PRECISION array, dimension (NRHS)
00312 *>          The componentwise relative backward error of each solution
00313 *>          vector X(j) (i.e., the smallest relative change in
00314 *>          any element of A or B that makes X(j) an exact solution).
00315 *> \endverbatim
00316 *>
00317 *> \param[out] WORK
00318 *> \verbatim
00319 *>          WORK is DOUBLE PRECISION array, dimension (3*N)
00320 *>          On exit, WORK(1) contains the reciprocal pivot growth
00321 *>          factor norm(A)/norm(U). The "max absolute element" norm is
00322 *>          used. If WORK(1) is much less than 1, then the stability
00323 *>          of the LU factorization of the (equilibrated) matrix A
00324 *>          could be poor. This also means that the solution X, condition
00325 *>          estimator RCOND, and forward error bound FERR could be
00326 *>          unreliable. If factorization fails with 0<INFO<=N, then
00327 *>          WORK(1) contains the reciprocal pivot growth factor for the
00328 *>          leading INFO columns of A.
00329 *> \endverbatim
00330 *>
00331 *> \param[out] IWORK
00332 *> \verbatim
00333 *>          IWORK is INTEGER array, dimension (N)
00334 *> \endverbatim
00335 *>
00336 *> \param[out] INFO
00337 *> \verbatim
00338 *>          INFO is INTEGER
00339 *>          = 0:  successful exit
00340 *>          < 0:  if INFO = -i, the i-th argument had an illegal value
00341 *>          > 0:  if INFO = i, and i is
00342 *>                <= N:  U(i,i) is exactly zero.  The factorization
00343 *>                       has been completed, but the factor U is exactly
00344 *>                       singular, so the solution and error bounds
00345 *>                       could not be computed. RCOND = 0 is returned.
00346 *>                = N+1: U is nonsingular, but RCOND is less than machine
00347 *>                       precision, meaning that the matrix is singular
00348 *>                       to working precision.  Nevertheless, the
00349 *>                       solution and error bounds are computed because
00350 *>                       there are a number of situations where the
00351 *>                       computed solution can be more accurate than the
00352 *>                       value of RCOND would suggest.
00353 *> \endverbatim
00354 *
00355 *  Authors:
00356 *  ========
00357 *
00358 *> \author Univ. of Tennessee 
00359 *> \author Univ. of California Berkeley 
00360 *> \author Univ. of Colorado Denver 
00361 *> \author NAG Ltd. 
00362 *
00363 *> \date April 2012
00364 *
00365 *> \ingroup doubleGBsolve
00366 *
00367 *  =====================================================================
00368       SUBROUTINE DGBSVX( FACT, TRANS, N, KL, KU, NRHS, AB, LDAB, AFB,
00369      $                   LDAFB, IPIV, EQUED, R, C, B, LDB, X, LDX,
00370      $                   RCOND, FERR, BERR, WORK, IWORK, INFO )
00371 *
00372 *  -- LAPACK driver routine (version 3.4.1) --
00373 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00374 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00375 *     April 2012
00376 *
00377 *     .. Scalar Arguments ..
00378       CHARACTER          EQUED, FACT, TRANS
00379       INTEGER            INFO, KL, KU, LDAB, LDAFB, LDB, LDX, N, NRHS
00380       DOUBLE PRECISION   RCOND
00381 *     ..
00382 *     .. Array Arguments ..
00383       INTEGER            IPIV( * ), IWORK( * )
00384       DOUBLE PRECISION   AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ),
00385      $                   BERR( * ), C( * ), FERR( * ), R( * ),
00386      $                   WORK( * ), X( LDX, * )
00387 *     ..
00388 *
00389 *  =====================================================================
00390 *
00391 *     .. Parameters ..
00392       DOUBLE PRECISION   ZERO, ONE
00393       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00394 *     ..
00395 *     .. Local Scalars ..
00396       LOGICAL            COLEQU, EQUIL, NOFACT, NOTRAN, ROWEQU
00397       CHARACTER          NORM
00398       INTEGER            I, INFEQU, J, J1, J2
00399       DOUBLE PRECISION   AMAX, ANORM, BIGNUM, COLCND, RCMAX, RCMIN,
00400      $                   ROWCND, RPVGRW, SMLNUM
00401 *     ..
00402 *     .. External Functions ..
00403       LOGICAL            LSAME
00404       DOUBLE PRECISION   DLAMCH, DLANGB, DLANTB
00405       EXTERNAL           LSAME, DLAMCH, DLANGB, DLANTB
00406 *     ..
00407 *     .. External Subroutines ..
00408       EXTERNAL           DCOPY, DGBCON, DGBEQU, DGBRFS, DGBTRF, DGBTRS,
00409      $                   DLACPY, DLAQGB, XERBLA
00410 *     ..
00411 *     .. Intrinsic Functions ..
00412       INTRINSIC          ABS, MAX, MIN
00413 *     ..
00414 *     .. Executable Statements ..
00415 *
00416       INFO = 0
00417       NOFACT = LSAME( FACT, 'N' )
00418       EQUIL = LSAME( FACT, 'E' )
00419       NOTRAN = LSAME( TRANS, 'N' )
00420       IF( NOFACT .OR. EQUIL ) THEN
00421          EQUED = 'N'
00422          ROWEQU = .FALSE.
00423          COLEQU = .FALSE.
00424       ELSE
00425          ROWEQU = LSAME( EQUED, 'R' ) .OR. LSAME( EQUED, 'B' )
00426          COLEQU = LSAME( EQUED, 'C' ) .OR. LSAME( EQUED, 'B' )
00427          SMLNUM = DLAMCH( 'Safe minimum' )
00428          BIGNUM = ONE / SMLNUM
00429       END IF
00430 *
00431 *     Test the input parameters.
00432 *
00433       IF( .NOT.NOFACT .AND. .NOT.EQUIL .AND. .NOT.LSAME( FACT, 'F' ) )
00434      $     THEN
00435          INFO = -1
00436       ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) .AND. .NOT.
00437      $         LSAME( TRANS, 'C' ) ) THEN
00438          INFO = -2
00439       ELSE IF( N.LT.0 ) THEN
00440          INFO = -3
00441       ELSE IF( KL.LT.0 ) THEN
00442          INFO = -4
00443       ELSE IF( KU.LT.0 ) THEN
00444          INFO = -5
00445       ELSE IF( NRHS.LT.0 ) THEN
00446          INFO = -6
00447       ELSE IF( LDAB.LT.KL+KU+1 ) THEN
00448          INFO = -8
00449       ELSE IF( LDAFB.LT.2*KL+KU+1 ) THEN
00450          INFO = -10
00451       ELSE IF( LSAME( FACT, 'F' ) .AND. .NOT.
00452      $         ( ROWEQU .OR. COLEQU .OR. LSAME( EQUED, 'N' ) ) ) THEN
00453          INFO = -12
00454       ELSE
00455          IF( ROWEQU ) THEN
00456             RCMIN = BIGNUM
00457             RCMAX = ZERO
00458             DO 10 J = 1, N
00459                RCMIN = MIN( RCMIN, R( J ) )
00460                RCMAX = MAX( RCMAX, R( J ) )
00461    10       CONTINUE
00462             IF( RCMIN.LE.ZERO ) THEN
00463                INFO = -13
00464             ELSE IF( N.GT.0 ) THEN
00465                ROWCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )
00466             ELSE
00467                ROWCND = ONE
00468             END IF
00469          END IF
00470          IF( COLEQU .AND. INFO.EQ.0 ) THEN
00471             RCMIN = BIGNUM
00472             RCMAX = ZERO
00473             DO 20 J = 1, N
00474                RCMIN = MIN( RCMIN, C( J ) )
00475                RCMAX = MAX( RCMAX, C( J ) )
00476    20       CONTINUE
00477             IF( RCMIN.LE.ZERO ) THEN
00478                INFO = -14
00479             ELSE IF( N.GT.0 ) THEN
00480                COLCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )
00481             ELSE
00482                COLCND = ONE
00483             END IF
00484          END IF
00485          IF( INFO.EQ.0 ) THEN
00486             IF( LDB.LT.MAX( 1, N ) ) THEN
00487                INFO = -16
00488             ELSE IF( LDX.LT.MAX( 1, N ) ) THEN
00489                INFO = -18
00490             END IF
00491          END IF
00492       END IF
00493 *
00494       IF( INFO.NE.0 ) THEN
00495          CALL XERBLA( 'DGBSVX', -INFO )
00496          RETURN
00497       END IF
00498 *
00499       IF( EQUIL ) THEN
00500 *
00501 *        Compute row and column scalings to equilibrate the matrix A.
00502 *
00503          CALL DGBEQU( N, N, KL, KU, AB, LDAB, R, C, ROWCND, COLCND,
00504      $                AMAX, INFEQU )
00505          IF( INFEQU.EQ.0 ) THEN
00506 *
00507 *           Equilibrate the matrix.
00508 *
00509             CALL DLAQGB( N, N, KL, KU, AB, LDAB, R, C, ROWCND, COLCND,
00510      $                   AMAX, EQUED )
00511             ROWEQU = LSAME( EQUED, 'R' ) .OR. LSAME( EQUED, 'B' )
00512             COLEQU = LSAME( EQUED, 'C' ) .OR. LSAME( EQUED, 'B' )
00513          END IF
00514       END IF
00515 *
00516 *     Scale the right hand side.
00517 *
00518       IF( NOTRAN ) THEN
00519          IF( ROWEQU ) THEN
00520             DO 40 J = 1, NRHS
00521                DO 30 I = 1, N
00522                   B( I, J ) = R( I )*B( I, J )
00523    30          CONTINUE
00524    40       CONTINUE
00525          END IF
00526       ELSE IF( COLEQU ) THEN
00527          DO 60 J = 1, NRHS
00528             DO 50 I = 1, N
00529                B( I, J ) = C( I )*B( I, J )
00530    50       CONTINUE
00531    60    CONTINUE
00532       END IF
00533 *
00534       IF( NOFACT .OR. EQUIL ) THEN
00535 *
00536 *        Compute the LU factorization of the band matrix A.
00537 *
00538          DO 70 J = 1, N
00539             J1 = MAX( J-KU, 1 )
00540             J2 = MIN( J+KL, N )
00541             CALL DCOPY( J2-J1+1, AB( KU+1-J+J1, J ), 1,
00542      $                  AFB( KL+KU+1-J+J1, J ), 1 )
00543    70    CONTINUE
00544 *
00545          CALL DGBTRF( N, N, KL, KU, AFB, LDAFB, IPIV, INFO )
00546 *
00547 *        Return if INFO is non-zero.
00548 *
00549          IF( INFO.GT.0 ) THEN
00550 *
00551 *           Compute the reciprocal pivot growth factor of the
00552 *           leading rank-deficient INFO columns of A.
00553 *
00554             ANORM = ZERO
00555             DO 90 J = 1, INFO
00556                DO 80 I = MAX( KU+2-J, 1 ), MIN( N+KU+1-J, KL+KU+1 )
00557                   ANORM = MAX( ANORM, ABS( AB( I, J ) ) )
00558    80          CONTINUE
00559    90       CONTINUE
00560             RPVGRW = DLANTB( 'M', 'U', 'N', INFO, MIN( INFO-1, KL+KU ),
00561      $                       AFB( MAX( 1, KL+KU+2-INFO ), 1 ), LDAFB,
00562      $                       WORK )
00563             IF( RPVGRW.EQ.ZERO ) THEN
00564                RPVGRW = ONE
00565             ELSE
00566                RPVGRW = ANORM / RPVGRW
00567             END IF
00568             WORK( 1 ) = RPVGRW
00569             RCOND = ZERO
00570             RETURN
00571          END IF
00572       END IF
00573 *
00574 *     Compute the norm of the matrix A and the
00575 *     reciprocal pivot growth factor RPVGRW.
00576 *
00577       IF( NOTRAN ) THEN
00578          NORM = '1'
00579       ELSE
00580          NORM = 'I'
00581       END IF
00582       ANORM = DLANGB( NORM, N, KL, KU, AB, LDAB, WORK )
00583       RPVGRW = DLANTB( 'M', 'U', 'N', N, KL+KU, AFB, LDAFB, WORK )
00584       IF( RPVGRW.EQ.ZERO ) THEN
00585          RPVGRW = ONE
00586       ELSE
00587          RPVGRW = DLANGB( 'M', N, KL, KU, AB, LDAB, WORK ) / RPVGRW
00588       END IF
00589 *
00590 *     Compute the reciprocal of the condition number of A.
00591 *
00592       CALL DGBCON( NORM, N, KL, KU, AFB, LDAFB, IPIV, ANORM, RCOND,
00593      $             WORK, IWORK, INFO )
00594 *
00595 *     Compute the solution matrix X.
00596 *
00597       CALL DLACPY( 'Full', N, NRHS, B, LDB, X, LDX )
00598       CALL DGBTRS( TRANS, N, KL, KU, NRHS, AFB, LDAFB, IPIV, X, LDX,
00599      $             INFO )
00600 *
00601 *     Use iterative refinement to improve the computed solution and
00602 *     compute error bounds and backward error estimates for it.
00603 *
00604       CALL DGBRFS( TRANS, N, KL, KU, NRHS, AB, LDAB, AFB, LDAFB, IPIV,
00605      $             B, LDB, X, LDX, FERR, BERR, WORK, IWORK, INFO )
00606 *
00607 *     Transform the solution matrix X to a solution of the original
00608 *     system.
00609 *
00610       IF( NOTRAN ) THEN
00611          IF( COLEQU ) THEN
00612             DO 110 J = 1, NRHS
00613                DO 100 I = 1, N
00614                   X( I, J ) = C( I )*X( I, J )
00615   100          CONTINUE
00616   110       CONTINUE
00617             DO 120 J = 1, NRHS
00618                FERR( J ) = FERR( J ) / COLCND
00619   120       CONTINUE
00620          END IF
00621       ELSE IF( ROWEQU ) THEN
00622          DO 140 J = 1, NRHS
00623             DO 130 I = 1, N
00624                X( I, J ) = R( I )*X( I, J )
00625   130       CONTINUE
00626   140    CONTINUE
00627          DO 150 J = 1, NRHS
00628             FERR( J ) = FERR( J ) / ROWCND
00629   150    CONTINUE
00630       END IF
00631 *
00632 *     Set INFO = N+1 if the matrix is singular to working precision.
00633 *
00634       IF( RCOND.LT.DLAMCH( 'Epsilon' ) )
00635      $   INFO = N + 1
00636 *
00637       WORK( 1 ) = RPVGRW
00638       RETURN
00639 *
00640 *     End of DGBSVX
00641 *
00642       END
 All Files Functions