cgbsvxx.c
Go to the documentation of this file.
00001 /* cgbsvxx.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 cgbsvxx_(char *fact, char *trans, integer *n, integer *
00017         kl, integer *ku, integer *nrhs, complex *ab, integer *ldab, complex *
00018         afb, integer *ldafb, integer *ipiv, char *equed, real *r__, real *c__, 
00019          complex *b, integer *ldb, complex *x, integer *ldx, real *rcond, 
00020         real *rpvgrw, real *berr, integer *n_err_bnds__, real *
00021         err_bnds_norm__, real *err_bnds_comp__, integer *nparams, real *
00022         params, complex *work, real *rwork, integer *info)
00023 {
00024     /* System generated locals */
00025     integer ab_dim1, ab_offset, afb_dim1, afb_offset, b_dim1, b_offset, 
00026             x_dim1, x_offset, err_bnds_norm_dim1, err_bnds_norm_offset, 
00027             err_bnds_comp_dim1, err_bnds_comp_offset, i__1, i__2, i__3, i__4;
00028     real r__1, r__2;
00029 
00030     /* Local variables */
00031     integer i__, j;
00032     real amax;
00033     extern doublereal cla_gbrpvgrw__(integer *, integer *, integer *, integer 
00034             *, complex *, integer *, complex *, integer *);
00035     extern logical lsame_(char *, char *);
00036     real rcmin, rcmax;
00037     logical equil;
00038     extern /* Subroutine */ int claqgb_(integer *, integer *, integer *, 
00039             integer *, complex *, integer *, real *, real *, real *, real *, 
00040             real *, char *);
00041     real colcnd;
00042     extern doublereal slamch_(char *);
00043     extern /* Subroutine */ int cgbtrf_(integer *, integer *, integer *, 
00044             integer *, complex *, integer *, integer *, integer *);
00045     logical nofact;
00046     extern /* Subroutine */ int clacpy_(char *, integer *, integer *, complex 
00047             *, integer *, complex *, integer *), xerbla_(char *, 
00048             integer *);
00049     real bignum;
00050     extern /* Subroutine */ int cgbtrs_(char *, integer *, integer *, integer 
00051             *, integer *, complex *, integer *, integer *, complex *, integer 
00052             *, integer *);
00053     integer infequ;
00054     logical colequ;
00055     real rowcnd;
00056     logical notran;
00057     real smlnum;
00058     logical rowequ;
00059     extern /* Subroutine */ int clascl2_(integer *, integer *, real *, 
00060             complex *, integer *), cgbequb_(integer *, integer *, integer *, 
00061             integer *, complex *, integer *, real *, real *, real *, real *, 
00062             real *, integer *), cgbrfsx_(char *, char *, integer *, integer *, 
00063              integer *, integer *, complex *, integer *, complex *, integer *, 
00064              integer *, real *, real *, complex *, integer *, complex *, 
00065             integer *, real *, real *, integer *, real *, real *, integer *, 
00066             real *, complex *, real *, integer *);
00067 
00068 
00069 /*     -- LAPACK driver routine (version 3.2)                          -- */
00070 /*     -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */
00071 /*     -- Jason Riedy of Univ. of California Berkeley.                 -- */
00072 /*     -- November 2008                                                -- */
00073 
00074 /*     -- LAPACK is a software package provided by Univ. of Tennessee, -- */
00075 /*     -- Univ. of California Berkeley and NAG Ltd.                    -- */
00076 
00077 /*     .. */
00078 /*     .. Scalar Arguments .. */
00079 /*     .. */
00080 /*     .. Array Arguments .. */
00081 /*     .. */
00082 
00083 /*     Purpose */
00084 /*     ======= */
00085 
00086 /*     CGBSVXX uses the LU factorization to compute the solution to a */
00087 /*     complex system of linear equations  A * X = B,  where A is an */
00088 /*     N-by-N matrix and X and B are N-by-NRHS matrices. */
00089 
00090 /*     If requested, both normwise and maximum componentwise error bounds */
00091 /*     are returned. CGBSVXX will return a solution with a tiny */
00092 /*     guaranteed error (O(eps) where eps is the working machine */
00093 /*     precision) unless the matrix is very ill-conditioned, in which */
00094 /*     case a warning is returned. Relevant condition numbers also are */
00095 /*     calculated and returned. */
00096 
00097 /*     CGBSVXX accepts user-provided factorizations and equilibration */
00098 /*     factors; see the definitions of the FACT and EQUED options. */
00099 /*     Solving with refinement and using a factorization from a previous */
00100 /*     CGBSVXX call will also produce a solution with either O(eps) */
00101 /*     errors or warnings, but we cannot make that claim for general */
00102 /*     user-provided factorizations and equilibration factors if they */
00103 /*     differ from what CGBSVXX would itself produce. */
00104 
00105 /*     Description */
00106 /*     =========== */
00107 
00108 /*     The following steps are performed: */
00109 
00110 /*     1. If FACT = 'E', real scaling factors are computed to equilibrate */
00111 /*     the system: */
00112 
00113 /*       TRANS = 'N':  diag(R)*A*diag(C)     *inv(diag(C))*X = diag(R)*B */
00114 /*       TRANS = 'T': (diag(R)*A*diag(C))**T *inv(diag(R))*X = diag(C)*B */
00115 /*       TRANS = 'C': (diag(R)*A*diag(C))**H *inv(diag(R))*X = diag(C)*B */
00116 
00117 /*     Whether or not the system will be equilibrated depends on the */
00118 /*     scaling of the matrix A, but if equilibration is used, A is */
00119 /*     overwritten by diag(R)*A*diag(C) and B by diag(R)*B (if TRANS='N') */
00120 /*     or diag(C)*B (if TRANS = 'T' or 'C'). */
00121 
00122 /*     2. If FACT = 'N' or 'E', the LU decomposition is used to factor */
00123 /*     the matrix A (after equilibration if FACT = 'E') as */
00124 
00125 /*       A = P * L * U, */
00126 
00127 /*     where P is a permutation matrix, L is a unit lower triangular */
00128 /*     matrix, and U is upper triangular. */
00129 
00130 /*     3. If some U(i,i)=0, so that U is exactly singular, then the */
00131 /*     routine returns with INFO = i. Otherwise, the factored form of A */
00132 /*     is used to estimate the condition number of the matrix A (see */
00133 /*     argument RCOND). If the reciprocal of the condition number is less */
00134 /*     than machine precision, the routine still goes on to solve for X */
00135 /*     and compute error bounds as described below. */
00136 
00137 /*     4. The system of equations is solved for X using the factored form */
00138 /*     of A. */
00139 
00140 /*     5. By default (unless PARAMS(LA_LINRX_ITREF_I) is set to zero), */
00141 /*     the routine will use iterative refinement to try to get a small */
00142 /*     error and error bounds.  Refinement calculates the residual to at */
00143 /*     least twice the working precision. */
00144 
00145 /*     6. If equilibration was used, the matrix X is premultiplied by */
00146 /*     diag(C) (if TRANS = 'N') or diag(R) (if TRANS = 'T' or 'C') so */
00147 /*     that it solves the original system before equilibration. */
00148 
00149 /*     Arguments */
00150 /*     ========= */
00151 
00152 /*     Some optional parameters are bundled in the PARAMS array.  These */
00153 /*     settings determine how refinement is performed, but often the */
00154 /*     defaults are acceptable.  If the defaults are acceptable, users */
00155 /*     can pass NPARAMS = 0 which prevents the source code from accessing */
00156 /*     the PARAMS argument. */
00157 
00158 /*     FACT    (input) CHARACTER*1 */
00159 /*     Specifies whether or not the factored form of the matrix A is */
00160 /*     supplied on entry, and if not, whether the matrix A should be */
00161 /*     equilibrated before it is factored. */
00162 /*       = 'F':  On entry, AF and IPIV contain the factored form of A. */
00163 /*               If EQUED is not 'N', the matrix A has been */
00164 /*               equilibrated with scaling factors given by R and C. */
00165 /*               A, AF, and IPIV are not modified. */
00166 /*       = 'N':  The matrix A will be copied to AF and factored. */
00167 /*       = 'E':  The matrix A will be equilibrated if necessary, then */
00168 /*               copied to AF and factored. */
00169 
00170 /*     TRANS   (input) CHARACTER*1 */
00171 /*     Specifies the form of the system of equations: */
00172 /*       = 'N':  A * X = B     (No transpose) */
00173 /*       = 'T':  A**T * X = B  (Transpose) */
00174 /*       = 'C':  A**H * X = B  (Conjugate Transpose = Transpose) */
00175 
00176 /*     N       (input) INTEGER */
00177 /*     The number of linear equations, i.e., the order of the */
00178 /*     matrix A.  N >= 0. */
00179 
00180 /*     KL      (input) INTEGER */
00181 /*     The number of subdiagonals within the band of A.  KL >= 0. */
00182 
00183 /*     KU      (input) INTEGER */
00184 /*     The number of superdiagonals within the band of A.  KU >= 0. */
00185 
00186 /*     NRHS    (input) INTEGER */
00187 /*     The number of right hand sides, i.e., the number of columns */
00188 /*     of the matrices B and X.  NRHS >= 0. */
00189 
00190 /*     AB      (input/output) REAL array, dimension (LDAB,N) */
00191 /*     On entry, the matrix A in band storage, in rows 1 to KL+KU+1. */
00192 /*     The j-th column of A is stored in the j-th column of the */
00193 /*     array AB as follows: */
00194 /*     AB(KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+kl) */
00195 
00196 /*     If FACT = 'F' and EQUED is not 'N', then AB must have been */
00197 /*     equilibrated by the scaling factors in R and/or C.  AB is not */
00198 /*     modified if FACT = 'F' or 'N', or if FACT = 'E' and */
00199 /*     EQUED = 'N' on exit. */
00200 
00201 /*     On exit, if EQUED .ne. 'N', A is scaled as follows: */
00202 /*     EQUED = 'R':  A := diag(R) * A */
00203 /*     EQUED = 'C':  A := A * diag(C) */
00204 /*     EQUED = 'B':  A := diag(R) * A * diag(C). */
00205 
00206 /*     LDAB    (input) INTEGER */
00207 /*     The leading dimension of the array AB.  LDAB >= KL+KU+1. */
00208 
00209 /*     AFB     (input or output) REAL array, dimension (LDAFB,N) */
00210 /*     If FACT = 'F', then AFB is an input argument and on entry */
00211 /*     contains details of the LU factorization of the band matrix */
00212 /*     A, as computed by CGBTRF.  U is stored as an upper triangular */
00213 /*     band matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, */
00214 /*     and the multipliers used during the factorization are stored */
00215 /*     in rows KL+KU+2 to 2*KL+KU+1.  If EQUED .ne. 'N', then AFB is */
00216 /*     the factored form of the equilibrated matrix A. */
00217 
00218 /*     If FACT = 'N', then AF is an output argument and on exit */
00219 /*     returns the factors L and U from the factorization A = P*L*U */
00220 /*     of the original matrix A. */
00221 
00222 /*     If FACT = 'E', then AF is an output argument and on exit */
00223 /*     returns the factors L and U from the factorization A = P*L*U */
00224 /*     of the equilibrated matrix A (see the description of A for */
00225 /*     the form of the equilibrated matrix). */
00226 
00227 /*     LDAFB   (input) INTEGER */
00228 /*     The leading dimension of the array AFB.  LDAFB >= 2*KL+KU+1. */
00229 
00230 /*     IPIV    (input or output) INTEGER array, dimension (N) */
00231 /*     If FACT = 'F', then IPIV is an input argument and on entry */
00232 /*     contains the pivot indices from the factorization A = P*L*U */
00233 /*     as computed by SGETRF; row i of the matrix was interchanged */
00234 /*     with row IPIV(i). */
00235 
00236 /*     If FACT = 'N', then IPIV is an output argument and on exit */
00237 /*     contains the pivot indices from the factorization A = P*L*U */
00238 /*     of the original matrix A. */
00239 
00240 /*     If FACT = 'E', then IPIV is an output argument and on exit */
00241 /*     contains the pivot indices from the factorization A = P*L*U */
00242 /*     of the equilibrated matrix A. */
00243 
00244 /*     EQUED   (input or output) CHARACTER*1 */
00245 /*     Specifies the form of equilibration that was done. */
00246 /*       = 'N':  No equilibration (always true if FACT = 'N'). */
00247 /*       = 'R':  Row equilibration, i.e., A has been premultiplied by */
00248 /*               diag(R). */
00249 /*       = 'C':  Column equilibration, i.e., A has been postmultiplied */
00250 /*               by diag(C). */
00251 /*       = 'B':  Both row and column equilibration, i.e., A has been */
00252 /*               replaced by diag(R) * A * diag(C). */
00253 /*     EQUED is an input argument if FACT = 'F'; otherwise, it is an */
00254 /*     output argument. */
00255 
00256 /*     R       (input or output) REAL array, dimension (N) */
00257 /*     The row scale factors for A.  If EQUED = 'R' or 'B', A is */
00258 /*     multiplied on the left by diag(R); if EQUED = 'N' or 'C', R */
00259 /*     is not accessed.  R is an input argument if FACT = 'F'; */
00260 /*     otherwise, R is an output argument.  If FACT = 'F' and */
00261 /*     EQUED = 'R' or 'B', each element of R must be positive. */
00262 /*     If R is output, each element of R is a power of the radix. */
00263 /*     If R is input, each element of R should be a power of the radix */
00264 /*     to ensure a reliable solution and error estimates. Scaling by */
00265 /*     powers of the radix does not cause rounding errors unless the */
00266 /*     result underflows or overflows. Rounding errors during scaling */
00267 /*     lead to refining with a matrix that is not equivalent to the */
00268 /*     input matrix, producing error estimates that may not be */
00269 /*     reliable. */
00270 
00271 /*     C       (input or output) REAL array, dimension (N) */
00272 /*     The column scale factors for A.  If EQUED = 'C' or 'B', A is */
00273 /*     multiplied on the right by diag(C); if EQUED = 'N' or 'R', C */
00274 /*     is not accessed.  C is an input argument if FACT = 'F'; */
00275 /*     otherwise, C is an output argument.  If FACT = 'F' and */
00276 /*     EQUED = 'C' or 'B', each element of C must be positive. */
00277 /*     If C is output, each element of C is a power of the radix. */
00278 /*     If C is input, each element of C should be a power of the radix */
00279 /*     to ensure a reliable solution and error estimates. Scaling by */
00280 /*     powers of the radix does not cause rounding errors unless the */
00281 /*     result underflows or overflows. Rounding errors during scaling */
00282 /*     lead to refining with a matrix that is not equivalent to the */
00283 /*     input matrix, producing error estimates that may not be */
00284 /*     reliable. */
00285 
00286 /*     B       (input/output) REAL array, dimension (LDB,NRHS) */
00287 /*     On entry, the N-by-NRHS right hand side matrix B. */
00288 /*     On exit, */
00289 /*     if EQUED = 'N', B is not modified; */
00290 /*     if TRANS = 'N' and EQUED = 'R' or 'B', B is overwritten by */
00291 /*        diag(R)*B; */
00292 /*     if TRANS = 'T' or 'C' and EQUED = 'C' or 'B', B is */
00293 /*        overwritten by diag(C)*B. */
00294 
00295 /*     LDB     (input) INTEGER */
00296 /*     The leading dimension of the array B.  LDB >= max(1,N). */
00297 
00298 /*     X       (output) REAL array, dimension (LDX,NRHS) */
00299 /*     If INFO = 0, the N-by-NRHS solution matrix X to the original */
00300 /*     system of equations.  Note that A and B are modified on exit */
00301 /*     if EQUED .ne. 'N', and the solution to the equilibrated system is */
00302 /*     inv(diag(C))*X if TRANS = 'N' and EQUED = 'C' or 'B', or */
00303 /*     inv(diag(R))*X if TRANS = 'T' or 'C' and EQUED = 'R' or 'B'. */
00304 
00305 /*     LDX     (input) INTEGER */
00306 /*     The leading dimension of the array X.  LDX >= max(1,N). */
00307 
00308 /*     RCOND   (output) REAL */
00309 /*     Reciprocal scaled condition number.  This is an estimate of the */
00310 /*     reciprocal Skeel condition number of the matrix A after */
00311 /*     equilibration (if done).  If this is less than the machine */
00312 /*     precision (in particular, if it is zero), the matrix is singular */
00313 /*     to working precision.  Note that the error may still be small even */
00314 /*     if this number is very small and the matrix appears ill- */
00315 /*     conditioned. */
00316 
00317 /*     RPVGRW  (output) REAL */
00318 /*     Reciprocal pivot growth.  On exit, this contains the reciprocal */
00319 /*     pivot growth factor norm(A)/norm(U). The "max absolute element" */
00320 /*     norm is used.  If this is much less than 1, then the stability of */
00321 /*     the LU factorization of the (equilibrated) matrix A could be poor. */
00322 /*     This also means that the solution X, estimated condition numbers, */
00323 /*     and error bounds could be unreliable. If factorization fails with */
00324 /*     0<INFO<=N, then this contains the reciprocal pivot growth factor */
00325 /*     for the leading INFO columns of A.  In SGESVX, this quantity is */
00326 /*     returned in WORK(1). */
00327 
00328 /*     BERR    (output) REAL array, dimension (NRHS) */
00329 /*     Componentwise relative backward error.  This is the */
00330 /*     componentwise relative backward error of each solution vector X(j) */
00331 /*     (i.e., the smallest relative change in any element of A or B that */
00332 /*     makes X(j) an exact solution). */
00333 
00334 /*     N_ERR_BNDS (input) INTEGER */
00335 /*     Number of error bounds to return for each right hand side */
00336 /*     and each type (normwise or componentwise).  See ERR_BNDS_NORM and */
00337 /*     ERR_BNDS_COMP below. */
00338 
00339 /*     ERR_BNDS_NORM  (output) REAL array, dimension (NRHS, N_ERR_BNDS) */
00340 /*     For each right-hand side, this array contains information about */
00341 /*     various error bounds and condition numbers corresponding to the */
00342 /*     normwise relative error, which is defined as follows: */
00343 
00344 /*     Normwise relative error in the ith solution vector: */
00345 /*             max_j (abs(XTRUE(j,i) - X(j,i))) */
00346 /*            ------------------------------ */
00347 /*                  max_j abs(X(j,i)) */
00348 
00349 /*     The array is indexed by the type of error information as described */
00350 /*     below. There currently are up to three pieces of information */
00351 /*     returned. */
00352 
00353 /*     The first index in ERR_BNDS_NORM(i,:) corresponds to the ith */
00354 /*     right-hand side. */
00355 
00356 /*     The second index in ERR_BNDS_NORM(:,err) contains the following */
00357 /*     three fields: */
00358 /*     err = 1 "Trust/don't trust" boolean. Trust the answer if the */
00359 /*              reciprocal condition number is less than the threshold */
00360 /*              sqrt(n) * slamch('Epsilon'). */
00361 
00362 /*     err = 2 "Guaranteed" error bound: The estimated forward error, */
00363 /*              almost certainly within a factor of 10 of the true error */
00364 /*              so long as the next entry is greater than the threshold */
00365 /*              sqrt(n) * slamch('Epsilon'). This error bound should only */
00366 /*              be trusted if the previous boolean is true. */
00367 
00368 /*     err = 3  Reciprocal condition number: Estimated normwise */
00369 /*              reciprocal condition number.  Compared with the threshold */
00370 /*              sqrt(n) * slamch('Epsilon') to determine if the error */
00371 /*              estimate is "guaranteed". These reciprocal condition */
00372 /*              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
00373 /*              appropriately scaled matrix Z. */
00374 /*              Let Z = S*A, where S scales each row by a power of the */
00375 /*              radix so all absolute row sums of Z are approximately 1. */
00376 
00377 /*     See Lapack Working Note 165 for further details and extra */
00378 /*     cautions. */
00379 
00380 /*     ERR_BNDS_COMP  (output) REAL array, dimension (NRHS, N_ERR_BNDS) */
00381 /*     For each right-hand side, this array contains information about */
00382 /*     various error bounds and condition numbers corresponding to the */
00383 /*     componentwise relative error, which is defined as follows: */
00384 
00385 /*     Componentwise relative error in the ith solution vector: */
00386 /*                    abs(XTRUE(j,i) - X(j,i)) */
00387 /*             max_j ---------------------- */
00388 /*                         abs(X(j,i)) */
00389 
00390 /*     The array is indexed by the right-hand side i (on which the */
00391 /*     componentwise relative error depends), and the type of error */
00392 /*     information as described below. There currently are up to three */
00393 /*     pieces of information returned for each right-hand side. If */
00394 /*     componentwise accuracy is not requested (PARAMS(3) = 0.0), then */
00395 /*     ERR_BNDS_COMP is not accessed.  If N_ERR_BNDS .LT. 3, then at most */
00396 /*     the first (:,N_ERR_BNDS) entries are returned. */
00397 
00398 /*     The first index in ERR_BNDS_COMP(i,:) corresponds to the ith */
00399 /*     right-hand side. */
00400 
00401 /*     The second index in ERR_BNDS_COMP(:,err) contains the following */
00402 /*     three fields: */
00403 /*     err = 1 "Trust/don't trust" boolean. Trust the answer if the */
00404 /*              reciprocal condition number is less than the threshold */
00405 /*              sqrt(n) * slamch('Epsilon'). */
00406 
00407 /*     err = 2 "Guaranteed" error bound: The estimated forward error, */
00408 /*              almost certainly within a factor of 10 of the true error */
00409 /*              so long as the next entry is greater than the threshold */
00410 /*              sqrt(n) * slamch('Epsilon'). This error bound should only */
00411 /*              be trusted if the previous boolean is true. */
00412 
00413 /*     err = 3  Reciprocal condition number: Estimated componentwise */
00414 /*              reciprocal condition number.  Compared with the threshold */
00415 /*              sqrt(n) * slamch('Epsilon') to determine if the error */
00416 /*              estimate is "guaranteed". These reciprocal condition */
00417 /*              numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
00418 /*              appropriately scaled matrix Z. */
00419 /*              Let Z = S*(A*diag(x)), where x is the solution for the */
00420 /*              current right-hand side and S scales each row of */
00421 /*              A*diag(x) by a power of the radix so all absolute row */
00422 /*              sums of Z are approximately 1. */
00423 
00424 /*     See Lapack Working Note 165 for further details and extra */
00425 /*     cautions. */
00426 
00427 /*     NPARAMS (input) INTEGER */
00428 /*     Specifies the number of parameters set in PARAMS.  If .LE. 0, the */
00429 /*     PARAMS array is never referenced and default values are used. */
00430 
00431 /*     PARAMS  (input / output) REAL array, dimension NPARAMS */
00432 /*     Specifies algorithm parameters.  If an entry is .LT. 0.0, then */
00433 /*     that entry will be filled with default value used for that */
00434 /*     parameter.  Only positions up to NPARAMS are accessed; defaults */
00435 /*     are used for higher-numbered parameters. */
00436 
00437 /*       PARAMS(LA_LINRX_ITREF_I = 1) : Whether to perform iterative */
00438 /*            refinement or not. */
00439 /*         Default: 1.0 */
00440 /*            = 0.0 : No refinement is performed, and no error bounds are */
00441 /*                    computed. */
00442 /*            = 1.0 : Use the double-precision refinement algorithm, */
00443 /*                    possibly with doubled-single computations if the */
00444 /*                    compilation environment does not support DOUBLE */
00445 /*                    PRECISION. */
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) REAL 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 = slamch_("Safe minimum");
00539     bignum = 1.f / 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 CGBRFSX. */
00554 
00555     *rpvgrw = 0.f;
00556 
00557 /*     Test the input parameters.  PARAMS is not tested until SGERFSX. */
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.f;
00583             i__1 = *n;
00584             for (j = 1; j <= i__1; ++j) {
00585 /* Computing MIN */
00586                 r__1 = rcmin, r__2 = r__[j];
00587                 rcmin = dmin(r__1,r__2);
00588 /* Computing MAX */
00589                 r__1 = rcmax, r__2 = r__[j];
00590                 rcmax = dmax(r__1,r__2);
00591 /* L10: */
00592             }
00593             if (rcmin <= 0.f) {
00594                 *info = -13;
00595             } else if (*n > 0) {
00596                 rowcnd = dmax(rcmin,smlnum) / dmin(rcmax,bignum);
00597             } else {
00598                 rowcnd = 1.f;
00599             }
00600         }
00601         if (colequ && *info == 0) {
00602             rcmin = bignum;
00603             rcmax = 0.f;
00604             i__1 = *n;
00605             for (j = 1; j <= i__1; ++j) {
00606 /* Computing MIN */
00607                 r__1 = rcmin, r__2 = c__[j];
00608                 rcmin = dmin(r__1,r__2);
00609 /* Computing MAX */
00610                 r__1 = rcmax, r__2 = c__[j];
00611                 rcmax = dmax(r__1,r__2);
00612 /* L20: */
00613             }
00614             if (rcmin <= 0.f) {
00615                 *info = -14;
00616             } else if (*n > 0) {
00617                 colcnd = dmax(rcmin,smlnum) / dmin(rcmax,bignum);
00618             } else {
00619                 colcnd = 1.f;
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_("CGBSVXX", &i__1);
00634         return 0;
00635     }
00636 
00637     if (equil) {
00638 
00639 /*     Compute row and column scalings to equilibrate the matrix A. */
00640 
00641         cgbequb_(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             claqgb_(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.f;
00661             }
00662         }
00663         if (! colequ) {
00664             i__1 = *n;
00665             for (j = 1; j <= i__1; ++j) {
00666                 c__[j] = 1.f;
00667             }
00668         }
00669     }
00670 
00671 /*     Scale the right-hand side. */
00672 
00673     if (notran) {
00674         if (rowequ) {
00675             clascl2_(n, nrhs, &r__[1], &b[b_offset], ldb);
00676         }
00677     } else {
00678         if (colequ) {
00679             clascl2_(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         cgbtrf_(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 = cla_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 = cla_gbrpvgrw__(n, kl, ku, n, &ab[ab_offset], ldab, &afb[
00717             afb_offset], ldafb);
00718 
00719 /*     Compute the solution matrix X. */
00720 
00721     clacpy_("Full", n, nrhs, &b[b_offset], ldb, &x[x_offset], ldx);
00722     cgbtrs_(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     cgbrfsx_(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         clascl2_(n, nrhs, &c__[1], &x[x_offset], ldx);
00739     } else if (rowequ && ! notran) {
00740         clascl2_(n, nrhs, &r__[1], &x[x_offset], ldx);
00741     }
00742 
00743     return 0;
00744 
00745 /*     End of CGBSVXX */
00746 
00747 } /* cgbsvxx_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:26