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 image.tomography.get_next_power() #3168

Merged
merged 1 commit into from
Jul 28, 2020
Merged

Conversation

pierrepaleo
Copy link
Contributor

@pierrepaleo pierrepaleo commented Jul 28, 2020

The module silx.image.tomography uses a function get_next_power() which, given an integer n, finds the next "friendly" power of (2, 3, 5 ,7). This is used for padding data before performing FFT.

The current implementation builds a sorted list of numbers in the form (2**a)*(3**b)*(5**c)*(7**d), and finds the "next friendly power" by bisection.

Building this list takes some time, which can be noticeable if get_next_power() is needed many times. In this PR, the list of powers is cached in a LRU structure.

@pierrepaleo
Copy link
Contributor Author

By the way I wonder if get_next_power() and generate_powers() should belong to silx.math.fft. Any thoughts ?

@payno payno merged commit 221eb8a into master Jul 28, 2020
@t20100 t20100 deleted the speedup_get_next_power branch November 4, 2020 08:06
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