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

Speed up recursions #307

Draft
wants to merge 113 commits into
base: development
Choose a base branch
from
Draft

Speed up recursions #307

wants to merge 113 commits into from

Conversation

BalzaniEdoardo
Copy link
Collaborator

@BalzaniEdoardo BalzaniEdoardo commented Feb 12, 2025

In this PR:

  • New accept integer for __mul__: basis * 3 will be equivalent to basis + basis+basis
  • Add an __rmul__ enabling right multiplicationn * basis
  • Improved the efficiency of __pow__ by bisect multiply (log2(n) multiplication, less deep copy)
  • Add a mechanism that do not perform a deep-copy when cloning a bases

Old clone performance

bas = nmo.basis.BSplineEval(5)**500
%timeit bas.__sklearn_clone__()
2.47 s ± 107 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

New clone performance

bas = nmo.basis.BSplineEval(5)**500
%timeit bas.__sklearn_clone__()
10.9 ms ± 22 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)

Old Power Performance

bas = nmo.basis.BSplineEval(5)
%timeit bas ** 500
2.49 s ± 76.7 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

New Power Performance

bas = nmo.basis.BSplineEval(5)
%timeit bas ** 500
8.46 ms ± 79.3 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)

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.

2 participants