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


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