dgbsvxx.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. /* dgbsvxx.f -- translated by f2c (version 20061008).
  2. You must link the resulting object file with libf2c:
  3. on Microsoft Windows system, link with libf2c.lib;
  4. on Linux or Unix systems, link with .../path/to/libf2c.a -lm
  5. or, if you install libf2c.a in a standard place, with -lf2c -lm
  6. -- in that order, at the end of the command line, as in
  7. cc *.o -lf2c -lm
  8. Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
  9. http://www.netlib.org/f2c/libf2c.zip
  10. */
  11. #include "f2c.h"
  12. #include "blaswrap.h"
  13. /* Subroutine */ int dgbsvxx_(char *fact, char *trans, integer *n, integer *
  14. kl, integer *ku, integer *nrhs, doublereal *ab, integer *ldab,
  15. doublereal *afb, integer *ldafb, integer *ipiv, char *equed,
  16. doublereal *r__, doublereal *c__, doublereal *b, integer *ldb,
  17. doublereal *x, integer *ldx, doublereal *rcond, doublereal *rpvgrw,
  18. doublereal *berr, integer *n_err_bnds__, doublereal *err_bnds_norm__,
  19. doublereal *err_bnds_comp__, integer *nparams, doublereal *params,
  20. doublereal *work, integer *iwork, integer *info)
  21. {
  22. /* System generated locals */
  23. integer ab_dim1, ab_offset, afb_dim1, afb_offset, b_dim1, b_offset,
  24. x_dim1, x_offset, err_bnds_norm_dim1, err_bnds_norm_offset,
  25. err_bnds_comp_dim1, err_bnds_comp_offset, i__1, i__2;
  26. doublereal d__1, d__2;
  27. /* Local variables */
  28. integer i__, j;
  29. doublereal amax;
  30. extern doublereal dla_gbrpvgrw__(integer *, integer *, integer *, integer
  31. *, doublereal *, integer *, doublereal *, integer *);
  32. extern logical lsame_(char *, char *);
  33. doublereal rcmin, rcmax;
  34. logical equil;
  35. extern doublereal dlamch_(char *);
  36. extern /* Subroutine */ int dlaqgb_(integer *, integer *, integer *,
  37. integer *, doublereal *, integer *, doublereal *, doublereal *,
  38. doublereal *, doublereal *, doublereal *, char *);
  39. doublereal colcnd;
  40. extern /* Subroutine */ int dgbtrf_(integer *, integer *, integer *,
  41. integer *, doublereal *, integer *, integer *, integer *);
  42. logical nofact;
  43. extern /* Subroutine */ int dlacpy_(char *, integer *, integer *,
  44. doublereal *, integer *, doublereal *, integer *),
  45. xerbla_(char *, integer *);
  46. doublereal bignum;
  47. extern /* Subroutine */ int dgbtrs_(char *, integer *, integer *, integer
  48. *, integer *, doublereal *, integer *, integer *, doublereal *,
  49. integer *, integer *);
  50. integer infequ;
  51. logical colequ;
  52. doublereal rowcnd;
  53. logical notran;
  54. doublereal smlnum;
  55. logical rowequ;
  56. extern /* Subroutine */ int dlascl2_(integer *, integer *, doublereal *,
  57. doublereal *, integer *), dgbequb_(integer *, integer *, integer *
  58. , integer *, doublereal *, integer *, doublereal *, doublereal *,
  59. doublereal *, doublereal *, doublereal *, integer *), dgbrfsx_(
  60. char *, char *, integer *, integer *, integer *, integer *,
  61. doublereal *, integer *, doublereal *, integer *, integer *,
  62. doublereal *, doublereal *, doublereal *, integer *, doublereal *,
  63. integer *, doublereal *, doublereal *, integer *, doublereal *,
  64. doublereal *, integer *, doublereal *, doublereal *, integer *,
  65. integer *);
  66. /* -- LAPACK driver routine (version 3.2) -- */
  67. /* -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */
  68. /* -- Jason Riedy of Univ. of California Berkeley. -- */
  69. /* -- November 2008 -- */
  70. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  71. /* -- Univ. of California Berkeley and NAG Ltd. -- */
  72. /* .. */
  73. /* .. Scalar Arguments .. */
  74. /* .. */
  75. /* .. Array Arguments .. */
  76. /* .. */
  77. /* Purpose */
  78. /* ======= */
  79. /* DGBSVXX uses the LU factorization to compute the solution to a */
  80. /* double precision system of linear equations A * X = B, where A is an */
  81. /* N-by-N matrix and X and B are N-by-NRHS matrices. */
  82. /* If requested, both normwise and maximum componentwise error bounds */
  83. /* are returned. DGBSVXX will return a solution with a tiny */
  84. /* guaranteed error (O(eps) where eps is the working machine */
  85. /* precision) unless the matrix is very ill-conditioned, in which */
  86. /* case a warning is returned. Relevant condition numbers also are */
  87. /* calculated and returned. */
  88. /* DGBSVXX accepts user-provided factorizations and equilibration */
  89. /* factors; see the definitions of the FACT and EQUED options. */
  90. /* Solving with refinement and using a factorization from a previous */
  91. /* DGBSVXX call will also produce a solution with either O(eps) */
  92. /* errors or warnings, but we cannot make that claim for general */
  93. /* user-provided factorizations and equilibration factors if they */
  94. /* differ from what DGBSVXX would itself produce. */
  95. /* Description */
  96. /* =========== */
  97. /* The following steps are performed: */
  98. /* 1. If FACT = 'E', double precision scaling factors are computed to equilibrate */
  99. /* the system: */
  100. /* TRANS = 'N': diag(R)*A*diag(C) *inv(diag(C))*X = diag(R)*B */
  101. /* TRANS = 'T': (diag(R)*A*diag(C))**T *inv(diag(R))*X = diag(C)*B */
  102. /* TRANS = 'C': (diag(R)*A*diag(C))**H *inv(diag(R))*X = diag(C)*B */
  103. /* Whether or not the system will be equilibrated depends on the */
  104. /* scaling of the matrix A, but if equilibration is used, A is */
  105. /* overwritten by diag(R)*A*diag(C) and B by diag(R)*B (if TRANS='N') */
  106. /* or diag(C)*B (if TRANS = 'T' or 'C'). */
  107. /* 2. If FACT = 'N' or 'E', the LU decomposition is used to factor */
  108. /* the matrix A (after equilibration if FACT = 'E') as */
  109. /* A = P * L * U, */
  110. /* where P is a permutation matrix, L is a unit lower triangular */
  111. /* matrix, and U is upper triangular. */
  112. /* 3. If some U(i,i)=0, so that U is exactly singular, then the */
  113. /* routine returns with INFO = i. Otherwise, the factored form of A */
  114. /* is used to estimate the condition number of the matrix A (see */
  115. /* argument RCOND). If the reciprocal of the condition number is less */
  116. /* than machine precision, the routine still goes on to solve for X */
  117. /* and compute error bounds as described below. */
  118. /* 4. The system of equations is solved for X using the factored form */
  119. /* of A. */
  120. /* 5. By default (unless PARAMS(LA_LINRX_ITREF_I) is set to zero), */
  121. /* the routine will use iterative refinement to try to get a small */
  122. /* error and error bounds. Refinement calculates the residual to at */
  123. /* least twice the working precision. */
  124. /* 6. If equilibration was used, the matrix X is premultiplied by */
  125. /* diag(C) (if TRANS = 'N') or diag(R) (if TRANS = 'T' or 'C') so */
  126. /* that it solves the original system before equilibration. */
  127. /* Arguments */
  128. /* ========= */
  129. /* Some optional parameters are bundled in the PARAMS array. These */
  130. /* settings determine how refinement is performed, but often the */
  131. /* defaults are acceptable. If the defaults are acceptable, users */
  132. /* can pass NPARAMS = 0 which prevents the source code from accessing */
  133. /* the PARAMS argument. */
  134. /* FACT (input) CHARACTER*1 */
  135. /* Specifies whether or not the factored form of the matrix A is */
  136. /* supplied on entry, and if not, whether the matrix A should be */
  137. /* equilibrated before it is factored. */
  138. /* = 'F': On entry, AF and IPIV contain the factored form of A. */
  139. /* If EQUED is not 'N', the matrix A has been */
  140. /* equilibrated with scaling factors given by R and C. */
  141. /* A, AF, and IPIV are not modified. */
  142. /* = 'N': The matrix A will be copied to AF and factored. */
  143. /* = 'E': The matrix A will be equilibrated if necessary, then */
  144. /* copied to AF and factored. */
  145. /* TRANS (input) CHARACTER*1 */
  146. /* Specifies the form of the system of equations: */
  147. /* = 'N': A * X = B (No transpose) */
  148. /* = 'T': A**T * X = B (Transpose) */
  149. /* = 'C': A**H * X = B (Conjugate Transpose = Transpose) */
  150. /* N (input) INTEGER */
  151. /* The number of linear equations, i.e., the order of the */
  152. /* matrix A. N >= 0. */
  153. /* KL (input) INTEGER */
  154. /* The number of subdiagonals within the band of A. KL >= 0. */
  155. /* KU (input) INTEGER */
  156. /* The number of superdiagonals within the band of A. KU >= 0. */
  157. /* NRHS (input) INTEGER */
  158. /* The number of right hand sides, i.e., the number of columns */
  159. /* of the matrices B and X. NRHS >= 0. */
  160. /* AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N) */
  161. /* On entry, the matrix A in band storage, in rows 1 to KL+KU+1. */
  162. /* The j-th column of A is stored in the j-th column of the */
  163. /* array AB as follows: */
  164. /* AB(KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+kl) */
  165. /* If FACT = 'F' and EQUED is not 'N', then AB must have been */
  166. /* equilibrated by the scaling factors in R and/or C. AB is not */
  167. /* modified if FACT = 'F' or 'N', or if FACT = 'E' and */
  168. /* EQUED = 'N' on exit. */
  169. /* On exit, if EQUED .ne. 'N', A is scaled as follows: */
  170. /* EQUED = 'R': A := diag(R) * A */
  171. /* EQUED = 'C': A := A * diag(C) */
  172. /* EQUED = 'B': A := diag(R) * A * diag(C). */
  173. /* LDAB (input) INTEGER */
  174. /* The leading dimension of the array AB. LDAB >= KL+KU+1. */
  175. /* AFB (input or output) DOUBLE PRECISION array, dimension (LDAFB,N) */
  176. /* If FACT = 'F', then AFB is an input argument and on entry */
  177. /* contains details of the LU factorization of the band matrix */
  178. /* A, as computed by DGBTRF. U is stored as an upper triangular */
  179. /* band matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, */
  180. /* and the multipliers used during the factorization are stored */
  181. /* in rows KL+KU+2 to 2*KL+KU+1. If EQUED .ne. 'N', then AFB is */
  182. /* the factored form of the equilibrated matrix A. */
  183. /* If FACT = 'N', then AF is an output argument and on exit */
  184. /* returns the factors L and U from the factorization A = P*L*U */
  185. /* of the original matrix A. */
  186. /* If FACT = 'E', then AF is an output argument and on exit */
  187. /* returns the factors L and U from the factorization A = P*L*U */
  188. /* of the equilibrated matrix A (see the description of A for */
  189. /* the form of the equilibrated matrix). */
  190. /* LDAFB (input) INTEGER */
  191. /* The leading dimension of the array AFB. LDAFB >= 2*KL+KU+1. */
  192. /* IPIV (input or output) INTEGER array, dimension (N) */
  193. /* If FACT = 'F', then IPIV is an input argument and on entry */
  194. /* contains the pivot indices from the factorization A = P*L*U */
  195. /* as computed by DGETRF; row i of the matrix was interchanged */
  196. /* with row IPIV(i). */
  197. /* If FACT = 'N', then IPIV is an output argument and on exit */
  198. /* contains the pivot indices from the factorization A = P*L*U */
  199. /* of the original matrix A. */
  200. /* If FACT = 'E', then IPIV is an output argument and on exit */
  201. /* contains the pivot indices from the factorization A = P*L*U */
  202. /* of the equilibrated matrix A. */
  203. /* EQUED (input or output) CHARACTER*1 */
  204. /* Specifies the form of equilibration that was done. */
  205. /* = 'N': No equilibration (always true if FACT = 'N'). */
  206. /* = 'R': Row equilibration, i.e., A has been premultiplied by */
  207. /* diag(R). */
  208. /* = 'C': Column equilibration, i.e., A has been postmultiplied */
  209. /* by diag(C). */
  210. /* = 'B': Both row and column equilibration, i.e., A has been */
  211. /* replaced by diag(R) * A * diag(C). */
  212. /* EQUED is an input argument if FACT = 'F'; otherwise, it is an */
  213. /* output argument. */
  214. /* R (input or output) DOUBLE PRECISION array, dimension (N) */
  215. /* The row scale factors for A. If EQUED = 'R' or 'B', A is */
  216. /* multiplied on the left by diag(R); if EQUED = 'N' or 'C', R */
  217. /* is not accessed. R is an input argument if FACT = 'F'; */
  218. /* otherwise, R is an output argument. If FACT = 'F' and */
  219. /* EQUED = 'R' or 'B', each element of R must be positive. */
  220. /* If R is output, each element of R is a power of the radix. */
  221. /* If R is input, each element of R should be a power of the radix */
  222. /* to ensure a reliable solution and error estimates. Scaling by */
  223. /* powers of the radix does not cause rounding errors unless the */
  224. /* result underflows or overflows. Rounding errors during scaling */
  225. /* lead to refining with a matrix that is not equivalent to the */
  226. /* input matrix, producing error estimates that may not be */
  227. /* reliable. */
  228. /* C (input or output) DOUBLE PRECISION array, dimension (N) */
  229. /* The column scale factors for A. If EQUED = 'C' or 'B', A is */
  230. /* multiplied on the right by diag(C); if EQUED = 'N' or 'R', C */
  231. /* is not accessed. C is an input argument if FACT = 'F'; */
  232. /* otherwise, C is an output argument. If FACT = 'F' and */
  233. /* EQUED = 'C' or 'B', each element of C must be positive. */
  234. /* If C is output, each element of C is a power of the radix. */
  235. /* If C is input, each element of C should be a power of the radix */
  236. /* to ensure a reliable solution and error estimates. Scaling by */
  237. /* powers of the radix does not cause rounding errors unless the */
  238. /* result underflows or overflows. Rounding errors during scaling */
  239. /* lead to refining with a matrix that is not equivalent to the */
  240. /* input matrix, producing error estimates that may not be */
  241. /* reliable. */
  242. /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
  243. /* On entry, the N-by-NRHS right hand side matrix B. */
  244. /* On exit, */
  245. /* if EQUED = 'N', B is not modified; */
  246. /* if TRANS = 'N' and EQUED = 'R' or 'B', B is overwritten by */
  247. /* diag(R)*B; */
  248. /* if TRANS = 'T' or 'C' and EQUED = 'C' or 'B', B is */
  249. /* overwritten by diag(C)*B. */
  250. /* LDB (input) INTEGER */
  251. /* The leading dimension of the array B. LDB >= max(1,N). */
  252. /* X (output) DOUBLE PRECISION array, dimension (LDX,NRHS) */
  253. /* If INFO = 0, the N-by-NRHS solution matrix X to the original */
  254. /* system of equations. Note that A and B are modified on exit */
  255. /* if EQUED .ne. 'N', and the solution to the equilibrated system is */
  256. /* inv(diag(C))*X if TRANS = 'N' and EQUED = 'C' or 'B', or */
  257. /* inv(diag(R))*X if TRANS = 'T' or 'C' and EQUED = 'R' or 'B'. */
  258. /* LDX (input) INTEGER */
  259. /* The leading dimension of the array X. LDX >= max(1,N). */
  260. /* RCOND (output) DOUBLE PRECISION */
  261. /* Reciprocal scaled condition number. This is an estimate of the */
  262. /* reciprocal Skeel condition number of the matrix A after */
  263. /* equilibration (if done). If this is less than the machine */
  264. /* precision (in particular, if it is zero), the matrix is singular */
  265. /* to working precision. Note that the error may still be small even */
  266. /* if this number is very small and the matrix appears ill- */
  267. /* conditioned. */
  268. /* RPVGRW (output) DOUBLE PRECISION */
  269. /* Reciprocal pivot growth. On exit, this contains the reciprocal */
  270. /* pivot growth factor norm(A)/norm(U). The "max absolute element" */
  271. /* norm is used. If this is much less than 1, then the stability of */
  272. /* the LU factorization of the (equilibrated) matrix A could be poor. */
  273. /* This also means that the solution X, estimated condition numbers, */
  274. /* and error bounds could be unreliable. If factorization fails with */
  275. /* 0<INFO<=N, then this contains the reciprocal pivot growth factor */
  276. /* for the leading INFO columns of A. In DGESVX, this quantity is */
  277. /* returned in WORK(1). */
  278. /* BERR (output) DOUBLE PRECISION array, dimension (NRHS) */
  279. /* Componentwise relative backward error. This is the */
  280. /* componentwise relative backward error of each solution vector X(j) */
  281. /* (i.e., the smallest relative change in any element of A or B that */
  282. /* makes X(j) an exact solution). */
  283. /* N_ERR_BNDS (input) INTEGER */
  284. /* Number of error bounds to return for each right hand side */
  285. /* and each type (normwise or componentwise). See ERR_BNDS_NORM and */
  286. /* ERR_BNDS_COMP below. */
  287. /* ERR_BNDS_NORM (output) DOUBLE PRECISION array, dimension (NRHS, N_ERR_BNDS) */
  288. /* For each right-hand side, this array contains information about */
  289. /* various error bounds and condition numbers corresponding to the */
  290. /* normwise relative error, which is defined as follows: */
  291. /* Normwise relative error in the ith solution vector: */
  292. /* max_j (abs(XTRUE(j,i) - X(j,i))) */
  293. /* ------------------------------ */
  294. /* max_j abs(X(j,i)) */
  295. /* The array is indexed by the type of error information as described */
  296. /* below. There currently are up to three pieces of information */
  297. /* returned. */
  298. /* The first index in ERR_BNDS_NORM(i,:) corresponds to the ith */
  299. /* right-hand side. */
  300. /* The second index in ERR_BNDS_NORM(:,err) contains the following */
  301. /* three fields: */
  302. /* err = 1 "Trust/don't trust" boolean. Trust the answer if the */
  303. /* reciprocal condition number is less than the threshold */
  304. /* sqrt(n) * dlamch('Epsilon'). */
  305. /* err = 2 "Guaranteed" error bound: The estimated forward error, */
  306. /* almost certainly within a factor of 10 of the true error */
  307. /* so long as the next entry is greater than the threshold */
  308. /* sqrt(n) * dlamch('Epsilon'). This error bound should only */
  309. /* be trusted if the previous boolean is true. */
  310. /* err = 3 Reciprocal condition number: Estimated normwise */
  311. /* reciprocal condition number. Compared with the threshold */
  312. /* sqrt(n) * dlamch('Epsilon') to determine if the error */
  313. /* estimate is "guaranteed". These reciprocal condition */
  314. /* numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
  315. /* appropriately scaled matrix Z. */
  316. /* Let Z = S*A, where S scales each row by a power of the */
  317. /* radix so all absolute row sums of Z are approximately 1. */
  318. /* See Lapack Working Note 165 for further details and extra */
  319. /* cautions. */
  320. /* ERR_BNDS_COMP (output) DOUBLE PRECISION array, dimension (NRHS, N_ERR_BNDS) */
  321. /* For each right-hand side, this array contains information about */
  322. /* various error bounds and condition numbers corresponding to the */
  323. /* componentwise relative error, which is defined as follows: */
  324. /* Componentwise relative error in the ith solution vector: */
  325. /* abs(XTRUE(j,i) - X(j,i)) */
  326. /* max_j ---------------------- */
  327. /* abs(X(j,i)) */
  328. /* The array is indexed by the right-hand side i (on which the */
  329. /* componentwise relative error depends), and the type of error */
  330. /* information as described below. There currently are up to three */
  331. /* pieces of information returned for each right-hand side. If */
  332. /* componentwise accuracy is not requested (PARAMS(3) = 0.0), then */
  333. /* ERR_BNDS_COMP is not accessed. If N_ERR_BNDS .LT. 3, then at most */
  334. /* the first (:,N_ERR_BNDS) entries are returned. */
  335. /* The first index in ERR_BNDS_COMP(i,:) corresponds to the ith */
  336. /* right-hand side. */
  337. /* The second index in ERR_BNDS_COMP(:,err) contains the following */
  338. /* three fields: */
  339. /* err = 1 "Trust/don't trust" boolean. Trust the answer if the */
  340. /* reciprocal condition number is less than the threshold */
  341. /* sqrt(n) * dlamch('Epsilon'). */
  342. /* err = 2 "Guaranteed" error bound: The estimated forward error, */
  343. /* almost certainly within a factor of 10 of the true error */
  344. /* so long as the next entry is greater than the threshold */
  345. /* sqrt(n) * dlamch('Epsilon'). This error bound should only */
  346. /* be trusted if the previous boolean is true. */
  347. /* err = 3 Reciprocal condition number: Estimated componentwise */
  348. /* reciprocal condition number. Compared with the threshold */
  349. /* sqrt(n) * dlamch('Epsilon') to determine if the error */
  350. /* estimate is "guaranteed". These reciprocal condition */
  351. /* numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
  352. /* appropriately scaled matrix Z. */
  353. /* Let Z = S*(A*diag(x)), where x is the solution for the */
  354. /* current right-hand side and S scales each row of */
  355. /* A*diag(x) by a power of the radix so all absolute row */
  356. /* sums of Z are approximately 1. */
  357. /* See Lapack Working Note 165 for further details and extra */
  358. /* cautions. */
  359. /* NPARAMS (input) INTEGER */
  360. /* Specifies the number of parameters set in PARAMS. If .LE. 0, the */
  361. /* PARAMS array is never referenced and default values are used. */
  362. /* PARAMS (input / output) DOUBLE PRECISION array, dimension NPARAMS */
  363. /* Specifies algorithm parameters. If an entry is .LT. 0.0, then */
  364. /* that entry will be filled with default value used for that */
  365. /* parameter. Only positions up to NPARAMS are accessed; defaults */
  366. /* are used for higher-numbered parameters. */
  367. /* PARAMS(LA_LINRX_ITREF_I = 1) : Whether to perform iterative */
  368. /* refinement or not. */
  369. /* Default: 1.0D+0 */
  370. /* = 0.0 : No refinement is performed, and no error bounds are */
  371. /* computed. */
  372. /* = 1.0 : Use the extra-precise refinement algorithm. */
  373. /* (other values are reserved for future use) */
  374. /* PARAMS(LA_LINRX_ITHRESH_I = 2) : Maximum number of residual */
  375. /* computations allowed for refinement. */
  376. /* Default: 10 */
  377. /* Aggressive: Set to 100 to permit convergence using approximate */
  378. /* factorizations or factorizations other than LU. If */
  379. /* the factorization uses a technique other than */
  380. /* Gaussian elimination, the guarantees in */
  381. /* err_bnds_norm and err_bnds_comp may no longer be */
  382. /* trustworthy. */
  383. /* PARAMS(LA_LINRX_CWISE_I = 3) : Flag determining if the code */
  384. /* will attempt to find a solution with small componentwise */
  385. /* relative error in the double-precision algorithm. Positive */
  386. /* is true, 0.0 is false. */
  387. /* Default: 1.0 (attempt componentwise convergence) */
  388. /* WORK (workspace) DOUBLE PRECISION array, dimension (4*N) */
  389. /* IWORK (workspace) INTEGER array, dimension (N) */
  390. /* INFO (output) INTEGER */
  391. /* = 0: Successful exit. The solution to every right-hand side is */
  392. /* guaranteed. */
  393. /* < 0: If INFO = -i, the i-th argument had an illegal value */
  394. /* > 0 and <= N: U(INFO,INFO) is exactly zero. The factorization */
  395. /* has been completed, but the factor U is exactly singular, so */
  396. /* the solution and error bounds could not be computed. RCOND = 0 */
  397. /* is returned. */
  398. /* = N+J: The solution corresponding to the Jth right-hand side is */
  399. /* not guaranteed. The solutions corresponding to other right- */
  400. /* hand sides K with K > J may not be guaranteed as well, but */
  401. /* only the first such right-hand side is reported. If a small */
  402. /* componentwise error is not requested (PARAMS(3) = 0.0) then */
  403. /* the Jth right-hand side is the first with a normwise error */
  404. /* bound that is not guaranteed (the smallest J such */
  405. /* that ERR_BNDS_NORM(J,1) = 0.0). By default (PARAMS(3) = 1.0) */
  406. /* the Jth right-hand side is the first with either a normwise or */
  407. /* componentwise error bound that is not guaranteed (the smallest */
  408. /* J such that either ERR_BNDS_NORM(J,1) = 0.0 or */
  409. /* ERR_BNDS_COMP(J,1) = 0.0). See the definition of */
  410. /* ERR_BNDS_NORM(:,1) and ERR_BNDS_COMP(:,1). To get information */
  411. /* about all of the right-hand sides check ERR_BNDS_NORM or */
  412. /* ERR_BNDS_COMP. */
  413. /* ================================================================== */
  414. /* .. Parameters .. */
  415. /* .. */
  416. /* .. Local Scalars .. */
  417. /* .. */
  418. /* .. External Functions .. */
  419. /* .. */
  420. /* .. External Subroutines .. */
  421. /* .. */
  422. /* .. Intrinsic Functions .. */
  423. /* .. */
  424. /* .. Executable Statements .. */
  425. /* Parameter adjustments */
  426. err_bnds_comp_dim1 = *nrhs;
  427. err_bnds_comp_offset = 1 + err_bnds_comp_dim1;
  428. err_bnds_comp__ -= err_bnds_comp_offset;
  429. err_bnds_norm_dim1 = *nrhs;
  430. err_bnds_norm_offset = 1 + err_bnds_norm_dim1;
  431. err_bnds_norm__ -= err_bnds_norm_offset;
  432. ab_dim1 = *ldab;
  433. ab_offset = 1 + ab_dim1;
  434. ab -= ab_offset;
  435. afb_dim1 = *ldafb;
  436. afb_offset = 1 + afb_dim1;
  437. afb -= afb_offset;
  438. --ipiv;
  439. --r__;
  440. --c__;
  441. b_dim1 = *ldb;
  442. b_offset = 1 + b_dim1;
  443. b -= b_offset;
  444. x_dim1 = *ldx;
  445. x_offset = 1 + x_dim1;
  446. x -= x_offset;
  447. --berr;
  448. --params;
  449. --work;
  450. --iwork;
  451. /* Function Body */
  452. *info = 0;
  453. nofact = lsame_(fact, "N");
  454. equil = lsame_(fact, "E");
  455. notran = lsame_(trans, "N");
  456. smlnum = dlamch_("Safe minimum");
  457. bignum = 1. / smlnum;
  458. if (nofact || equil) {
  459. *(unsigned char *)equed = 'N';
  460. rowequ = FALSE_;
  461. colequ = FALSE_;
  462. } else {
  463. rowequ = lsame_(equed, "R") || lsame_(equed,
  464. "B");
  465. colequ = lsame_(equed, "C") || lsame_(equed,
  466. "B");
  467. }
  468. /* Default is failure. If an input parameter is wrong or */
  469. /* factorization fails, make everything look horrible. Only the */
  470. /* pivot growth is set here, the rest is initialized in DGBRFSX. */
  471. *rpvgrw = 0.;
  472. /* Test the input parameters. PARAMS is not tested until DGBRFSX. */
  473. if (! nofact && ! equil && ! lsame_(fact, "F")) {
  474. *info = -1;
  475. } else if (! notran && ! lsame_(trans, "T") && !
  476. lsame_(trans, "C")) {
  477. *info = -2;
  478. } else if (*n < 0) {
  479. *info = -3;
  480. } else if (*kl < 0) {
  481. *info = -4;
  482. } else if (*ku < 0) {
  483. *info = -5;
  484. } else if (*nrhs < 0) {
  485. *info = -6;
  486. } else if (*ldab < *kl + *ku + 1) {
  487. *info = -8;
  488. } else if (*ldafb < (*kl << 1) + *ku + 1) {
  489. *info = -10;
  490. } else if (lsame_(fact, "F") && ! (rowequ || colequ
  491. || lsame_(equed, "N"))) {
  492. *info = -12;
  493. } else {
  494. if (rowequ) {
  495. rcmin = bignum;
  496. rcmax = 0.;
  497. i__1 = *n;
  498. for (j = 1; j <= i__1; ++j) {
  499. /* Computing MIN */
  500. d__1 = rcmin, d__2 = r__[j];
  501. rcmin = min(d__1,d__2);
  502. /* Computing MAX */
  503. d__1 = rcmax, d__2 = r__[j];
  504. rcmax = max(d__1,d__2);
  505. /* L10: */
  506. }
  507. if (rcmin <= 0.) {
  508. *info = -13;
  509. } else if (*n > 0) {
  510. rowcnd = max(rcmin,smlnum) / min(rcmax,bignum);
  511. } else {
  512. rowcnd = 1.;
  513. }
  514. }
  515. if (colequ && *info == 0) {
  516. rcmin = bignum;
  517. rcmax = 0.;
  518. i__1 = *n;
  519. for (j = 1; j <= i__1; ++j) {
  520. /* Computing MIN */
  521. d__1 = rcmin, d__2 = c__[j];
  522. rcmin = min(d__1,d__2);
  523. /* Computing MAX */
  524. d__1 = rcmax, d__2 = c__[j];
  525. rcmax = max(d__1,d__2);
  526. /* L20: */
  527. }
  528. if (rcmin <= 0.) {
  529. *info = -14;
  530. } else if (*n > 0) {
  531. colcnd = max(rcmin,smlnum) / min(rcmax,bignum);
  532. } else {
  533. colcnd = 1.;
  534. }
  535. }
  536. if (*info == 0) {
  537. if (*ldb < max(1,*n)) {
  538. *info = -15;
  539. } else if (*ldx < max(1,*n)) {
  540. *info = -16;
  541. }
  542. }
  543. }
  544. if (*info != 0) {
  545. i__1 = -(*info);
  546. xerbla_("DGBSVXX", &i__1);
  547. return 0;
  548. }
  549. if (equil) {
  550. /* Compute row and column scalings to equilibrate the matrix A. */
  551. dgbequb_(n, n, kl, ku, &ab[ab_offset], ldab, &r__[1], &c__[1], &
  552. rowcnd, &colcnd, &amax, &infequ);
  553. if (infequ == 0) {
  554. /* Equilibrate the matrix. */
  555. dlaqgb_(n, n, kl, ku, &ab[ab_offset], ldab, &r__[1], &c__[1], &
  556. rowcnd, &colcnd, &amax, equed);
  557. rowequ = lsame_(equed, "R") || lsame_(equed,
  558. "B");
  559. colequ = lsame_(equed, "C") || lsame_(equed,
  560. "B");
  561. }
  562. /* If the scaling factors are not applied, set them to 1.0. */
  563. if (! rowequ) {
  564. i__1 = *n;
  565. for (j = 1; j <= i__1; ++j) {
  566. r__[j] = 1.;
  567. }
  568. }
  569. if (! colequ) {
  570. i__1 = *n;
  571. for (j = 1; j <= i__1; ++j) {
  572. c__[j] = 1.;
  573. }
  574. }
  575. }
  576. /* Scale the right hand side. */
  577. if (notran) {
  578. if (rowequ) {
  579. dlascl2_(n, nrhs, &r__[1], &b[b_offset], ldb);
  580. }
  581. } else {
  582. if (colequ) {
  583. dlascl2_(n, nrhs, &c__[1], &b[b_offset], ldb);
  584. }
  585. }
  586. if (nofact || equil) {
  587. /* Compute the LU factorization of A. */
  588. i__1 = *n;
  589. for (j = 1; j <= i__1; ++j) {
  590. i__2 = (*kl << 1) + *ku + 1;
  591. for (i__ = *kl + 1; i__ <= i__2; ++i__) {
  592. afb[i__ + j * afb_dim1] = ab[i__ - *kl + j * ab_dim1];
  593. /* L30: */
  594. }
  595. /* L40: */
  596. }
  597. dgbtrf_(n, n, kl, ku, &afb[afb_offset], ldafb, &ipiv[1], info);
  598. /* Return if INFO is non-zero. */
  599. if (*info > 0) {
  600. /* Pivot in column INFO is exactly 0 */
  601. /* Compute the reciprocal pivot growth factor of the */
  602. /* leading rank-deficient INFO columns of A. */
  603. *rpvgrw = dla_gbrpvgrw__(n, kl, ku, info, &ab[ab_offset], ldab, &
  604. afb[afb_offset], ldafb);
  605. return 0;
  606. }
  607. }
  608. /* Compute the reciprocal pivot growth factor RPVGRW. */
  609. *rpvgrw = dla_gbrpvgrw__(n, kl, ku, n, &ab[ab_offset], ldab, &afb[
  610. afb_offset], ldafb);
  611. /* Compute the solution matrix X. */
  612. dlacpy_("Full", n, nrhs, &b[b_offset], ldb, &x[x_offset], ldx);
  613. dgbtrs_(trans, n, kl, ku, nrhs, &afb[afb_offset], ldafb, &ipiv[1], &x[
  614. x_offset], ldx, info);
  615. /* Use iterative refinement to improve the computed solution and */
  616. /* compute error bounds and backward error estimates for it. */
  617. dgbrfsx_(trans, equed, n, kl, ku, nrhs, &ab[ab_offset], ldab, &afb[
  618. afb_offset], ldafb, &ipiv[1], &r__[1], &c__[1], &b[b_offset], ldb,
  619. &x[x_offset], ldx, rcond, &berr[1], n_err_bnds__, &
  620. err_bnds_norm__[err_bnds_norm_offset], &err_bnds_comp__[
  621. err_bnds_comp_offset], nparams, &params[1], &work[1], &iwork[1],
  622. info);
  623. /* Scale solutions. */
  624. if (colequ && notran) {
  625. dlascl2_(n, nrhs, &c__[1], &x[x_offset], ldx);
  626. } else if (rowequ && ! notran) {
  627. dlascl2_(n, nrhs, &r__[1], &x[x_offset], ldx);
  628. }
  629. return 0;
  630. /* End of DGBSVXX */
  631. } /* dgbsvxx_ */