-
Notifications
You must be signed in to change notification settings - Fork 14
Vectorize signal generator functions #252
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #252 +/- ##
==========================================
+ Coverage 96.07% 96.14% +0.07%
==========================================
Files 31 31
Lines 3565 3581 +16
==========================================
+ Hits 3425 3443 +18
+ Misses 140 138 -2 ☔ View full report in Codecov by Sentry. |
|
| if precomps is None: | ||
| precomps = generate_precomputes(L, -mm, sampling, nside, L_lower) | ||
| precomps = generate_precomputes( | ||
| L=L, | ||
| spin=-mm, | ||
| sampling=sampling, | ||
| nside=nside, | ||
| forward=False, | ||
| L_lower=L_lower, | ||
| ) |
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.
| elif n > 0: | ||
| # Generate independent complex coefficients for positive n | ||
| flmn[N - 1 + n, min_el:L, L - 1] = complex_normal( | ||
| rng, L - min_el, var=2 | ||
| ) | ||
| # For m = 0, n > 0 | ||
| # flmn[N - 1 - n, el, L - 1] = (-1)**n * flmn[N - 1 + n, el, L - 1].conj | ||
| flmn[N - 1 - n, min_el:L, L - 1] = (-1) ** n * ( | ||
| flmn[N - 1 + n, min_el:L, L - 1].conj() | ||
| ) |
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.
Compared to previous implementation, here for m = 0 and abs(n) > 0 we generate complex coefficients rather than real, as the conjugate symmetry condition does not seem to enforce reality in this case - not sure if this is correct though?
CosmoMatt
left a comment
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.
Nice! We originally just implemented these functions for testing purposes so didn't bother optimising them, but as you say definitely worth quickly updating them now.
When running some benchmarks with large
LI noticed that the signal generation functions ins2fft.utils.signal_generatorbecome very slow for largeLdue to the nested for loops.This switches to using a vectorized implementation.
Currently implemented forgenerate_flmonly.EDIT: Now implemented for both
generate_flmandgenerate_flmn.