-
Notifications
You must be signed in to change notification settings - Fork 105
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
Improve fbp speed #1505
base: master
Are you sure you want to change the base?
Improve fbp speed #1505
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,12 +20,13 @@ | |
is_real_dtype, is_numeric_dtype, is_real_floating_dtype, | ||
is_complex_floating_dtype, complex_dtype, dtype_repr, | ||
is_string, | ||
normalized_scalar_param_list, normalized_axes_tuple) | ||
normalized_scalar_param_list, normalized_axes_tuple, nextpow2) | ||
|
||
|
||
__all__ = ('reciprocal_grid', 'realspace_grid', | ||
'reciprocal_space', | ||
'dft_preprocess_data', 'dft_postprocess_data') | ||
'dft_preprocess_data', 'dft_postprocess_data', | ||
'next_fast_len') | ||
|
||
|
||
def reciprocal_grid(grid, shift=True, axes=None, halfcomplex=False): | ||
|
@@ -649,6 +650,19 @@ def reciprocal_space(space, axes=None, halfcomplex=False, shift=True, | |
return recip_spc | ||
|
||
|
||
def next_fast_len(n, impl, rfft=False): | ||
"""The smallest size for which a fast fft implementation is available.""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FFT |
||
n = int(n) | ||
if impl == 'pyfftw': | ||
if rfft: | ||
return 2 ** nextpow2(n) | ||
else: | ||
import pyfftw | ||
return pyfftw.next_fast_len(n) | ||
elif impl == 'numpy': | ||
return 2 ** nextpow2(n) | ||
|
||
|
||
if __name__ == '__main__': | ||
from doctest import testmod, NORMALIZE_WHITESPACE | ||
testmod(optionflags=NORMALIZE_WHITESPACE) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ | |
'repr_string', | ||
'attribute_repr_string', | ||
'method_repr_string', | ||
'nextpow2', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although tiny, I'd probably put this into |
||
'run_from_ipython', | ||
'npy_random_seed', | ||
'unique', | ||
|
@@ -1607,6 +1608,28 @@ def unique(seq): | |
return unique_values | ||
|
||
|
||
def nextpow2(n): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
""" | ||
Compute the integer which is a power of two. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On first line. |
||
|
||
Parameters | ||
---------- | ||
n : int | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No text? Not that there's a lot to say, but doc formatting might break. |
||
Examples | ||
======== | ||
>>> odl.util.nextpow2(0) | ||
1 | ||
>>> odl.util.nextpow2(7) | ||
8 | ||
>>> odl.util.nextpow2(513) | ||
1024 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doctests ought to fail now |
||
""" | ||
if n == 0: | ||
return 0 | ||
return int(np.ceil(np.log2(n))) | ||
|
||
|
||
if __name__ == '__main__': | ||
from odl.util.testutils import run_doctests | ||
run_doctests() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
is_rfft