-
Notifications
You must be signed in to change notification settings - Fork 106
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 2 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 |
---|---|---|
|
@@ -47,6 +47,7 @@ | |
'repr_string', | ||
'attribute_repr_string', | ||
'method_repr_string', | ||
'nextpow2', | ||
'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 1 | ||
return 2 ** 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.
Although tiny, I'd probably put this into
numerics.py
, if only to avoid littering this kitchen sink file.