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