-
Notifications
You must be signed in to change notification settings - Fork 58
refactor: simplify convolution function signatures #341
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mmolari
commented
Nov 11, 2025
| let dx_a = compute_uniform_spacing(a.t())?; | ||
| let dx_b = compute_uniform_spacing(b.t())?; | ||
| // Use max instead of min to prevent exponentially growing grid sizes | ||
| let dx = dx_a.max(dx_b); |
Author
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.
I also changed this to use first the fine-grained dx (minimum between the two) to make the convolution more precise, and then later interpolate the result of the convolution on the coarse-grained grid (maximum dx between the two)
- change the signature of the `convolve` method, simplifying the underlying logic. Input/output grid are not arguments anymore, and only the grid size is passed. - adapting the testing to this new signature
…d then subsample to coarse grid dx
d5c2629 to
7fdb264
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The convolution function had signature:
But in most cases convolutions are implemented on grids with the same uniform spacing.
Moreover (except for the Riemann case) the convolution is always evaluated on the full output domain and then interpolated to fit the output grid
I think that in most cases it might be useful to simplify the signature of the convolve function to
so that it takes as input simply:
dxIt will then simply return the array of values of the convolution, on a grid of size
|f| + |g| - 1The restriction to particular output ranges or changes in grid sizes can then be done outside of the function. For example now the output grid determination is done here, outside of the function.
In this PR I:
convolvemethod, as specified above