dgbrfsx.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. /* dgbrfsx.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. /* Table of constant values */
  14. static integer c_n1 = -1;
  15. static integer c__0 = 0;
  16. static integer c__1 = 1;
  17. /* Subroutine */ int _starpu_dgbrfsx_(char *trans, char *equed, integer *n, integer *
  18. kl, integer *ku, integer *nrhs, doublereal *ab, integer *ldab,
  19. doublereal *afb, integer *ldafb, integer *ipiv, doublereal *r__,
  20. doublereal *c__, doublereal *b, integer *ldb, doublereal *x, integer *
  21. ldx, doublereal *rcond, doublereal *berr, integer *n_err_bnds__,
  22. doublereal *err_bnds_norm__, doublereal *err_bnds_comp__, integer *
  23. nparams, doublereal *params, doublereal *work, integer *iwork,
  24. integer *info)
  25. {
  26. /* System generated locals */
  27. integer ab_dim1, ab_offset, afb_dim1, afb_offset, b_dim1, b_offset,
  28. x_dim1, x_offset, err_bnds_norm_dim1, err_bnds_norm_offset,
  29. err_bnds_comp_dim1, err_bnds_comp_offset, i__1;
  30. doublereal d__1, d__2;
  31. /* Builtin functions */
  32. double sqrt(doublereal);
  33. /* Local variables */
  34. doublereal illrcond_thresh__, unstable_thresh__, err_lbnd__;
  35. integer ref_type__;
  36. extern integer _starpu_ilatrans_(char *);
  37. integer j;
  38. doublereal rcond_tmp__;
  39. integer prec_type__, trans_type__;
  40. extern doublereal _starpu_dla_gbrcond__(char *, integer *, integer *, integer *,
  41. doublereal *, integer *, doublereal *, integer *, integer *,
  42. integer *, doublereal *, integer *, doublereal *, integer *,
  43. ftnlen);
  44. doublereal cwise_wrong__;
  45. extern /* Subroutine */ int _starpu_dla_gbrfsx_extended__(integer *, integer *,
  46. integer *, integer *, integer *, integer *, doublereal *, integer
  47. *, doublereal *, integer *, integer *, logical *, doublereal *,
  48. doublereal *, integer *, doublereal *, integer *, doublereal *,
  49. integer *, doublereal *, doublereal *, doublereal *, doublereal *,
  50. doublereal *, doublereal *, doublereal *, integer *, doublereal *
  51. , doublereal *, logical *, integer *);
  52. char norm[1];
  53. logical ignore_cwise__;
  54. extern logical _starpu_lsame_(char *, char *);
  55. doublereal anorm;
  56. extern doublereal _starpu_dlangb_(char *, integer *, integer *, integer *,
  57. doublereal *, integer *, doublereal *), _starpu_dlamch_(char *);
  58. extern /* Subroutine */ int _starpu_dgbcon_(char *, integer *, integer *, integer
  59. *, doublereal *, integer *, integer *, doublereal *, doublereal *,
  60. doublereal *, integer *, integer *), _starpu_xerbla_(char *,
  61. integer *);
  62. logical colequ, notran, rowequ;
  63. extern integer _starpu_ilaprec_(char *);
  64. integer ithresh, n_norms__;
  65. doublereal rthresh;
  66. /* -- LAPACK routine (version 3.2.1) -- */
  67. /* -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */
  68. /* -- Jason Riedy of Univ. of California Berkeley. -- */
  69. /* -- April 2009 -- */
  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. /* DGBRFSX improves the computed solution to a system of linear */
  80. /* equations and provides error bounds and backward error estimates */
  81. /* for the solution. In addition to normwise error bound, the code */
  82. /* provides maximum componentwise error bound if possible. See */
  83. /* comments for ERR_BNDS_NORM and ERR_BNDS_COMP for details of the */
  84. /* error bounds. */
  85. /* The original system of linear equations may have been equilibrated */
  86. /* before calling this routine, as described by arguments EQUED, R */
  87. /* and C below. In this case, the solution and error bounds returned */
  88. /* are for the original unequilibrated system. */
  89. /* Arguments */
  90. /* ========= */
  91. /* Some optional parameters are bundled in the PARAMS array. These */
  92. /* settings determine how refinement is performed, but often the */
  93. /* defaults are acceptable. If the defaults are acceptable, users */
  94. /* can pass NPARAMS = 0 which prevents the source code from accessing */
  95. /* the PARAMS argument. */
  96. /* TRANS (input) CHARACTER*1 */
  97. /* Specifies the form of the system of equations: */
  98. /* = 'N': A * X = B (No transpose) */
  99. /* = 'T': A**T * X = B (Transpose) */
  100. /* = 'C': A**H * X = B (Conjugate transpose = Transpose) */
  101. /* EQUED (input) CHARACTER*1 */
  102. /* Specifies the form of equilibration that was done to A */
  103. /* before calling this routine. This is needed to compute */
  104. /* the solution and error bounds correctly. */
  105. /* = 'N': No equilibration */
  106. /* = 'R': Row equilibration, i.e., A has been premultiplied by */
  107. /* diag(R). */
  108. /* = 'C': Column equilibration, i.e., A has been postmultiplied */
  109. /* by diag(C). */
  110. /* = 'B': Both row and column equilibration, i.e., A has been */
  111. /* replaced by diag(R) * A * diag(C). */
  112. /* The right hand side B has been changed accordingly. */
  113. /* N (input) INTEGER */
  114. /* The order of the matrix A. N >= 0. */
  115. /* KL (input) INTEGER */
  116. /* The number of subdiagonals within the band of A. KL >= 0. */
  117. /* KU (input) INTEGER */
  118. /* The number of superdiagonals within the band of A. KU >= 0. */
  119. /* NRHS (input) INTEGER */
  120. /* The number of right hand sides, i.e., the number of columns */
  121. /* of the matrices B and X. NRHS >= 0. */
  122. /* AB (input) DOUBLE PRECISION array, dimension (LDAB,N) */
  123. /* The original band matrix A, stored in rows 1 to KL+KU+1. */
  124. /* The j-th column of A is stored in the j-th column of the */
  125. /* array AB as follows: */
  126. /* AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(n,j+kl). */
  127. /* LDAB (input) INTEGER */
  128. /* The leading dimension of the array AB. LDAB >= KL+KU+1. */
  129. /* AFB (input) DOUBLE PRECISION array, dimension (LDAFB,N) */
  130. /* Details of the LU factorization of the band matrix A, as */
  131. /* computed by DGBTRF. U is stored as an upper triangular band */
  132. /* matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and */
  133. /* the multipliers used during the factorization are stored in */
  134. /* rows KL+KU+2 to 2*KL+KU+1. */
  135. /* LDAFB (input) INTEGER */
  136. /* The leading dimension of the array AFB. LDAFB >= 2*KL*KU+1. */
  137. /* IPIV (input) INTEGER array, dimension (N) */
  138. /* The pivot indices from DGETRF; for 1<=i<=N, row i of the */
  139. /* matrix was interchanged with row IPIV(i). */
  140. /* R (input or output) DOUBLE PRECISION array, dimension (N) */
  141. /* The row scale factors for A. If EQUED = 'R' or 'B', A is */
  142. /* multiplied on the left by diag(R); if EQUED = 'N' or 'C', R */
  143. /* is not accessed. R is an input argument if FACT = 'F'; */
  144. /* otherwise, R is an output argument. If FACT = 'F' and */
  145. /* EQUED = 'R' or 'B', each element of R must be positive. */
  146. /* If R is output, each element of R is a power of the radix. */
  147. /* If R is input, each element of R should be a power of the radix */
  148. /* to ensure a reliable solution and error estimates. Scaling by */
  149. /* powers of the radix does not cause rounding errors unless the */
  150. /* result underflows or overflows. Rounding errors during scaling */
  151. /* lead to refining with a matrix that is not equivalent to the */
  152. /* input matrix, producing error estimates that may not be */
  153. /* reliable. */
  154. /* C (input or output) DOUBLE PRECISION array, dimension (N) */
  155. /* The column scale factors for A. If EQUED = 'C' or 'B', A is */
  156. /* multiplied on the right by diag(C); if EQUED = 'N' or 'R', C */
  157. /* is not accessed. C is an input argument if FACT = 'F'; */
  158. /* otherwise, C is an output argument. If FACT = 'F' and */
  159. /* EQUED = 'C' or 'B', each element of C must be positive. */
  160. /* If C is output, each element of C is a power of the radix. */
  161. /* If C is input, each element of C should be a power of the radix */
  162. /* to ensure a reliable solution and error estimates. Scaling by */
  163. /* powers of the radix does not cause rounding errors unless the */
  164. /* result underflows or overflows. Rounding errors during scaling */
  165. /* lead to refining with a matrix that is not equivalent to the */
  166. /* input matrix, producing error estimates that may not be */
  167. /* reliable. */
  168. /* B (input) DOUBLE PRECISION array, dimension (LDB,NRHS) */
  169. /* The right hand side matrix B. */
  170. /* LDB (input) INTEGER */
  171. /* The leading dimension of the array B. LDB >= max(1,N). */
  172. /* X (input/output) DOUBLE PRECISION array, dimension (LDX,NRHS) */
  173. /* On entry, the solution matrix X, as computed by DGETRS. */
  174. /* On exit, the improved solution matrix X. */
  175. /* LDX (input) INTEGER */
  176. /* The leading dimension of the array X. LDX >= max(1,N). */
  177. /* RCOND (output) DOUBLE PRECISION */
  178. /* Reciprocal scaled condition number. This is an estimate of the */
  179. /* reciprocal Skeel condition number of the matrix A after */
  180. /* equilibration (if done). If this is less than the machine */
  181. /* precision (in particular, if it is zero), the matrix is singular */
  182. /* to working precision. Note that the error may still be small even */
  183. /* if this number is very small and the matrix appears ill- */
  184. /* conditioned. */
  185. /* BERR (output) DOUBLE PRECISION array, dimension (NRHS) */
  186. /* Componentwise relative backward error. This is the */
  187. /* componentwise relative backward error of each solution vector X(j) */
  188. /* (i.e., the smallest relative change in any element of A or B that */
  189. /* makes X(j) an exact solution). */
  190. /* N_ERR_BNDS (input) INTEGER */
  191. /* Number of error bounds to return for each right hand side */
  192. /* and each type (normwise or componentwise). See ERR_BNDS_NORM and */
  193. /* ERR_BNDS_COMP below. */
  194. /* ERR_BNDS_NORM (output) DOUBLE PRECISION array, dimension (NRHS, N_ERR_BNDS) */
  195. /* For each right-hand side, this array contains information about */
  196. /* various error bounds and condition numbers corresponding to the */
  197. /* normwise relative error, which is defined as follows: */
  198. /* Normwise relative error in the ith solution vector: */
  199. /* max_j (abs(XTRUE(j,i) - X(j,i))) */
  200. /* ------------------------------ */
  201. /* max_j abs(X(j,i)) */
  202. /* The array is indexed by the type of error information as described */
  203. /* below. There currently are up to three pieces of information */
  204. /* returned. */
  205. /* The first index in ERR_BNDS_NORM(i,:) corresponds to the ith */
  206. /* right-hand side. */
  207. /* The second index in ERR_BNDS_NORM(:,err) contains the following */
  208. /* three fields: */
  209. /* err = 1 "Trust/don't trust" boolean. Trust the answer if the */
  210. /* reciprocal condition number is less than the threshold */
  211. /* sqrt(n) * dlamch('Epsilon'). */
  212. /* err = 2 "Guaranteed" error bound: The estimated forward error, */
  213. /* almost certainly within a factor of 10 of the true error */
  214. /* so long as the next entry is greater than the threshold */
  215. /* sqrt(n) * dlamch('Epsilon'). This error bound should only */
  216. /* be trusted if the previous boolean is true. */
  217. /* err = 3 Reciprocal condition number: Estimated normwise */
  218. /* reciprocal condition number. Compared with the threshold */
  219. /* sqrt(n) * dlamch('Epsilon') to determine if the error */
  220. /* estimate is "guaranteed". These reciprocal condition */
  221. /* numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
  222. /* appropriately scaled matrix Z. */
  223. /* Let Z = S*A, where S scales each row by a power of the */
  224. /* radix so all absolute row sums of Z are approximately 1. */
  225. /* See Lapack Working Note 165 for further details and extra */
  226. /* cautions. */
  227. /* ERR_BNDS_COMP (output) DOUBLE PRECISION array, dimension (NRHS, N_ERR_BNDS) */
  228. /* For each right-hand side, this array contains information about */
  229. /* various error bounds and condition numbers corresponding to the */
  230. /* componentwise relative error, which is defined as follows: */
  231. /* Componentwise relative error in the ith solution vector: */
  232. /* abs(XTRUE(j,i) - X(j,i)) */
  233. /* max_j ---------------------- */
  234. /* abs(X(j,i)) */
  235. /* The array is indexed by the right-hand side i (on which the */
  236. /* componentwise relative error depends), and the type of error */
  237. /* information as described below. There currently are up to three */
  238. /* pieces of information returned for each right-hand side. If */
  239. /* componentwise accuracy is not requested (PARAMS(3) = 0.0), then */
  240. /* ERR_BNDS_COMP is not accessed. If N_ERR_BNDS .LT. 3, then at most */
  241. /* the first (:,N_ERR_BNDS) entries are returned. */
  242. /* The first index in ERR_BNDS_COMP(i,:) corresponds to the ith */
  243. /* right-hand side. */
  244. /* The second index in ERR_BNDS_COMP(:,err) contains the following */
  245. /* three fields: */
  246. /* err = 1 "Trust/don't trust" boolean. Trust the answer if the */
  247. /* reciprocal condition number is less than the threshold */
  248. /* sqrt(n) * dlamch('Epsilon'). */
  249. /* err = 2 "Guaranteed" error bound: The estimated forward error, */
  250. /* almost certainly within a factor of 10 of the true error */
  251. /* so long as the next entry is greater than the threshold */
  252. /* sqrt(n) * dlamch('Epsilon'). This error bound should only */
  253. /* be trusted if the previous boolean is true. */
  254. /* err = 3 Reciprocal condition number: Estimated componentwise */
  255. /* reciprocal condition number. Compared with the threshold */
  256. /* sqrt(n) * dlamch('Epsilon') to determine if the error */
  257. /* estimate is "guaranteed". These reciprocal condition */
  258. /* numbers are 1 / (norm(Z^{-1},inf) * norm(Z,inf)) for some */
  259. /* appropriately scaled matrix Z. */
  260. /* Let Z = S*(A*diag(x)), where x is the solution for the */
  261. /* current right-hand side and S scales each row of */
  262. /* A*diag(x) by a power of the radix so all absolute row */
  263. /* sums of Z are approximately 1. */
  264. /* See Lapack Working Note 165 for further details and extra */
  265. /* cautions. */
  266. /* NPARAMS (input) INTEGER */
  267. /* Specifies the number of parameters set in PARAMS. If .LE. 0, the */
  268. /* PARAMS array is never referenced and default values are used. */
  269. /* PARAMS (input / output) DOUBLE PRECISION array, dimension NPARAMS */
  270. /* Specifies algorithm parameters. If an entry is .LT. 0.0, then */
  271. /* that entry will be filled with default value used for that */
  272. /* parameter. Only positions up to NPARAMS are accessed; defaults */
  273. /* are used for higher-numbered parameters. */
  274. /* PARAMS(LA_LINRX_ITREF_I = 1) : Whether to perform iterative */
  275. /* refinement or not. */
  276. /* Default: 1.0D+0 */
  277. /* = 0.0 : No refinement is performed, and no error bounds are */
  278. /* computed. */
  279. /* = 1.0 : Use the double-precision refinement algorithm, */
  280. /* possibly with doubled-single computations if the */
  281. /* compilation environment does not support DOUBLE */
  282. /* PRECISION. */
  283. /* (other values are reserved for future use) */
  284. /* PARAMS(LA_LINRX_ITHRESH_I = 2) : Maximum number of residual */
  285. /* computations allowed for refinement. */
  286. /* Default: 10 */
  287. /* Aggressive: Set to 100 to permit convergence using approximate */
  288. /* factorizations or factorizations other than LU. If */
  289. /* the factorization uses a technique other than */
  290. /* Gaussian elimination, the guarantees in */
  291. /* err_bnds_norm and err_bnds_comp may no longer be */
  292. /* trustworthy. */
  293. /* PARAMS(LA_LINRX_CWISE_I = 3) : Flag determining if the code */
  294. /* will attempt to find a solution with small componentwise */
  295. /* relative error in the double-precision algorithm. Positive */
  296. /* is true, 0.0 is false. */
  297. /* Default: 1.0 (attempt componentwise convergence) */
  298. /* WORK (workspace) DOUBLE PRECISION array, dimension (4*N) */
  299. /* IWORK (workspace) INTEGER array, dimension (N) */
  300. /* INFO (output) INTEGER */
  301. /* = 0: Successful exit. The solution to every right-hand side is */
  302. /* guaranteed. */
  303. /* < 0: If INFO = -i, the i-th argument had an illegal value */
  304. /* > 0 and <= N: U(INFO,INFO) is exactly zero. The factorization */
  305. /* has been completed, but the factor U is exactly singular, so */
  306. /* the solution and error bounds could not be computed. RCOND = 0 */
  307. /* is returned. */
  308. /* = N+J: The solution corresponding to the Jth right-hand side is */
  309. /* not guaranteed. The solutions corresponding to other right- */
  310. /* hand sides K with K > J may not be guaranteed as well, but */
  311. /* only the first such right-hand side is reported. If a small */
  312. /* componentwise error is not requested (PARAMS(3) = 0.0) then */
  313. /* the Jth right-hand side is the first with a normwise error */
  314. /* bound that is not guaranteed (the smallest J such */
  315. /* that ERR_BNDS_NORM(J,1) = 0.0). By default (PARAMS(3) = 1.0) */
  316. /* the Jth right-hand side is the first with either a normwise or */
  317. /* componentwise error bound that is not guaranteed (the smallest */
  318. /* J such that either ERR_BNDS_NORM(J,1) = 0.0 or */
  319. /* ERR_BNDS_COMP(J,1) = 0.0). See the definition of */
  320. /* ERR_BNDS_NORM(:,1) and ERR_BNDS_COMP(:,1). To get information */
  321. /* about all of the right-hand sides check ERR_BNDS_NORM or */
  322. /* ERR_BNDS_COMP. */
  323. /* ================================================================== */
  324. /* .. Parameters .. */
  325. /* .. */
  326. /* .. Local Scalars .. */
  327. /* .. */
  328. /* .. External Subroutines .. */
  329. /* .. */
  330. /* .. Intrinsic Functions .. */
  331. /* .. */
  332. /* .. External Functions .. */
  333. /* .. */
  334. /* .. Executable Statements .. */
  335. /* Check the input parameters. */
  336. /* Parameter adjustments */
  337. err_bnds_comp_dim1 = *nrhs;
  338. err_bnds_comp_offset = 1 + err_bnds_comp_dim1;
  339. err_bnds_comp__ -= err_bnds_comp_offset;
  340. err_bnds_norm_dim1 = *nrhs;
  341. err_bnds_norm_offset = 1 + err_bnds_norm_dim1;
  342. err_bnds_norm__ -= err_bnds_norm_offset;
  343. ab_dim1 = *ldab;
  344. ab_offset = 1 + ab_dim1;
  345. ab -= ab_offset;
  346. afb_dim1 = *ldafb;
  347. afb_offset = 1 + afb_dim1;
  348. afb -= afb_offset;
  349. --ipiv;
  350. --r__;
  351. --c__;
  352. b_dim1 = *ldb;
  353. b_offset = 1 + b_dim1;
  354. b -= b_offset;
  355. x_dim1 = *ldx;
  356. x_offset = 1 + x_dim1;
  357. x -= x_offset;
  358. --berr;
  359. --params;
  360. --work;
  361. --iwork;
  362. /* Function Body */
  363. *info = 0;
  364. trans_type__ = _starpu_ilatrans_(trans);
  365. ref_type__ = 1;
  366. if (*nparams >= 1) {
  367. if (params[1] < 0.) {
  368. params[1] = 1.;
  369. } else {
  370. ref_type__ = (integer) params[1];
  371. }
  372. }
  373. /* Set default parameters. */
  374. illrcond_thresh__ = (doublereal) (*n) * _starpu_dlamch_("Epsilon");
  375. ithresh = 10;
  376. rthresh = .5;
  377. unstable_thresh__ = .25;
  378. ignore_cwise__ = FALSE_;
  379. if (*nparams >= 2) {
  380. if (params[2] < 0.) {
  381. params[2] = (doublereal) ithresh;
  382. } else {
  383. ithresh = (integer) params[2];
  384. }
  385. }
  386. if (*nparams >= 3) {
  387. if (params[3] < 0.) {
  388. if (ignore_cwise__) {
  389. params[3] = 0.;
  390. } else {
  391. params[3] = 1.;
  392. }
  393. } else {
  394. ignore_cwise__ = params[3] == 0.;
  395. }
  396. }
  397. if (ref_type__ == 0 || *n_err_bnds__ == 0) {
  398. n_norms__ = 0;
  399. } else if (ignore_cwise__) {
  400. n_norms__ = 1;
  401. } else {
  402. n_norms__ = 2;
  403. }
  404. notran = _starpu_lsame_(trans, "N");
  405. rowequ = _starpu_lsame_(equed, "R") || _starpu_lsame_(equed, "B");
  406. colequ = _starpu_lsame_(equed, "C") || _starpu_lsame_(equed, "B");
  407. /* Test input parameters. */
  408. if (trans_type__ == -1) {
  409. *info = -1;
  410. } else if (! rowequ && ! colequ && ! _starpu_lsame_(equed, "N")) {
  411. *info = -2;
  412. } else if (*n < 0) {
  413. *info = -3;
  414. } else if (*kl < 0) {
  415. *info = -4;
  416. } else if (*ku < 0) {
  417. *info = -5;
  418. } else if (*nrhs < 0) {
  419. *info = -6;
  420. } else if (*ldab < *kl + *ku + 1) {
  421. *info = -8;
  422. } else if (*ldafb < (*kl << 1) + *ku + 1) {
  423. *info = -10;
  424. } else if (*ldb < max(1,*n)) {
  425. *info = -13;
  426. } else if (*ldx < max(1,*n)) {
  427. *info = -15;
  428. }
  429. if (*info != 0) {
  430. i__1 = -(*info);
  431. _starpu_xerbla_("DGBRFSX", &i__1);
  432. return 0;
  433. }
  434. /* Quick return if possible. */
  435. if (*n == 0 || *nrhs == 0) {
  436. *rcond = 1.;
  437. i__1 = *nrhs;
  438. for (j = 1; j <= i__1; ++j) {
  439. berr[j] = 0.;
  440. if (*n_err_bnds__ >= 1) {
  441. err_bnds_norm__[j + err_bnds_norm_dim1] = 1.;
  442. err_bnds_comp__[j + err_bnds_comp_dim1] = 1.;
  443. } else if (*n_err_bnds__ >= 2) {
  444. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 0.;
  445. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 0.;
  446. } else if (*n_err_bnds__ >= 3) {
  447. err_bnds_norm__[j + err_bnds_norm_dim1 * 3] = 1.;
  448. err_bnds_comp__[j + err_bnds_comp_dim1 * 3] = 1.;
  449. }
  450. }
  451. return 0;
  452. }
  453. /* Default to failure. */
  454. *rcond = 0.;
  455. i__1 = *nrhs;
  456. for (j = 1; j <= i__1; ++j) {
  457. berr[j] = 1.;
  458. if (*n_err_bnds__ >= 1) {
  459. err_bnds_norm__[j + err_bnds_norm_dim1] = 1.;
  460. err_bnds_comp__[j + err_bnds_comp_dim1] = 1.;
  461. } else if (*n_err_bnds__ >= 2) {
  462. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 1.;
  463. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 1.;
  464. } else if (*n_err_bnds__ >= 3) {
  465. err_bnds_norm__[j + err_bnds_norm_dim1 * 3] = 0.;
  466. err_bnds_comp__[j + err_bnds_comp_dim1 * 3] = 0.;
  467. }
  468. }
  469. /* Compute the norm of A and the reciprocal of the condition */
  470. /* number of A. */
  471. if (notran) {
  472. *(unsigned char *)norm = 'I';
  473. } else {
  474. *(unsigned char *)norm = '1';
  475. }
  476. anorm = _starpu_dlangb_(norm, n, kl, ku, &ab[ab_offset], ldab, &work[1]);
  477. _starpu_dgbcon_(norm, n, kl, ku, &afb[afb_offset], ldafb, &ipiv[1], &anorm, rcond,
  478. &work[1], &iwork[1], info);
  479. /* Perform refinement on each right-hand side */
  480. if (ref_type__ != 0) {
  481. prec_type__ = _starpu_ilaprec_("E");
  482. if (notran) {
  483. _starpu_dla_gbrfsx_extended__(&prec_type__, &trans_type__, n, kl, ku,
  484. nrhs, &ab[ab_offset], ldab, &afb[afb_offset], ldafb, &
  485. ipiv[1], &colequ, &c__[1], &b[b_offset], ldb, &x[x_offset]
  486. , ldx, &berr[1], &n_norms__, &err_bnds_norm__[
  487. err_bnds_norm_offset], &err_bnds_comp__[
  488. err_bnds_comp_offset], &work[*n + 1], &work[1], &work[(*n
  489. << 1) + 1], &work[1], rcond, &ithresh, &rthresh, &
  490. unstable_thresh__, &ignore_cwise__, info);
  491. } else {
  492. _starpu_dla_gbrfsx_extended__(&prec_type__, &trans_type__, n, kl, ku,
  493. nrhs, &ab[ab_offset], ldab, &afb[afb_offset], ldafb, &
  494. ipiv[1], &rowequ, &r__[1], &b[b_offset], ldb, &x[x_offset]
  495. , ldx, &berr[1], &n_norms__, &err_bnds_norm__[
  496. err_bnds_norm_offset], &err_bnds_comp__[
  497. err_bnds_comp_offset], &work[*n + 1], &work[1], &work[(*n
  498. << 1) + 1], &work[1], rcond, &ithresh, &rthresh, &
  499. unstable_thresh__, &ignore_cwise__, info);
  500. }
  501. }
  502. /* Computing MAX */
  503. d__1 = 10., d__2 = sqrt((doublereal) (*n));
  504. err_lbnd__ = max(d__1,d__2) * _starpu_dlamch_("Epsilon");
  505. if (*n_err_bnds__ >= 1 && n_norms__ >= 1) {
  506. /* Compute scaled normwise condition number cond(A*C). */
  507. if (colequ && notran) {
  508. rcond_tmp__ = _starpu_dla_gbrcond__(trans, n, kl, ku, &ab[ab_offset],
  509. ldab, &afb[afb_offset], ldafb, &ipiv[1], &c_n1, &c__[1],
  510. info, &work[1], &iwork[1], (ftnlen)1);
  511. } else if (rowequ && ! notran) {
  512. rcond_tmp__ = _starpu_dla_gbrcond__(trans, n, kl, ku, &ab[ab_offset],
  513. ldab, &afb[afb_offset], ldafb, &ipiv[1], &c_n1, &r__[1],
  514. info, &work[1], &iwork[1], (ftnlen)1);
  515. } else {
  516. rcond_tmp__ = _starpu_dla_gbrcond__(trans, n, kl, ku, &ab[ab_offset],
  517. ldab, &afb[afb_offset], ldafb, &ipiv[1], &c__0, &r__[1],
  518. info, &work[1], &iwork[1], (ftnlen)1);
  519. }
  520. i__1 = *nrhs;
  521. for (j = 1; j <= i__1; ++j) {
  522. /* Cap the error at 1.0. */
  523. if (*n_err_bnds__ >= 2 && err_bnds_norm__[j + (err_bnds_norm_dim1
  524. << 1)] > 1.) {
  525. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 1.;
  526. }
  527. /* Threshold the error (see LAWN). */
  528. if (rcond_tmp__ < illrcond_thresh__) {
  529. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = 1.;
  530. err_bnds_norm__[j + err_bnds_norm_dim1] = 0.;
  531. if (*info <= *n) {
  532. *info = *n + j;
  533. }
  534. } else if (err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] <
  535. err_lbnd__) {
  536. err_bnds_norm__[j + (err_bnds_norm_dim1 << 1)] = err_lbnd__;
  537. err_bnds_norm__[j + err_bnds_norm_dim1] = 1.;
  538. }
  539. /* Save the condition number. */
  540. if (*n_err_bnds__ >= 3) {
  541. err_bnds_norm__[j + err_bnds_norm_dim1 * 3] = rcond_tmp__;
  542. }
  543. }
  544. }
  545. if (*n_err_bnds__ >= 1 && n_norms__ >= 2) {
  546. /* Compute componentwise condition number cond(A*diag(Y(:,J))) for */
  547. /* each right-hand side using the current solution as an estimate of */
  548. /* the true solution. If the componentwise error estimate is too */
  549. /* large, then the solution is a lousy estimate of truth and the */
  550. /* estimated RCOND may be too optimistic. To avoid misleading users, */
  551. /* the inverse condition number is set to 0.0 when the estimated */
  552. /* cwise error is at least CWISE_WRONG. */
  553. cwise_wrong__ = sqrt(_starpu_dlamch_("Epsilon"));
  554. i__1 = *nrhs;
  555. for (j = 1; j <= i__1; ++j) {
  556. if (err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] <
  557. cwise_wrong__) {
  558. rcond_tmp__ = _starpu_dla_gbrcond__(trans, n, kl, ku, &ab[ab_offset],
  559. ldab, &afb[afb_offset], ldafb, &ipiv[1], &c__1, &x[j *
  560. x_dim1 + 1], info, &work[1], &iwork[1], (ftnlen)1);
  561. } else {
  562. rcond_tmp__ = 0.;
  563. }
  564. /* Cap the error at 1.0. */
  565. if (*n_err_bnds__ >= 2 && err_bnds_comp__[j + (err_bnds_comp_dim1
  566. << 1)] > 1.) {
  567. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 1.;
  568. }
  569. /* Threshold the error (see LAWN). */
  570. if (rcond_tmp__ < illrcond_thresh__) {
  571. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = 1.;
  572. err_bnds_comp__[j + err_bnds_comp_dim1] = 0.;
  573. if (params[3] == 1. && *info < *n + j) {
  574. *info = *n + j;
  575. }
  576. } else if (err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] <
  577. err_lbnd__) {
  578. err_bnds_comp__[j + (err_bnds_comp_dim1 << 1)] = err_lbnd__;
  579. err_bnds_comp__[j + err_bnds_comp_dim1] = 1.;
  580. }
  581. /* Save the condition number. */
  582. if (*n_err_bnds__ >= 3) {
  583. err_bnds_comp__[j + err_bnds_comp_dim1 * 3] = rcond_tmp__;
  584. }
  585. }
  586. }
  587. return 0;
  588. /* End of DGBRFSX */
  589. } /* _starpu_dgbrfsx_ */