{"action":"created","issue":{"url":"https://api.github.com/repos/scipy/scipy/issues/6693","repository_url":"https://api.github.com/repos/scipy/scipy","labels_url":"https://api.github.com/repos/scipy/scipy/issues/6693/labels{/name}","comments_url":"https://api.github.com/repos/scipy/scipy/issues/6693/comments","events_url":"https://api.github.com/repos/scipy/scipy/issues/6693/events","html_url":"https://github.com/scipy/scipy/pull/6693","id":183465788,"number":6693,"title":"WIP: ENH: Integrating LAPACK \"expert\" routines with conditioning warnings for linalg.solve_ family","user":{"login":"ilayn","id":1303842,"avatar_url":"https://avatars.githubusercontent.com/u/1303842?v=3","gravatar_id":"","url":"https://api.github.com/users/ilayn","html_url":"https://github.com/ilayn","followers_url":"https://api.github.com/users/ilayn/followers","following_url":"https://api.github.com/users/ilayn/following{/other_user}","gists_url":"https://api.github.com/users/ilayn/gists{/gist_id}","starred_url":"https://api.github.com/users/ilayn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilayn/subscriptions","organizations_url":"https://api.github.com/users/ilayn/orgs","repos_url":"https://api.github.com/users/ilayn/repos","events_url":"https://api.github.com/users/ilayn/events{/privacy}","received_events_url":"https://api.github.com/users/ilayn/received_events","type":"User","site_admin":false},"labels":[{"id":37340735,"url":"https://api.github.com/repos/scipy/scipy/labels/enhancement","name":"enhancement","color":"bfe5bf","default":true},{"id":37340991,"url":"https://api.github.com/repos/scipy/scipy/labels/scipy.linalg","name":"scipy.linalg","color":"207de5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":21,"created_at":"2016-10-17T16:35:41Z","updated_at":"2016-11-06T12:28:46Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/scipy/scipy/pulls/6693","html_url":"https://github.com/scipy/scipy/pull/6693","diff_url":"https://github.com/scipy/scipy/pull/6693.diff","patch_url":"https://github.com/scipy/scipy/pull/6693.patch"},"body":"As briefly discussed in #6634, in this PR the ?GESVX routine of LAPACK is exposed for generic use. They are the so-called eXpert versions of the already existing ?GESV routine family which are used in `sp.linalg.solve` \r\n\r\nThe use case for these routines are many-fold \r\n- The most important case is to finally change the silent singular matrix handling. With the condition number and error estimates, a warning/error/msg can be emitted (needs-decision).\r\n- Ill-conditioned matrices can be checked before inversion steps and nonsensical results can be avoided\r\n- cond and rcond functions can now use estimates for comparison\r\n- the lu factorization comes with a bonus (as is with ?GESV too but the API throws it away currently)\r\n- The numerical accuracy is improved thanks to the balancing and iterative refinement (Lapack prefers the term `equilibration` for this particular instance). \r\n\r\nThe API requirements for such routine is a bit tedious to satisfy. One of the main reasons for that is the variety of options to choose from. To give an example, here is an example from LAPACK documentation: \r\n\r\n> ```\r\n>      EQUED is CHARACTER*1\r\n>       Specifies the form of equilibration that was done.\r\n>       = 'N':  No equilibration (always true if FACT = 'N').\r\n>       = 'R':  Row equilibration, i.e., A has been premultiplied by\r\n>               diag(R).\r\n>       = 'C':  Column equilibration, i.e., A has been postmultiplied\r\n>               by diag(C).\r\n>       = 'B':  Both row and column equilibration, i.e., A has been\r\n>               replaced by diag(R) * A * diag(C).\r\n>       EQUED is an input argument if FACT = 'F'; otherwise, it is an\r\n>       output argument.\r\n> ```\r\n\r\nor an even more joyful one is the following \r\n\r\n> ```\r\n>       AF is DOUBLE PRECISION array, dimension (LDAF,N)\r\n>       If FACT = 'F', then AF is an input argument and on entry\r\n>       contains the factors L and U from the factorization\r\n>       A = P*L*U as computed by DGETRF.  If EQUED .ne. 'N', then\r\n>       AF is the factored form of the equilibrated matrix A.\r\n> \r\n>      If FACT = 'N', then AF is an output argument and on exit\r\n>       returns the factors L and U from the factorization A = P*L*U\r\n>       of the original matrix A.\r\n> \r\n>      If FACT = 'E', then AF is an output argument and on exit\r\n>       returns the factors L and U from the factorization A = P*L*U\r\n>       of the equilibrated matrix A (see the description of A for\r\n>       the form of the equilibrated matrix).\r\n> ```\r\n\r\nThere will be a a few phases for this PR to come to fruition and I would really appreciate all the feedback from the wizards.\r\n- [x] Make sure the f2py interface is correct. \r\n- [x] Make sure that the input-output arguments are handled correctly.\r\n- [x] Make sure that the varying number of I/O arguments are not exposed to the user and the decision tree should not lead to confusion. In other words, if out of inexperience a user selects two conflicting keyword arguments (as it is extremely easy to fall into those traps) the behavior should be unambiguous override or err out directly. \r\n- [ ] Make sure that the tests cover sufficient examples\r\n- [x] Decide on the numerical bound formula to accept numerical singularity\r\n- [ ]  Decide on where this functionality goes into, existing `sp.linalg.solve` as an addition or a standalone solver and so on.\r\n"},"comment":{"url":"https://api.github.com/repos/scipy/scipy/issues/comments/258677870","html_url":"https://github.com/scipy/scipy/pull/6693#issuecomment-258677870","issue_url":"https://api.github.com/repos/scipy/scipy/issues/6693","id":258677870,"user":{"login":"ilayn","id":1303842,"avatar_url":"https://avatars.githubusercontent.com/u/1303842?v=3","gravatar_id":"","url":"https://api.github.com/users/ilayn","html_url":"https://github.com/ilayn","followers_url":"https://api.github.com/users/ilayn/followers","following_url":"https://api.github.com/users/ilayn/following{/other_user}","gists_url":"https://api.github.com/users/ilayn/gists{/gist_id}","starred_url":"https://api.github.com/users/ilayn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilayn/subscriptions","organizations_url":"https://api.github.com/users/ilayn/orgs","repos_url":"https://api.github.com/users/ilayn/repos","events_url":"https://api.github.com/users/ilayn/events{/privacy}","received_events_url":"https://api.github.com/users/ilayn/received_events","type":"User","site_admin":false},"created_at":"2016-11-06T12:28:46Z","updated_at":"2016-11-06T12:28:46Z","body":"Here are the speed comparison calling directly `sp.linalg.lapack.dgesvx(A,B)` and `sp.linalg.lapack.dgesv(A,B)` with \r\n```\r\nA = np.random.rand(n, n)\r\nB = np.random.rand(n, 3)\r\n```\r\n\r\nhorizontal axis is `n` and vertical axis is seconds in the first one. In the second it's just the ratio of two curves. The numbers are averages of 25 runs for each n. \r\n\r\n![1](https://cloud.githubusercontent.com/assets/1303842/20037654/540d643e-a424-11e6-9d6b-860c47e7b5d6.png)\r\n![2](https://cloud.githubusercontent.com/assets/1303842/20037655/56a1215e-a424-11e6-8569-b629fcd4cada.png)\r\n"}}
{"actor":{"display_login":"ilayn"}}