dgbsvx.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. /* dgbsvx.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__1 = 1;
  15. /* Subroutine */ int _starpu_dgbsvx_(char *fact, char *trans, integer *n, integer *kl,
  16. integer *ku, integer *nrhs, doublereal *ab, integer *ldab,
  17. doublereal *afb, integer *ldafb, integer *ipiv, char *equed,
  18. doublereal *r__, doublereal *c__, doublereal *b, integer *ldb,
  19. doublereal *x, integer *ldx, doublereal *rcond, doublereal *ferr,
  20. doublereal *berr, 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, i__1, i__2, i__3, i__4, i__5;
  25. doublereal d__1, d__2, d__3;
  26. /* Local variables */
  27. integer i__, j, j1, j2;
  28. doublereal amax;
  29. char norm[1];
  30. extern logical _starpu_lsame_(char *, char *);
  31. doublereal rcmin, rcmax, anorm;
  32. extern /* Subroutine */ int _starpu_dcopy_(integer *, doublereal *, integer *,
  33. doublereal *, integer *);
  34. logical equil;
  35. extern doublereal _starpu_dlangb_(char *, integer *, integer *, integer *,
  36. doublereal *, integer *, doublereal *), _starpu_dlamch_(char *);
  37. extern /* Subroutine */ int _starpu_dlaqgb_(integer *, integer *, integer *,
  38. integer *, doublereal *, integer *, doublereal *, doublereal *,
  39. doublereal *, doublereal *, doublereal *, char *),
  40. _starpu_dgbcon_(char *, integer *, integer *, integer *, doublereal *,
  41. integer *, integer *, doublereal *, doublereal *, doublereal *,
  42. integer *, integer *);
  43. doublereal colcnd;
  44. extern doublereal _starpu_dlantb_(char *, char *, char *, integer *, integer *,
  45. doublereal *, integer *, doublereal *);
  46. extern /* Subroutine */ int _starpu_dgbequ_(integer *, integer *, integer *,
  47. integer *, doublereal *, integer *, doublereal *, doublereal *,
  48. doublereal *, doublereal *, doublereal *, integer *), _starpu_dgbrfs_(
  49. char *, integer *, integer *, integer *, integer *, doublereal *,
  50. integer *, doublereal *, integer *, integer *, doublereal *,
  51. integer *, doublereal *, integer *, doublereal *, doublereal *,
  52. doublereal *, integer *, integer *), _starpu_dgbtrf_(integer *,
  53. integer *, integer *, integer *, doublereal *, integer *, integer
  54. *, integer *);
  55. logical nofact;
  56. extern /* Subroutine */ int _starpu_dlacpy_(char *, integer *, integer *,
  57. doublereal *, integer *, doublereal *, integer *),
  58. _starpu_xerbla_(char *, integer *);
  59. doublereal bignum;
  60. extern /* Subroutine */ int _starpu_dgbtrs_(char *, integer *, integer *, integer
  61. *, integer *, doublereal *, integer *, integer *, doublereal *,
  62. integer *, integer *);
  63. integer infequ;
  64. logical colequ;
  65. doublereal rowcnd;
  66. logical notran;
  67. doublereal smlnum;
  68. logical rowequ;
  69. doublereal rpvgrw;
  70. /* -- LAPACK driver routine (version 3.2) -- */
  71. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  72. /* November 2006 */
  73. /* .. Scalar Arguments .. */
  74. /* .. */
  75. /* .. Array Arguments .. */
  76. /* .. */
  77. /* Purpose */
  78. /* ======= */
  79. /* DGBSVX uses the LU factorization to compute the solution to a real */
  80. /* system of linear equations A * X = B, A**T * X = B, or A**H * X = B, */
  81. /* where A is a band matrix of order N with KL subdiagonals and KU */
  82. /* superdiagonals, and X and B are N-by-NRHS matrices. */
  83. /* Error bounds on the solution and a condition estimate are also */
  84. /* provided. */
  85. /* Description */
  86. /* =========== */
  87. /* The following steps are performed by this subroutine: */
  88. /* 1. If FACT = 'E', real scaling factors are computed to equilibrate */
  89. /* the system: */
  90. /* TRANS = 'N': diag(R)*A*diag(C) *inv(diag(C))*X = diag(R)*B */
  91. /* TRANS = 'T': (diag(R)*A*diag(C))**T *inv(diag(R))*X = diag(C)*B */
  92. /* TRANS = 'C': (diag(R)*A*diag(C))**H *inv(diag(R))*X = diag(C)*B */
  93. /* Whether or not the system will be equilibrated depends on the */
  94. /* scaling of the matrix A, but if equilibration is used, A is */
  95. /* overwritten by diag(R)*A*diag(C) and B by diag(R)*B (if TRANS='N') */
  96. /* or diag(C)*B (if TRANS = 'T' or 'C'). */
  97. /* 2. If FACT = 'N' or 'E', the LU decomposition is used to factor the */
  98. /* matrix A (after equilibration if FACT = 'E') as */
  99. /* A = L * U, */
  100. /* where L is a product of permutation and unit lower triangular */
  101. /* matrices with KL subdiagonals, and U is upper triangular with */
  102. /* KL+KU superdiagonals. */
  103. /* 3. If some U(i,i)=0, so that U is exactly singular, then the routine */
  104. /* returns with INFO = i. Otherwise, the factored form of A is used */
  105. /* to estimate the condition number of the matrix A. If the */
  106. /* reciprocal of the condition number is less than machine precision, */
  107. /* INFO = N+1 is returned as a warning, but the routine still goes on */
  108. /* to solve for X and compute error bounds as described below. */
  109. /* 4. The system of equations is solved for X using the factored form */
  110. /* of A. */
  111. /* 5. Iterative refinement is applied to improve the computed solution */
  112. /* matrix and calculate error bounds and backward error estimates */
  113. /* for it. */
  114. /* 6. If equilibration was used, the matrix X is premultiplied by */
  115. /* diag(C) (if TRANS = 'N') or diag(R) (if TRANS = 'T' or 'C') so */
  116. /* that it solves the original system before equilibration. */
  117. /* Arguments */
  118. /* ========= */
  119. /* FACT (input) CHARACTER*1 */
  120. /* Specifies whether or not the factored form of the matrix A is */
  121. /* supplied on entry, and if not, whether the matrix A should be */
  122. /* equilibrated before it is factored. */
  123. /* = 'F': On entry, AFB and IPIV contain the factored form of */
  124. /* A. If EQUED is not 'N', the matrix A has been */
  125. /* equilibrated with scaling factors given by R and C. */
  126. /* AB, AFB, and IPIV are not modified. */
  127. /* = 'N': The matrix A will be copied to AFB and factored. */
  128. /* = 'E': The matrix A will be equilibrated if necessary, then */
  129. /* copied to AFB and factored. */
  130. /* TRANS (input) CHARACTER*1 */
  131. /* Specifies the form of the system of equations. */
  132. /* = 'N': A * X = B (No transpose) */
  133. /* = 'T': A**T * X = B (Transpose) */
  134. /* = 'C': A**H * X = B (Transpose) */
  135. /* N (input) INTEGER */
  136. /* The number of linear equations, i.e., the order of the */
  137. /* matrix A. N >= 0. */
  138. /* KL (input) INTEGER */
  139. /* The number of subdiagonals within the band of A. KL >= 0. */
  140. /* KU (input) INTEGER */
  141. /* The number of superdiagonals within the band of A. KU >= 0. */
  142. /* NRHS (input) INTEGER */
  143. /* The number of right hand sides, i.e., the number of columns */
  144. /* of the matrices B and X. NRHS >= 0. */
  145. /* AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N) */
  146. /* On entry, the matrix A in band storage, in rows 1 to KL+KU+1. */
  147. /* The j-th column of A is stored in the j-th column of the */
  148. /* array AB as follows: */
  149. /* AB(KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+kl) */
  150. /* If FACT = 'F' and EQUED is not 'N', then A must have been */
  151. /* equilibrated by the scaling factors in R and/or C. AB is not */
  152. /* modified if FACT = 'F' or 'N', or if FACT = 'E' and */
  153. /* EQUED = 'N' on exit. */
  154. /* On exit, if EQUED .ne. 'N', A is scaled as follows: */
  155. /* EQUED = 'R': A := diag(R) * A */
  156. /* EQUED = 'C': A := A * diag(C) */
  157. /* EQUED = 'B': A := diag(R) * A * diag(C). */
  158. /* LDAB (input) INTEGER */
  159. /* The leading dimension of the array AB. LDAB >= KL+KU+1. */
  160. /* AFB (input or output) DOUBLE PRECISION array, dimension (LDAFB,N) */
  161. /* If FACT = 'F', then AFB is an input argument and on entry */
  162. /* contains details of the LU factorization of the band matrix */
  163. /* A, as computed by DGBTRF. U is stored as an upper triangular */
  164. /* band matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, */
  165. /* and the multipliers used during the factorization are stored */
  166. /* in rows KL+KU+2 to 2*KL+KU+1. If EQUED .ne. 'N', then AFB is */
  167. /* the factored form of the equilibrated matrix A. */
  168. /* If FACT = 'N', then AFB is an output argument and on exit */
  169. /* returns details of the LU factorization of A. */
  170. /* If FACT = 'E', then AFB is an output argument and on exit */
  171. /* returns details of the LU factorization of the equilibrated */
  172. /* matrix A (see the description of AB for the form of the */
  173. /* equilibrated matrix). */
  174. /* LDAFB (input) INTEGER */
  175. /* The leading dimension of the array AFB. LDAFB >= 2*KL+KU+1. */
  176. /* IPIV (input or output) INTEGER array, dimension (N) */
  177. /* If FACT = 'F', then IPIV is an input argument and on entry */
  178. /* contains the pivot indices from the factorization A = L*U */
  179. /* as computed by DGBTRF; row i of the matrix was interchanged */
  180. /* with row IPIV(i). */
  181. /* If FACT = 'N', then IPIV is an output argument and on exit */
  182. /* contains the pivot indices from the factorization A = L*U */
  183. /* of the original matrix A. */
  184. /* If FACT = 'E', then IPIV is an output argument and on exit */
  185. /* contains the pivot indices from the factorization A = L*U */
  186. /* of the equilibrated matrix A. */
  187. /* EQUED (input or output) CHARACTER*1 */
  188. /* Specifies the form of equilibration that was done. */
  189. /* = 'N': No equilibration (always true if FACT = 'N'). */
  190. /* = 'R': Row equilibration, i.e., A has been premultiplied by */
  191. /* diag(R). */
  192. /* = 'C': Column equilibration, i.e., A has been postmultiplied */
  193. /* by diag(C). */
  194. /* = 'B': Both row and column equilibration, i.e., A has been */
  195. /* replaced by diag(R) * A * diag(C). */
  196. /* EQUED is an input argument if FACT = 'F'; otherwise, it is an */
  197. /* output argument. */
  198. /* R (input or output) DOUBLE PRECISION array, dimension (N) */
  199. /* The row scale factors for A. If EQUED = 'R' or 'B', A is */
  200. /* multiplied on the left by diag(R); if EQUED = 'N' or 'C', R */
  201. /* is not accessed. R is an input argument if FACT = 'F'; */
  202. /* otherwise, R is an output argument. If FACT = 'F' and */
  203. /* EQUED = 'R' or 'B', each element of R must be positive. */
  204. /* C (input or output) DOUBLE PRECISION array, dimension (N) */
  205. /* The column scale factors for A. If EQUED = 'C' or 'B', A is */
  206. /* multiplied on the right by diag(C); if EQUED = 'N' or 'R', C */
  207. /* is not accessed. C is an input argument if FACT = 'F'; */
  208. /* otherwise, C is an output argument. If FACT = 'F' and */
  209. /* EQUED = 'C' or 'B', each element of C must be positive. */
  210. /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
  211. /* On entry, the right hand side matrix B. */
  212. /* On exit, */
  213. /* if EQUED = 'N', B is not modified; */
  214. /* if TRANS = 'N' and EQUED = 'R' or 'B', B is overwritten by */
  215. /* diag(R)*B; */
  216. /* if TRANS = 'T' or 'C' and EQUED = 'C' or 'B', B is */
  217. /* overwritten by diag(C)*B. */
  218. /* LDB (input) INTEGER */
  219. /* The leading dimension of the array B. LDB >= max(1,N). */
  220. /* X (output) DOUBLE PRECISION array, dimension (LDX,NRHS) */
  221. /* If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X */
  222. /* to the original system of equations. Note that A and B are */
  223. /* modified on exit if EQUED .ne. 'N', and the solution to the */
  224. /* equilibrated system is inv(diag(C))*X if TRANS = 'N' and */
  225. /* EQUED = 'C' or 'B', or inv(diag(R))*X if TRANS = 'T' or 'C' */
  226. /* and EQUED = 'R' or 'B'. */
  227. /* LDX (input) INTEGER */
  228. /* The leading dimension of the array X. LDX >= max(1,N). */
  229. /* RCOND (output) DOUBLE PRECISION */
  230. /* The estimate of the reciprocal condition number of the matrix */
  231. /* A after equilibration (if done). If RCOND is less than the */
  232. /* machine precision (in particular, if RCOND = 0), the matrix */
  233. /* is singular to working precision. This condition is */
  234. /* indicated by a return code of INFO > 0. */
  235. /* FERR (output) DOUBLE PRECISION array, dimension (NRHS) */
  236. /* The estimated forward error bound for each solution vector */
  237. /* X(j) (the j-th column of the solution matrix X). */
  238. /* If XTRUE is the true solution corresponding to X(j), FERR(j) */
  239. /* is an estimated upper bound for the magnitude of the largest */
  240. /* element in (X(j) - XTRUE) divided by the magnitude of the */
  241. /* largest element in X(j). The estimate is as reliable as */
  242. /* the estimate for RCOND, and is almost always a slight */
  243. /* overestimate of the true error. */
  244. /* BERR (output) DOUBLE PRECISION array, dimension (NRHS) */
  245. /* The componentwise relative backward error of each solution */
  246. /* vector X(j) (i.e., the smallest relative change in */
  247. /* any element of A or B that makes X(j) an exact solution). */
  248. /* WORK (workspace/output) DOUBLE PRECISION array, dimension (3*N) */
  249. /* On exit, WORK(1) contains the reciprocal pivot growth */
  250. /* factor norm(A)/norm(U). The "max absolute element" norm is */
  251. /* used. If WORK(1) is much less than 1, then the stability */
  252. /* of the LU factorization of the (equilibrated) matrix A */
  253. /* could be poor. This also means that the solution X, condition */
  254. /* estimator RCOND, and forward error bound FERR could be */
  255. /* unreliable. If factorization fails with 0<INFO<=N, then */
  256. /* WORK(1) contains the reciprocal pivot growth factor for the */
  257. /* leading INFO columns of A. */
  258. /* IWORK (workspace) INTEGER array, dimension (N) */
  259. /* INFO (output) INTEGER */
  260. /* = 0: successful exit */
  261. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  262. /* > 0: if INFO = i, and i is */
  263. /* <= N: U(i,i) is exactly zero. The factorization */
  264. /* has been completed, but the factor U is exactly */
  265. /* singular, so the solution and error bounds */
  266. /* could not be computed. RCOND = 0 is returned. */
  267. /* = N+1: U is nonsingular, but RCOND is less than machine */
  268. /* precision, meaning that the matrix is singular */
  269. /* to working precision. Nevertheless, the */
  270. /* solution and error bounds are computed because */
  271. /* there are a number of situations where the */
  272. /* computed solution can be more accurate than the */
  273. /* value of RCOND would suggest. */
  274. /* ===================================================================== */
  275. /* .. Parameters .. */
  276. /* .. */
  277. /* .. Local Scalars .. */
  278. /* .. */
  279. /* .. External Functions .. */
  280. /* .. */
  281. /* .. External Subroutines .. */
  282. /* .. */
  283. /* .. Intrinsic Functions .. */
  284. /* .. */
  285. /* .. Executable Statements .. */
  286. /* Parameter adjustments */
  287. ab_dim1 = *ldab;
  288. ab_offset = 1 + ab_dim1;
  289. ab -= ab_offset;
  290. afb_dim1 = *ldafb;
  291. afb_offset = 1 + afb_dim1;
  292. afb -= afb_offset;
  293. --ipiv;
  294. --r__;
  295. --c__;
  296. b_dim1 = *ldb;
  297. b_offset = 1 + b_dim1;
  298. b -= b_offset;
  299. x_dim1 = *ldx;
  300. x_offset = 1 + x_dim1;
  301. x -= x_offset;
  302. --ferr;
  303. --berr;
  304. --work;
  305. --iwork;
  306. /* Function Body */
  307. *info = 0;
  308. nofact = _starpu_lsame_(fact, "N");
  309. equil = _starpu_lsame_(fact, "E");
  310. notran = _starpu_lsame_(trans, "N");
  311. if (nofact || equil) {
  312. *(unsigned char *)equed = 'N';
  313. rowequ = FALSE_;
  314. colequ = FALSE_;
  315. } else {
  316. rowequ = _starpu_lsame_(equed, "R") || _starpu_lsame_(equed,
  317. "B");
  318. colequ = _starpu_lsame_(equed, "C") || _starpu_lsame_(equed,
  319. "B");
  320. smlnum = _starpu_dlamch_("Safe minimum");
  321. bignum = 1. / smlnum;
  322. }
  323. /* Test the input parameters. */
  324. if (! nofact && ! equil && ! _starpu_lsame_(fact, "F")) {
  325. *info = -1;
  326. } else if (! notran && ! _starpu_lsame_(trans, "T") && !
  327. _starpu_lsame_(trans, "C")) {
  328. *info = -2;
  329. } else if (*n < 0) {
  330. *info = -3;
  331. } else if (*kl < 0) {
  332. *info = -4;
  333. } else if (*ku < 0) {
  334. *info = -5;
  335. } else if (*nrhs < 0) {
  336. *info = -6;
  337. } else if (*ldab < *kl + *ku + 1) {
  338. *info = -8;
  339. } else if (*ldafb < (*kl << 1) + *ku + 1) {
  340. *info = -10;
  341. } else if (_starpu_lsame_(fact, "F") && ! (rowequ || colequ
  342. || _starpu_lsame_(equed, "N"))) {
  343. *info = -12;
  344. } else {
  345. if (rowequ) {
  346. rcmin = bignum;
  347. rcmax = 0.;
  348. i__1 = *n;
  349. for (j = 1; j <= i__1; ++j) {
  350. /* Computing MIN */
  351. d__1 = rcmin, d__2 = r__[j];
  352. rcmin = min(d__1,d__2);
  353. /* Computing MAX */
  354. d__1 = rcmax, d__2 = r__[j];
  355. rcmax = max(d__1,d__2);
  356. /* L10: */
  357. }
  358. if (rcmin <= 0.) {
  359. *info = -13;
  360. } else if (*n > 0) {
  361. rowcnd = max(rcmin,smlnum) / min(rcmax,bignum);
  362. } else {
  363. rowcnd = 1.;
  364. }
  365. }
  366. if (colequ && *info == 0) {
  367. rcmin = bignum;
  368. rcmax = 0.;
  369. i__1 = *n;
  370. for (j = 1; j <= i__1; ++j) {
  371. /* Computing MIN */
  372. d__1 = rcmin, d__2 = c__[j];
  373. rcmin = min(d__1,d__2);
  374. /* Computing MAX */
  375. d__1 = rcmax, d__2 = c__[j];
  376. rcmax = max(d__1,d__2);
  377. /* L20: */
  378. }
  379. if (rcmin <= 0.) {
  380. *info = -14;
  381. } else if (*n > 0) {
  382. colcnd = max(rcmin,smlnum) / min(rcmax,bignum);
  383. } else {
  384. colcnd = 1.;
  385. }
  386. }
  387. if (*info == 0) {
  388. if (*ldb < max(1,*n)) {
  389. *info = -16;
  390. } else if (*ldx < max(1,*n)) {
  391. *info = -18;
  392. }
  393. }
  394. }
  395. if (*info != 0) {
  396. i__1 = -(*info);
  397. _starpu_xerbla_("DGBSVX", &i__1);
  398. return 0;
  399. }
  400. if (equil) {
  401. /* Compute row and column scalings to equilibrate the matrix A. */
  402. _starpu_dgbequ_(n, n, kl, ku, &ab[ab_offset], ldab, &r__[1], &c__[1], &rowcnd,
  403. &colcnd, &amax, &infequ);
  404. if (infequ == 0) {
  405. /* Equilibrate the matrix. */
  406. _starpu_dlaqgb_(n, n, kl, ku, &ab[ab_offset], ldab, &r__[1], &c__[1], &
  407. rowcnd, &colcnd, &amax, equed);
  408. rowequ = _starpu_lsame_(equed, "R") || _starpu_lsame_(equed,
  409. "B");
  410. colequ = _starpu_lsame_(equed, "C") || _starpu_lsame_(equed,
  411. "B");
  412. }
  413. }
  414. /* Scale the right hand side. */
  415. if (notran) {
  416. if (rowequ) {
  417. i__1 = *nrhs;
  418. for (j = 1; j <= i__1; ++j) {
  419. i__2 = *n;
  420. for (i__ = 1; i__ <= i__2; ++i__) {
  421. b[i__ + j * b_dim1] = r__[i__] * b[i__ + j * b_dim1];
  422. /* L30: */
  423. }
  424. /* L40: */
  425. }
  426. }
  427. } else if (colequ) {
  428. i__1 = *nrhs;
  429. for (j = 1; j <= i__1; ++j) {
  430. i__2 = *n;
  431. for (i__ = 1; i__ <= i__2; ++i__) {
  432. b[i__ + j * b_dim1] = c__[i__] * b[i__ + j * b_dim1];
  433. /* L50: */
  434. }
  435. /* L60: */
  436. }
  437. }
  438. if (nofact || equil) {
  439. /* Compute the LU factorization of the band matrix A. */
  440. i__1 = *n;
  441. for (j = 1; j <= i__1; ++j) {
  442. /* Computing MAX */
  443. i__2 = j - *ku;
  444. j1 = max(i__2,1);
  445. /* Computing MIN */
  446. i__2 = j + *kl;
  447. j2 = min(i__2,*n);
  448. i__2 = j2 - j1 + 1;
  449. _starpu_dcopy_(&i__2, &ab[*ku + 1 - j + j1 + j * ab_dim1], &c__1, &afb[*
  450. kl + *ku + 1 - j + j1 + j * afb_dim1], &c__1);
  451. /* L70: */
  452. }
  453. _starpu_dgbtrf_(n, n, kl, ku, &afb[afb_offset], ldafb, &ipiv[1], info);
  454. /* Return if INFO is non-zero. */
  455. if (*info > 0) {
  456. /* Compute the reciprocal pivot growth factor of the */
  457. /* leading rank-deficient INFO columns of A. */
  458. anorm = 0.;
  459. i__1 = *info;
  460. for (j = 1; j <= i__1; ++j) {
  461. /* Computing MAX */
  462. i__2 = *ku + 2 - j;
  463. /* Computing MIN */
  464. i__4 = *n + *ku + 1 - j, i__5 = *kl + *ku + 1;
  465. i__3 = min(i__4,i__5);
  466. for (i__ = max(i__2,1); i__ <= i__3; ++i__) {
  467. /* Computing MAX */
  468. d__2 = anorm, d__3 = (d__1 = ab[i__ + j * ab_dim1], abs(
  469. d__1));
  470. anorm = max(d__2,d__3);
  471. /* L80: */
  472. }
  473. /* L90: */
  474. }
  475. /* Computing MIN */
  476. i__3 = *info - 1, i__2 = *kl + *ku;
  477. i__1 = min(i__3,i__2);
  478. /* Computing MAX */
  479. i__4 = 1, i__5 = *kl + *ku + 2 - *info;
  480. rpvgrw = _starpu_dlantb_("M", "U", "N", info, &i__1, &afb[max(i__4, i__5)
  481. + afb_dim1], ldafb, &work[1]);
  482. if (rpvgrw == 0.) {
  483. rpvgrw = 1.;
  484. } else {
  485. rpvgrw = anorm / rpvgrw;
  486. }
  487. work[1] = rpvgrw;
  488. *rcond = 0.;
  489. return 0;
  490. }
  491. }
  492. /* Compute the norm of the matrix A and the */
  493. /* reciprocal pivot growth factor RPVGRW. */
  494. if (notran) {
  495. *(unsigned char *)norm = '1';
  496. } else {
  497. *(unsigned char *)norm = 'I';
  498. }
  499. anorm = _starpu_dlangb_(norm, n, kl, ku, &ab[ab_offset], ldab, &work[1]);
  500. i__1 = *kl + *ku;
  501. rpvgrw = _starpu_dlantb_("M", "U", "N", n, &i__1, &afb[afb_offset], ldafb, &work[
  502. 1]);
  503. if (rpvgrw == 0.) {
  504. rpvgrw = 1.;
  505. } else {
  506. rpvgrw = _starpu_dlangb_("M", n, kl, ku, &ab[ab_offset], ldab, &work[1]) / rpvgrw;
  507. }
  508. /* Compute the reciprocal of the condition number of A. */
  509. _starpu_dgbcon_(norm, n, kl, ku, &afb[afb_offset], ldafb, &ipiv[1], &anorm, rcond,
  510. &work[1], &iwork[1], info);
  511. /* Compute the solution matrix X. */
  512. _starpu_dlacpy_("Full", n, nrhs, &b[b_offset], ldb, &x[x_offset], ldx);
  513. _starpu_dgbtrs_(trans, n, kl, ku, nrhs, &afb[afb_offset], ldafb, &ipiv[1], &x[
  514. x_offset], ldx, info);
  515. /* Use iterative refinement to improve the computed solution and */
  516. /* compute error bounds and backward error estimates for it. */
  517. _starpu_dgbrfs_(trans, n, kl, ku, nrhs, &ab[ab_offset], ldab, &afb[afb_offset],
  518. ldafb, &ipiv[1], &b[b_offset], ldb, &x[x_offset], ldx, &ferr[1], &
  519. berr[1], &work[1], &iwork[1], info);
  520. /* Transform the solution matrix X to a solution of the original */
  521. /* system. */
  522. if (notran) {
  523. if (colequ) {
  524. i__1 = *nrhs;
  525. for (j = 1; j <= i__1; ++j) {
  526. i__3 = *n;
  527. for (i__ = 1; i__ <= i__3; ++i__) {
  528. x[i__ + j * x_dim1] = c__[i__] * x[i__ + j * x_dim1];
  529. /* L100: */
  530. }
  531. /* L110: */
  532. }
  533. i__1 = *nrhs;
  534. for (j = 1; j <= i__1; ++j) {
  535. ferr[j] /= colcnd;
  536. /* L120: */
  537. }
  538. }
  539. } else if (rowequ) {
  540. i__1 = *nrhs;
  541. for (j = 1; j <= i__1; ++j) {
  542. i__3 = *n;
  543. for (i__ = 1; i__ <= i__3; ++i__) {
  544. x[i__ + j * x_dim1] = r__[i__] * x[i__ + j * x_dim1];
  545. /* L130: */
  546. }
  547. /* L140: */
  548. }
  549. i__1 = *nrhs;
  550. for (j = 1; j <= i__1; ++j) {
  551. ferr[j] /= rowcnd;
  552. /* L150: */
  553. }
  554. }
  555. /* Set INFO = N+1 if the matrix is singular to working precision. */
  556. if (*rcond < _starpu_dlamch_("Epsilon")) {
  557. *info = *n + 1;
  558. }
  559. work[1] = rpvgrw;
  560. return 0;
  561. /* End of DGBSVX */
  562. } /* _starpu_dgbsvx_ */