Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: support_enumeration: Use _numba_linalg_solve #311

Merged
merged 5 commits into from
May 31, 2017
Merged

Conversation

oyamad
Copy link
Member

@oyamad oyamad commented May 28, 2017

  • It turned out that the workaround in item 3 in game_theory: Add support_enumeration #263 (comment) did not work properly in all cases.
  • This fix replaces "SVD + linalg.solve" with _numba_linalg_solve, which calls directly Numba internal numba_xgesv.
  • As a bonus, this leads to about 9x speedup.
ns = [8, 9, 10, 11]
seed = 1234
for n in ns:
    g = gt.random_game((n, n), random_state=seed)
    %timeit gt.support_enumeration(g)
  • Current version:

    • n = 8: 99.1 ms
    • n = 9: 391 ms
    • n = 10: 1.58 s
    • n = 11: 6.56 s
  • This PR:

    • n = 8: 11.6 ms
    • n = 9: 43 ms
    • n = 10: 179 ms
    • n = 11: 727 ms
numba.__version__
'0.30.1'

"LinAlgError: Matrix is singular to machine precision.” raised
@coveralls
Copy link

Coverage Status

Coverage increased (+0.8%) to 91.978% when pulling b283cbd on fix_supp_enum into 34b628b on master.

For use in a jitted function in nopython mode
* Call directly Numba internal `numba_xgesv`
* Return nonzero int if input matrix is singular, allowing alternative to try-except np.linalg.LinAlgError
Allow `cache=True`, close #285
@coveralls
Copy link

Coverage Status

Coverage increased (+1.0%) to 92.124% when pulling e7bcb02 on fix_supp_enum into 34b628b on master.

function. The data in `a` and `b` are interpreted in Fortran order,
and dtype of `a` and `b` must be the same, one of {float32, float64,
complex64, complex128}. `a` and `b` are modified in place, and the
solution is stored in `b`. *No error check is made for the inputs.*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oyamad is it standard convention to return the solution in b and not explicitly return the solution and a status code from the function as a tuple?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if I understand your question, but here is where this is used, where it is check whether matrix A is nonsingular (instead of try-except which is not available in nopython mode), and in case A is singular I don't know what is in there in b.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah. I see. In the code example b is out and it is modified in place (rather than returned). Thanks @oyamad

@mmcky
Copy link
Contributor

mmcky commented May 29, 2017

Thanks @oyamad. I just have one inline question/comment.

This is looking great. I will leave this open for one day and then merge tomorrow.

@mmcky mmcky merged commit c60251d into master May 31, 2017
@mmcky mmcky deleted the fix_supp_enum branch May 31, 2017 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants