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


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