dgesvxx.c 29 KB

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