zgbsvxx.c
Go to the documentation of this file.
00001 /* zgbsvxx.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Subroutine */ int zgbsvxx_(char *fact, char *trans, integer *n, integer *
00017         kl, integer *ku, integer *nrhs, doublecomplex *ab, integer *ldab, 
00018         doublecomplex *afb, integer *ldafb, integer *ipiv, char *equed, 
00019         doublereal *r__, doublereal *c__, doublecomplex *b, integer *ldb, 
00020         doublecomplex *x, integer *ldx, doublereal *rcond, doublereal *rpvgrw, 
00021          doublereal *berr, integer *n_err_bnds__, doublereal *err_bnds_norm__, 
00022          doublereal *err_bnds_comp__, integer *nparams, doublereal *params, 
00023         doublecomplex *work, doublereal *rwork, integer *info)
00024 {
00025     /* System generated locals */
00026     integer ab_dim1, ab_offset, afb_dim1, afb_offset, b_dim1, b_offset, 
00027             x_dim1, x_offset, err_bnds_norm_dim1, err_bnds_norm_offset, 
00028             err_bnds_comp_dim1, err_bnds_comp_offset, i__1, i__2, i__3, i__4;
00029     doublereal d__1, d__2;
00030 
00031     /* Local variables */
00032     integer i__, j;
00033     doublereal amax;
00034     extern doublereal zla_gbrpvgrw__(integer *, integer *, integer *, integer 
00035             *, doublecomplex *, integer *, doublecomplex *, integer *);
00036     extern logical lsame_(char *, char *);
00037     doublereal rcmin, rcmax;
00038     logical equil;
00039     extern doublereal dlamch_(char *);
00040     doublereal colcnd;
00041     logical nofact;
00042     extern /* Subroutine */ int xerbla_(char *, integer *), zlaqgb_(
00043             integer *, integer *, integer *, integer *, doublecomplex *, 
00044             integer *, doublereal *, doublereal *, doublereal *, doublereal *, 
00045              doublereal *, char *);
00046     doublereal bignum;
00047     integer infequ;
00048     logical colequ;
00049     doublereal rowcnd;
00050     extern /* Subroutine */ int zgbtrf_(integer *, integer *, integer *, 
00051             integer *, doublecomplex *, integer *, integer *, integer *);
00052     logical notran;
00053     extern /* Subroutine */ int zlacpy_(char *, integer *, integer *, 
00054             doublecomplex *, integer *, doublecomplex *, integer *);
00055     doublereal smlnum;
00056     extern /* Subroutine */ int zgbtrs_(char *, integer *, integer *, integer 
00057             *, integer *, doublecomplex *, integer *, integer *, 
00058             doublecomplex *, integer *, integer *);
00059     logical rowequ;
00060     extern /* Subroutine */ int zlascl2_(integer *, integer *, doublereal *, 
00061             doublecomplex *, integer *), zgbequb_(integer *, integer *, 
00062             integer *, integer *, doublecomplex *, integer *, doublereal *, 
00063             doublereal *, doublereal *, doublereal *, doublereal *, integer *)
00064             , zgbrfsx_(char *, char *, integer *, integer *, integer *, 
00065             integer *, doublecomplex *, integer *, doublecomplex *, integer *, 
00066              integer *, doublereal *, doublereal *, doublecomplex *, integer *
00067 , doublecomplex *, integer *, doublereal *, doublereal *, integer 
00068             *, doublereal *, doublereal *, integer *, doublereal *, 
00069             doublecomplex *, doublereal *, integer *);
00070 
00071 
00072 /*     -- LAPACK driver routine (version 3.2)                          -- */
00073 /*     -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */
00074 /*     -- Jason Riedy of Univ. of California Berkeley.                 -- */
00075 /*     -- November 2008                                                -- */
00076 
00077 /*     -- LAPACK is a software package provided by Univ. of Tennessee, -- */
00078 /*     -- Univ. of California Berkeley and NAG Ltd.                    -- */
00079 
00080 /*     .. */
00081 /*     .. Scalar Arguments .. */
00082 /*     .. */
00083 /*     .. Array Arguments .. */
00084 /*     .. */
00085 
00086 /*     Purpose */
00087 /*     ======= */
00088 
00089 /*     ZGBSVXX uses the LU factorization to compute the solution to a */
00090 /*     complex*16 system of linear equations  A * X = B,  where A is an */
00091 /*     N-by-N matrix and X and B are N-by-NRHS matrices. */
00092 
00093 /*     If requested, both normwise and maximum componentwise error bounds */
00094 /*     are returned. ZGBSVXX will return a solution with a tiny */
00095 /*     guaranteed error (O(eps) where eps is the working machine */
00096 /*     precision) unless the matrix is very ill-conditioned, in which */
00097 /*     case a warning is returned. Relevant condition numbers also are */
00098 /*     calculated and returned. */
00099 
00100 /*     ZGBSVXX accepts user-provided factorizations and equilibration */
00101 /*     factors; see the definitions of the FACT and EQUED options. */
00102 /*     Solving with refinement and using a factorization from a previous */
00103 /*     ZGBSVXX call will also produce a solution with either O(eps) */
00104 /*     errors or warnings, but we cannot make that claim for general */
00105 /*     user-provided factorizations and equilibration factors if they */
00106 /*     differ from what ZGBSVXX would itself produce. */
00107 
00108 /*     Description */
00109 /*     =========== */
00110 
00111 /*     The following steps are performed: */
00112 
00113 /*     1. If FACT = 'E', double precision scaling factors are computed to equilibrate */
00114 /*     the system: */
00115 
00116 /*       TRANS = 'N':  diag(R)*A*diag(C)     *inv(diag(C))*X = diag(R)*B */
00117 /*       TRANS = 'T': (diag(R)*A*diag(C))**T *inv(diag(R))*X = diag(C)*B */
00118 /*       TRANS = 'C': (diag(R)*A*diag(C))**H *inv(diag(R))*X = diag(C)*B */
00119 
00120 /*     Whether or not the system will be equilibrated depends on the */
00121 /*     scaling of the matrix A, but if equilibration is used, A is */
00122 /*     overwritten by diag(R)*A*diag(C) and B by diag(R)*B (if TRANS='N') */
00123 /*     or diag(C)*B (if TRANS = 'T' or 'C'). */
00124 
00125 /*     2. If FACT = 'N' or 'E', the LU decomposition is used to factor */
00126 /*     the matrix A (after equilibration if FACT = 'E') as */
00127 
00128 /*       A = P * L * U, */
00129 
00130 /*     where P is a permutation matrix, L is a unit lower triangular */
00131 /*     matrix, and U is upper triangular. */
00132 
00133 /*     3. If some U(i,i)=0, so that U is exactly singular, then the */
00134 /*     routine returns with INFO = i. Otherwise, the factored form of A */
00135 /*     is used to estimate the condition number of the matrix A (see */
00136 /*     argument RCOND). If the reciprocal of the condition number is less */
00137 /*     than machine precision, the routine still goes on to solve for X */
00138 /*     and compute error bounds as described below. */
00139 
00140 /*     4. The system of equations is solved for X using the factored form */
00141 /*     of A. */
00142 
00143 /*     5. By default (unless PARAMS(LA_LINRX_ITREF_I) is set to zero), */
00144 /*     the routine will use iterative refinement to try to get a small */
00145 /*     error and error bounds.  Refinement calculates the residual to at */
00146 /*     least twice the working precision. */
00147 
00148 /*     6. If equilibration was used, the matrix X is premultiplied by */
00149 /*     diag(C) (if TRANS = 'N') or diag(R) (if TRANS = 'T' or 'C') so */
00150 /*     that it solves the original system before equilibration. */
00151 
00152 /*     Arguments */
00153 /*     ========= */
00154 
00155 /*     Some optional parameters are bundled in the PARAMS array.  These */
00156 /*     settings determine how refinement is performed, but often the */
00157 /*     defaults are acceptable.  If the defaults are acceptable, users */
00158 /*     can pass NPARAMS = 0 which prevents the source code from accessing */
00159 /*     the PARAMS argument. */
00160 
00161 /*     FACT    (input) CHARACTER*1 */
00162 /*     Specifies whether or not the factored form of the matrix A is */
00163 /*     supplied on entry, and if not, whether the matrix A should be */
00164 /*     equilibrated before it is factored. */
00165 /*       = 'F':  On entry, AF and IPIV contain the factored form of A. */
00166 /*               If EQUED is not 'N', the matrix A has been */
00167 /*               equilibrated with scaling factors given by R and C. */
00168 /*               A, AF, and IPIV are not modified. */
00169 /*       = 'N':  The matrix A will be copied to AF and factored. */
00170 /*       = 'E':  The matrix A will be equilibrated if necessary, then */
00171 /*               copied to AF and factored. */
00172 
00173 /*     TRANS   (input) CHARACTER*1 */
00174 /*     Specifies the form of the system of equations: */
00175 /*       = 'N':  A * X = B     (No transpose) */
00176 /*       = 'T':  A**T * X = B  (Transpose) */
00177 /*       = 'C':  A**H * X = B  (Conjugate Transpose = Transpose) */
00178 
00179 /*     N       (input) INTEGER */
00180 /*     The number of linear equations, i.e., the order of the */
00181 /*     matrix A.  N >= 0. */
00182 
00183 /*     KL      (input) INTEGER */
00184 /*     The number of subdiagonals within the band of A.  KL >= 0. */
00185 
00186 /*     KU      (input) INTEGER */
00187 /*     The number of superdiagonals within the band of A.  KU >= 0. */
00188 
00189 /*     NRHS    (input) INTEGER */
00190 /*     The number of right hand sides, i.e., the number of columns */
00191 /*     of the matrices B and X.  NRHS >= 0. */
00192 
00193 /*     AB      (input/output) DOUBLE PRECISION array, dimension (LDAB,N) */
00194 /*     On entry, the matrix A in band storage, in rows 1 to KL+KU+1. */
00195 /*     The j-th column of A is stored in the j-th column of the */
00196 /*     array AB as follows: */
00197 /*     AB(KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+kl) */
00198 
00199 /*     If FACT = 'F' and EQUED is not 'N', then AB must have been */
00200 /*     equilibrated by the scaling factors in R and/or C.  AB is not */
00201 /*     modified if FACT = 'F' or 'N', or if FACT = 'E' and */
00202 /*     EQUED = 'N' on exit. */
00203 
00204 /*     On exit, if EQUED .ne. 'N', A is scaled as follows: */
00205 /*     EQUED = 'R':  A := diag(R) * A */
00206 /*     EQUED = 'C':  A := A * diag(C) */
00207 /*     EQUED = 'B':  A := diag(R) * A * diag(C). */
00208 
00209 /*     LDAB    (input) INTEGER */
00210 /*     The leading dimension of the array AB.  LDAB >= KL+KU+1. */
00211 
00212 /*     AFB     (input or output) DOUBLE PRECISION array, dimension (LDAFB,N) */
00213 /*     If FACT = 'F', then AFB is an input argument and on entry */
00214 /*     contains details of the LU factorization of the band matrix */
00215 /*     A, as computed by ZGBTRF.  U is stored as an upper triangular */
00216 /*     band matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, */
00217 /*     and the multipliers used during the factorization are stored */
00218 /*     in rows KL+KU+2 to 2*KL+KU+1.  If EQUED .ne. 'N', then AFB is */
00219 /*     the factored form of the equilibrated matrix A. */
00220 
00221 /*     If FACT = 'N', then AF is an output argument and on exit */
00222 /*     returns the factors L and U from the factorization A = P*L*U */
00223 /*     of the original matrix A. */
00224 
00225 /*     If FACT = 'E', then AF is an output argument and on exit */
00226 /*     returns the factors L and U from the factorization A = P*L*U */
00227 /*     of the equilibrated matrix A (see the description of A for */
00228 /*     the form of the equilibrated matrix). */
00229 
00230 /*     LDAFB   (input) INTEGER */
00231 /*     The leading dimension of the array AFB.  LDAFB >= 2*KL+KU+1. */
00232 
00233 /*     IPIV    (input or output) INTEGER array, dimension (N) */
00234 /*     If FACT = 'F', then IPIV is an input argument and on entry */
00235 /*     contains the pivot indices from the factorization A = P*L*U */
00236 /*     as computed by DGETRF; row i of the matrix was interchanged */
00237 /*     with row IPIV(i). */
00238 
00239 /*     If FACT = 'N', then IPIV is an output argument and on exit */
00240 /*     contains the pivot indices from the factorization A = P*L*U */
00241 /*     of the original matrix A. */
00242 
00243 /*     If FACT = 'E', then IPIV is an output argument and on exit */
00244 /*     contains the pivot indices from the factorization A = P*L*U */
00245 /*     of the equilibrated matrix A. */
00246 
00247 /*     EQUED   (input or output) CHARACTER*1 */
00248 /*     Specifies the form of equilibration that was done. */
00249 /*       = 'N':  No equilibration (always true if FACT = 'N'). */
00250 /*       = 'R':  Row equilibration, i.e., A has been premultiplied by */
00251 /*               diag(R). */
00252 /*       = 'C':  Column equilibration, i.e., A has been postmultiplied */
00253 /*               by diag(C). */
00254 /*       = 'B':  Both row and column equilibration, i.e., A has been */
00255 /*               replaced by diag(R) * A * diag(C). */
00256 /*     EQUED is an input argument if FACT = 'F'; otherwise, it is an */
00257 /*     output argument. */
00258 
00259 /*     R       (input or output) DOUBLE PRECISION array, dimension (N) */
00260 /*     The row scale factors for A.  If EQUED = 'R' or 'B', A is */
00261 /*     multiplied on the left by diag(R); if EQUED = 'N' or 'C', R */
00262 /*     is not accessed.  R is an input argument if FACT = 'F'; */
00263 /*     otherwise, R is an output argument.  If FACT = 'F' and */
00264 /*     EQUED = 'R' or 'B', each element of R must be positive. */
00265 /*     If R is output, each element of R is a power of the radix. */
00266 /*     If R is input, each element of R should be a power of the radix */
00267 /*     to ensure a reliable solution and error estimates. Scaling by */
00268 /*     powers of the radix does not cause rounding errors unless the */
00269 /*     result underflows or overflows. Rounding errors during scaling */
00270 /*     lead to refining with a matrix that is not equivalent to the */
00271 /*     input matrix, producing error estimates that may not be */
00272 /*     reliable. */
00273 
00274 /*     C       (input or output) DOUBLE PRECISION array, dimension (N) */
00275 /*     The column scale factors for A.  If EQUED = 'C' or 'B', A is */
00276 /*     multiplied on the right by diag(C); if EQUED = 'N' or 'R', C */
00277 /*     is not accessed.  C is an input argument if FACT = 'F'; */
00278 /*     otherwise, C is an output argument.  If FACT = 'F' and */
00279 /*     EQUED = 'C' or 'B', each element of C must be positive. */
00280 /*     If C is output, each element of C is a power of the radix. */
00281 /*     If C is input, each element of C should be a power of the radix */
00282 /*     to ensure a reliable solution and error estimates. Scaling by */
00283 /*     powers of the radix does not cause rounding errors unless the */
00284 /*     result underflows or overflows. Rounding errors during scaling */
00285 /*     lead to refining with a matrix that is not equivalent to the */
00286 /*     input matrix, producing error estimates that may not be */
00287 /*     reliable. */
00288 
00289 /*     B       (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
00290 /*     On entry, the N-by-NRHS right hand side matrix B. */
00291 /*     On exit, */
00292 /*     if EQUED = 'N', B is not modified; */
00293 /*     if TRANS = 'N' and EQUED = 'R' or 'B', B is overwritten by */
00294 /*        diag(R)*B; */
00295 /*     if TRANS = 'T' or 'C' and EQUED = 'C' or 'B', B is */
00296 /*        overwritten by diag(C)*B. */
00297 
00298 /*     LDB     (input) INTEGER */
00299 /*     The leading dimension of the array B.  LDB >= max(1,N). */
00300 
00301 /*     X       (output) DOUBLE PRECISION array, dimension (LDX,NRHS) */
00302 /*     If INFO = 0, the N-by-NRHS solution matrix X to the original */
00303 /*     system of equations.  Note that A and B are modified on exit */
00304 /*     if EQUED .ne. 'N', and the solution to the equilibrated system is */
00305 /*     inv(diag(C))*X if TRANS = 'N' and EQUED = 'C' or 'B', or */
00306 /*     inv(diag(R))*X if TRANS = 'T' or 'C' and EQUED = 'R' or 'B'. */
00307 
00308 /*     LDX     (input) INTEGER */
00309 /*     The leading dimension of the array X.  LDX >= max(1,N). */
00310 
00311 /*     RCOND   (output) DOUBLE PRECISION */
00312 /*     Reciprocal scaled condition number.  This is an estimate of the */
00313 /*     reciprocal Skeel condition number of the matrix A after */
00314 /*     equilibration (if done).  If this is less than the machine */
00315 /*     precision (in particular, if it is zero), the matrix is singular */
00316 /*     to working precision.  Note that the error may still be small even */
00317 /*     if this number is very small and the matrix appears ill- */
00318 /*     conditioned. */
00319 
00320 /*     RPVGRW  (output) DOUBLE PRECISION */
00321 /*     Reciprocal pivot growth.  On exit, this contains the reciprocal */
00322 /*     pivot growth factor norm(A)/norm(U). The "max absolute element" */
00323 /*     norm is used.  If this is much less than 1, then the stability of */
00324 /*     the LU factorization of the (equilibrated) matrix A could be poor. */
00325 /*     This also means that the solution X, estimated condition numbers, */
00326 /*     and error bounds could be unreliable. If factorization fails with */
00327 /*     0<INFO<=N, then this contains the reciprocal pivot growth factor */
00328 /*     for the leading INFO columns of A.  In DGESVX, this quantity is */
00329 /*     returned in WORK(1). */
00330 
00331 /*     BERR    (output) DOUBLE PRECISION array, dimension (NRHS) */
00332 /*     Componentwise relative backward error.  This is the */
00333 /*     componentwise relative backward error of each solution vector X(j) */
00334 /*     (i.e., the smallest relative change in any element of A or B that */
00335 /*     makes X(j) an exact solution). */
00336 
00337 /*     N_ERR_BNDS (input) INTEGER */
00338 /*     Number of error bounds to return for each right hand side */
00339 /*     and each type (normwise or componentwise).  See ERR_BNDS_NORM and */
00340 /*     ERR_BNDS_COMP below. */
00341 
00342 /*     ERR_BNDS_NORM  (output) DOUBLE PRECISION array, dimension (NRHS, N_ERR_BNDS) */
00343 /*     For each right-hand side, this array contains information about */
00344 /*     various error bounds and condition numbers corresponding to the */
00345 /*     normwise relative error, which is defined as follows: */
00346 
00347 /*     Normwise relative error in the ith solution vector: */
00348 /*             max_j (abs(XTRUE(j,i) - X(j,i))) */
00349 /*            ------------------------------ */
00350 /*                  max_j abs(X(j,i)) */
00351 
00352 /*     The array is indexed by the type of error information as described */
00353 /*     below. There currently are up to three pieces of information */
00354 /*     returned. */
00355 
00356 /*     The first index in ERR_BNDS_NORM(i,:) corresponds to the ith */
00357 /*     right-hand side. */
00358 
00359 /*     The second index in ERR_BNDS_NORM(:,err) contains the following */
00360 /*     three fields: */
00361 /*     err = 1 "Trust/don't trust" boolean. Trust the answer if the */
00362 /*              reciprocal condition number is less than the threshold */
00363 /*              sqrt(n) * dlamch('Epsilon'). */
00364 
00365 /*     err = 2 "Guaranteed" error bound: The estimated forward error, */
00366 /*              almost certainly within a factor of 10 of the true error */
00367 /*              so long as the next entry is greater than the threshold */
00368 /*              sqrt(n) * dlamch('Epsilon'). This error bound should only */
00369 /*              be trusted if the previous boolean is true. */
00370 
00371 /*     err = 3  Reciprocal condition number: Estimated normwise */
00372 /*              reciprocal condition number.  Compared with the threshold */
00373 /*              sqrt(n) * dlamch('Epsilon') to determine if the error */
00374 /*              estimate is "guaranteed". These reciprocal condition */
00375 /*              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
00376 /*              appropriately scaled matrix Z. */
00377 /*              Let Z = S*A, where S scales each row by a power of the */
00378 /*              radix so all absolute row sums of Z are approximately 1. */
00379 
00380 /*     See Lapack Working Note 165 for further details and extra */
00381 /*     cautions. */
00382 
00383 /*     ERR_BNDS_COMP  (output) DOUBLE PRECISION array, dimension (NRHS, N_ERR_BNDS) */
00384 /*     For each right-hand side, this array contains information about */
00385 /*     various error bounds and condition numbers corresponding to the */
00386 /*     componentwise relative error, which is defined as follows: */
00387 
00388 /*     Componentwise relative error in the ith solution vector: */
00389 /*                    abs(XTRUE(j,i) - X(j,i)) */
00390 /*             max_j ---------------------- */
00391 /*                         abs(X(j,i)) */
00392 
00393 /*     The array is indexed by the right-hand side i (on which the */
00394 /*     componentwise relative error depends), and the type of error */
00395 /*     information as described below. There currently are up to three */
00396 /*     pieces of information returned for each right-hand side. If */
00397 /*     componentwise accuracy is not requested (PARAMS(3) = 0.0), then */
00398 /*     ERR_BNDS_COMP is not accessed.  If N_ERR_BNDS .LT. 3, then at most */
00399 /*     the first (:,N_ERR_BNDS) entries are returned. */
00400 
00401 /*     The first index in ERR_BNDS_COMP(i,:) corresponds to the ith */
00402 /*     right-hand side. */
00403 
00404 /*     The second index in ERR_BNDS_COMP(:,err) contains the following */
00405 /*     three fields: */
00406 /*     err = 1 "Trust/don't trust" boolean. Trust the answer if the */
00407 /*              reciprocal condition number is less than the threshold */
00408 /*              sqrt(n) * dlamch('Epsilon'). */
00409 
00410 /*     err = 2 "Guaranteed" error bound: The estimated forward error, */
00411 /*              almost certainly within a factor of 10 of the true error */
00412 /*              so long as the next entry is greater than the threshold */
00413 /*              sqrt(n) * dlamch('Epsilon'). This error bound should only */
00414 /*              be trusted if the previous boolean is true. */
00415 
00416 /*     err = 3  Reciprocal condition number: Estimated componentwise */
00417 /*              reciprocal condition number.  Compared with the threshold */
00418 /*              sqrt(n) * dlamch('Epsilon') to determine if the error */
00419 /*              estimate is "guaranteed". These reciprocal condition */
00420 /*              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
00421 /*              appropriately scaled matrix Z. */
00422 /*              Let Z = S*(A*diag(x)), where x is the solution for the */
00423 /*              current right-hand side and S scales each row of */
00424 /*              A*diag(x) by a power of the radix so all absolute row */
00425 /*              sums of Z are approximately 1. */
00426 
00427 /*     See Lapack Working Note 165 for further details and extra */
00428 /*     cautions. */
00429 
00430 /*     NPARAMS (input) INTEGER */
00431 /*     Specifies the number of parameters set in PARAMS.  If .LE. 0, the */
00432 /*     PARAMS array is never referenced and default values are used. */
00433 
00434 /*     PARAMS  (input / output) DOUBLE PRECISION array, dimension NPARAMS */
00435 /*     Specifies algorithm parameters.  If an entry is .LT. 0.0, then */
00436 /*     that entry will be filled with default value used for that */
00437 /*     parameter.  Only positions up to NPARAMS are accessed; defaults */
00438 /*     are used for higher-numbered parameters. */
00439 
00440 /*       PARAMS(LA_LINRX_ITREF_I = 1) : Whether to perform iterative */
00441 /*            refinement or not. */
00442 /*         Default: 1.0D+0 */
00443 /*            = 0.0 : No refinement is performed, and no error bounds are */
00444 /*                    computed. */
00445 /*            = 1.0 : Use the extra-precise refinement algorithm. */
00446 /*              (other values are reserved for future use) */
00447 
00448 /*       PARAMS(LA_LINRX_ITHRESH_I = 2) : Maximum number of residual */
00449 /*            computations allowed for refinement. */
00450 /*         Default: 10 */
00451 /*         Aggressive: Set to 100 to permit convergence using approximate */
00452 /*                     factorizations or factorizations other than LU. If */
00453 /*                     the factorization uses a technique other than */
00454 /*                     Gaussian elimination, the guarantees in */
00455 /*                     err_bnds_norm and err_bnds_comp may no longer be */
00456 /*                     trustworthy. */
00457 
00458 /*       PARAMS(LA_LINRX_CWISE_I = 3) : Flag determining if the code */
00459 /*            will attempt to find a solution with small componentwise */
00460 /*            relative error in the double-precision algorithm.  Positive */
00461 /*            is true, 0.0 is false. */
00462 /*         Default: 1.0 (attempt componentwise convergence) */
00463 
00464 /*     WORK    (workspace) DOUBLE PRECISION array, dimension (4*N) */
00465 
00466 /*     IWORK   (workspace) INTEGER array, dimension (N) */
00467 
00468 /*     INFO    (output) INTEGER */
00469 /*       = 0:  Successful exit. The solution to every right-hand side is */
00470 /*         guaranteed. */
00471 /*       < 0:  If INFO = -i, the i-th argument had an illegal value */
00472 /*       > 0 and <= N:  U(INFO,INFO) is exactly zero.  The factorization */
00473 /*         has been completed, but the factor U is exactly singular, so */
00474 /*         the solution and error bounds could not be computed. RCOND = 0 */
00475 /*         is returned. */
00476 /*       = N+J: The solution corresponding to the Jth right-hand side is */
00477 /*         not guaranteed. The solutions corresponding to other right- */
00478 /*         hand sides K with K > J may not be guaranteed as well, but */
00479 /*         only the first such right-hand side is reported. If a small */
00480 /*         componentwise error is not requested (PARAMS(3) = 0.0) then */
00481 /*         the Jth right-hand side is the first with a normwise error */
00482 /*         bound that is not guaranteed (the smallest J such */
00483 /*         that ERR_BNDS_NORM(J,1) = 0.0). By default (PARAMS(3) = 1.0) */
00484 /*         the Jth right-hand side is the first with either a normwise or */
00485 /*         componentwise error bound that is not guaranteed (the smallest */
00486 /*         J such that either ERR_BNDS_NORM(J,1) = 0.0 or */
00487 /*         ERR_BNDS_COMP(J,1) = 0.0). See the definition of */
00488 /*         ERR_BNDS_NORM(:,1) and ERR_BNDS_COMP(:,1). To get information */
00489 /*         about all of the right-hand sides check ERR_BNDS_NORM or */
00490 /*         ERR_BNDS_COMP. */
00491 
00492 /*     ================================================================== */
00493 
00494 /*     .. Parameters .. */
00495 /*     .. */
00496 /*     .. Local Scalars .. */
00497 /*     .. */
00498 /*     .. External Functions .. */
00499 /*     .. */
00500 /*     .. External Subroutines .. */
00501 /*     .. */
00502 /*     .. Intrinsic Functions .. */
00503 /*     .. */
00504 /*     .. Executable Statements .. */
00505 
00506     /* Parameter adjustments */
00507     err_bnds_comp_dim1 = *nrhs;
00508     err_bnds_comp_offset = 1 + err_bnds_comp_dim1;
00509     err_bnds_comp__ -= err_bnds_comp_offset;
00510     err_bnds_norm_dim1 = *nrhs;
00511     err_bnds_norm_offset = 1 + err_bnds_norm_dim1;
00512     err_bnds_norm__ -= err_bnds_norm_offset;
00513     ab_dim1 = *ldab;
00514     ab_offset = 1 + ab_dim1;
00515     ab -= ab_offset;
00516     afb_dim1 = *ldafb;
00517     afb_offset = 1 + afb_dim1;
00518     afb -= afb_offset;
00519     --ipiv;
00520     --r__;
00521     --c__;
00522     b_dim1 = *ldb;
00523     b_offset = 1 + b_dim1;
00524     b -= b_offset;
00525     x_dim1 = *ldx;
00526     x_offset = 1 + x_dim1;
00527     x -= x_offset;
00528     --berr;
00529     --params;
00530     --work;
00531     --rwork;
00532 
00533     /* Function Body */
00534     *info = 0;
00535     nofact = lsame_(fact, "N");
00536     equil = lsame_(fact, "E");
00537     notran = lsame_(trans, "N");
00538     smlnum = dlamch_("Safe minimum");
00539     bignum = 1. / smlnum;
00540     if (nofact || equil) {
00541         *(unsigned char *)equed = 'N';
00542         rowequ = FALSE_;
00543         colequ = FALSE_;
00544     } else {
00545         rowequ = lsame_(equed, "R") || lsame_(equed, 
00546                 "B");
00547         colequ = lsame_(equed, "C") || lsame_(equed, 
00548                 "B");
00549     }
00550 
00551 /*     Default is failure.  If an input parameter is wrong or */
00552 /*     factorization fails, make everything look horrible.  Only the */
00553 /*     pivot growth is set here, the rest is initialized in ZGBRFSX. */
00554 
00555     *rpvgrw = 0.;
00556 
00557 /*     Test the input parameters.  PARAMS is not tested until DGERFSX. */
00558 
00559     if (! nofact && ! equil && ! lsame_(fact, "F")) {
00560         *info = -1;
00561     } else if (! notran && ! lsame_(trans, "T") && ! 
00562             lsame_(trans, "C")) {
00563         *info = -2;
00564     } else if (*n < 0) {
00565         *info = -3;
00566     } else if (*kl < 0) {
00567         *info = -4;
00568     } else if (*ku < 0) {
00569         *info = -5;
00570     } else if (*nrhs < 0) {
00571         *info = -6;
00572     } else if (*ldab < *kl + *ku + 1) {
00573         *info = -8;
00574     } else if (*ldafb < (*kl << 1) + *ku + 1) {
00575         *info = -10;
00576     } else if (lsame_(fact, "F") && ! (rowequ || colequ 
00577             || lsame_(equed, "N"))) {
00578         *info = -12;
00579     } else {
00580         if (rowequ) {
00581             rcmin = bignum;
00582             rcmax = 0.;
00583             i__1 = *n;
00584             for (j = 1; j <= i__1; ++j) {
00585 /* Computing MIN */
00586                 d__1 = rcmin, d__2 = r__[j];
00587                 rcmin = min(d__1,d__2);
00588 /* Computing MAX */
00589                 d__1 = rcmax, d__2 = r__[j];
00590                 rcmax = max(d__1,d__2);
00591 /* L10: */
00592             }
00593             if (rcmin <= 0.) {
00594                 *info = -13;
00595             } else if (*n > 0) {
00596                 rowcnd = max(rcmin,smlnum) / min(rcmax,bignum);
00597             } else {
00598                 rowcnd = 1.;
00599             }
00600         }
00601         if (colequ && *info == 0) {
00602             rcmin = bignum;
00603             rcmax = 0.;
00604             i__1 = *n;
00605             for (j = 1; j <= i__1; ++j) {
00606 /* Computing MIN */
00607                 d__1 = rcmin, d__2 = c__[j];
00608                 rcmin = min(d__1,d__2);
00609 /* Computing MAX */
00610                 d__1 = rcmax, d__2 = c__[j];
00611                 rcmax = max(d__1,d__2);
00612 /* L20: */
00613             }
00614             if (rcmin <= 0.) {
00615                 *info = -14;
00616             } else if (*n > 0) {
00617                 colcnd = max(rcmin,smlnum) / min(rcmax,bignum);
00618             } else {
00619                 colcnd = 1.;
00620             }
00621         }
00622         if (*info == 0) {
00623             if (*ldb < max(1,*n)) {
00624                 *info = -15;
00625             } else if (*ldx < max(1,*n)) {
00626                 *info = -16;
00627             }
00628         }
00629     }
00630 
00631     if (*info != 0) {
00632         i__1 = -(*info);
00633         xerbla_("ZGBSVXX", &i__1);
00634         return 0;
00635     }
00636 
00637     if (equil) {
00638 
00639 /*     Compute row and column scalings to equilibrate the matrix A. */
00640 
00641         zgbequb_(n, n, kl, ku, &ab[ab_offset], ldab, &r__[1], &c__[1], &
00642                 rowcnd, &colcnd, &amax, &infequ);
00643         if (infequ == 0) {
00644 
00645 /*     Equilibrate the matrix. */
00646 
00647             zlaqgb_(n, n, kl, ku, &ab[ab_offset], ldab, &r__[1], &c__[1], &
00648                     rowcnd, &colcnd, &amax, equed);
00649             rowequ = lsame_(equed, "R") || lsame_(equed, 
00650                      "B");
00651             colequ = lsame_(equed, "C") || lsame_(equed, 
00652                      "B");
00653         }
00654 
00655 /*     If the scaling factors are not applied, set them to 1.0. */
00656 
00657         if (! rowequ) {
00658             i__1 = *n;
00659             for (j = 1; j <= i__1; ++j) {
00660                 r__[j] = 1.;
00661             }
00662         }
00663         if (! colequ) {
00664             i__1 = *n;
00665             for (j = 1; j <= i__1; ++j) {
00666                 c__[j] = 1.;
00667             }
00668         }
00669     }
00670 
00671 /*     Scale the right-hand side. */
00672 
00673     if (notran) {
00674         if (rowequ) {
00675             zlascl2_(n, nrhs, &r__[1], &b[b_offset], ldb);
00676         }
00677     } else {
00678         if (colequ) {
00679             zlascl2_(n, nrhs, &c__[1], &b[b_offset], ldb);
00680         }
00681     }
00682 
00683     if (nofact || equil) {
00684 
00685 /*        Compute the LU factorization of A. */
00686 
00687         i__1 = *n;
00688         for (j = 1; j <= i__1; ++j) {
00689             i__2 = (*kl << 1) + *ku + 1;
00690             for (i__ = *kl + 1; i__ <= i__2; ++i__) {
00691                 i__3 = i__ + j * afb_dim1;
00692                 i__4 = i__ - *kl + j * ab_dim1;
00693                 afb[i__3].r = ab[i__4].r, afb[i__3].i = ab[i__4].i;
00694 /* L30: */
00695             }
00696 /* L40: */
00697         }
00698         zgbtrf_(n, n, kl, ku, &afb[afb_offset], ldafb, &ipiv[1], info);
00699 
00700 /*        Return if INFO is non-zero. */
00701 
00702         if (*info > 0) {
00703 
00704 /*           Pivot in column INFO is exactly 0 */
00705 /*           Compute the reciprocal pivot growth factor of the */
00706 /*           leading rank-deficient INFO columns of A. */
00707 
00708             *rpvgrw = zla_gbrpvgrw__(n, kl, ku, info, &ab[ab_offset], ldab, &
00709                     afb[afb_offset], ldafb);
00710             return 0;
00711         }
00712     }
00713 
00714 /*     Compute the reciprocal pivot growth factor RPVGRW. */
00715 
00716     *rpvgrw = zla_gbrpvgrw__(n, kl, ku, n, &ab[ab_offset], ldab, &afb[
00717             afb_offset], ldafb);
00718 
00719 /*     Compute the solution matrix X. */
00720 
00721     zlacpy_("Full", n, nrhs, &b[b_offset], ldb, &x[x_offset], ldx);
00722     zgbtrs_(trans, n, kl, ku, nrhs, &afb[afb_offset], ldafb, &ipiv[1], &x[
00723             x_offset], ldx, info);
00724 
00725 /*     Use iterative refinement to improve the computed solution and */
00726 /*     compute error bounds and backward error estimates for it. */
00727 
00728     zgbrfsx_(trans, equed, n, kl, ku, nrhs, &ab[ab_offset], ldab, &afb[
00729             afb_offset], ldafb, &ipiv[1], &r__[1], &c__[1], &b[b_offset], ldb, 
00730              &x[x_offset], ldx, rcond, &berr[1], n_err_bnds__, &
00731             err_bnds_norm__[err_bnds_norm_offset], &err_bnds_comp__[
00732             err_bnds_comp_offset], nparams, &params[1], &work[1], &rwork[1], 
00733             info);
00734 
00735 /*     Scale solutions. */
00736 
00737     if (colequ && notran) {
00738         zlascl2_(n, nrhs, &c__[1], &x[x_offset], ldx);
00739     } else if (rowequ && ! notran) {
00740         zlascl2_(n, nrhs, &r__[1], &x[x_offset], ldx);
00741     }
00742 
00743     return 0;
00744 
00745 /*     End of ZGBSVXX */
00746 
00747 } /* zgbsvxx_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:30