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


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