-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Specialize Base.similar
for VectorOfArray
with multidimensional parent
#359
Specialize Base.similar
for VectorOfArray
with multidimensional parent
#359
Conversation
@ranocha I think with these changes, we can deal with multidimensional arrays of For example, the following works for me under this PR: using StaticArrays
using RecursiveArrayTools
using OrdinaryDiffEq
function rhs!(duu::VectorOfArray, uu::VectorOfArray, p, t)
du = parent(duu)
u = parent(uu)
du .= u
end
u = fill(SVector{2}(ones(2)), 2, 3)
ode = ODEProblem(rhs!, VectorOfArray(u), (0.0, 1.0))
sol = solve(ode, Tsit5()) |
Add that as a regression test in the downstream portion (https://github.com/SciML/RecursiveArrayTools.jl/blob/master/test/upstream.jl which is for some reason named upstream we should fix that and move it to the other test group https://github.com/SciML/RecursiveArrayTools.jl/blob/master/test/runtests.jl#L63 |
Co-authored-by: Christopher Rackauckas <[email protected]>
Nice 👍 |
This PR specializes
Base.similar
forVectorOfArray
with a homogeneous (e.g., all elements are the same type) multidimensional parent array (introduced in #357). This ensures thatsimilar(VectorOfArray(array)).u
is similar toarray.u
wherearray
is a homogeneous multi-dimensional array.This PR also adds
Base.parent
forVectorOfArray
(parent(vec)
just returnsvec.u
)