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