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