-
-
Notifications
You must be signed in to change notification settings - Fork 74
Add recursivefill! and recursivecopy! for ragged arrays
#582
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
ChrisRackauckas
merged 6 commits into
SciML:master
from
JoshuaLampert:recursivefill-raggedarrays
Apr 28, 2026
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5bf7a41
add recursivefill! and recursivecopy! for ragged arrays
JoshuaLampert 6609672
add tests
JoshuaLampert 08d3450
fix mapreduce
JoshuaLampert e1e0c07
add SciMLBase extension
JoshuaLampert 48afea0
fix inference issue on julia v1.10
JoshuaLampert 546b1ab
remove extension again
JoshuaLampert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
27 changes: 27 additions & 0 deletions
27
lib/RecursiveArrayToolsRaggedArrays/ext/RecursiveArrayToolsRaggedArraysDiffEqBaseExt.jl
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| module RecursiveArrayToolsRaggedArraysDiffEqBaseExt | ||
|
|
||
| import RecursiveArrayTools: AbstractRaggedVectorOfArray | ||
| import DiffEqBase | ||
|
|
||
| # Mirror the AbstractVectorOfArray dispatch in DiffEqBase so that adaptive ODE | ||
| # solvers compute the correct RMS-normalized norm instead of the unnormalized | ||
| # Euclidean norm. Without these methods, ODE_DEFAULT_NORM falls through to | ||
| # `norm(u)` = sqrt(sum_abs2), which is sqrt(n_elements) times larger than the | ||
| # intended RMS norm, making the adaptive controller target a stricter tolerance | ||
| # than requested (abstol/reltol). | ||
|
|
||
| function DiffEqBase.UNITLESS_ABS2(x::AbstractRaggedVectorOfArray) | ||
| return mapreduce(DiffEqBase.UNITLESS_ABS2, +, x.u; | ||
| init = zero(real(eltype(x)))) | ||
| end | ||
|
|
||
| function DiffEqBase.recursive_length(u::AbstractRaggedVectorOfArray) | ||
| return sum(DiffEqBase.recursive_length, u.u; init = 0) | ||
| end | ||
|
|
||
| function DiffEqBase.ODE_DEFAULT_NORM(u::AbstractRaggedVectorOfArray, _) | ||
| return Base.FastMath.sqrt_fast( | ||
| DiffEqBase.UNITLESS_ABS2(u) / max(DiffEqBase.recursive_length(u), 1)) | ||
| end | ||
|
|
||
| end # module |
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
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
Oops, something went wrong.
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.
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.
This is circular: these overloads need to go into DiffEqBase instead.
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.
Totally fine with me. Do you (or one of your bots) create a PR in DiffEqBase.jl? Please ping me there if there is one.
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 created SciML/OrdinaryDiffEq.jl#3572.
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.
yeah sorry Mr. Bot is a bit slow right now with all the travel and the big stuff of the recent majors.
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.
Yeah, no worries. I removed the extension again as this will be handled in DiffEqBase.jl now. So I think this is ready from my side.