Skip to content

Conversation

@gatocor
Copy link

@gatocor gatocor commented Oct 20, 2025

Implement basic version of recursivecopy! function.

The recursivecopy! is the default fallback for coping base structures from DifferentialEquations during stepping. If using custom structures that not necessarily follow the AbstractStructures/RecursiveArrayTools schemes, the stepping breaks.

Adding a naive recursivecopy! without specialization solves the problem when using custom structures with a Base.copyto! method defined without need of overloading recursivecopy! internaly.

Implement basic version of recursivecopy! function.
@ChrisRackauckas
Copy link
Member

There is a bit of a difference though. recursivecopy! does not alias subarrays while copyto! does. For example,

a = [zeros(4), zeros(4)]
b = [ones(4), ones(4)]
copyto!(a,b)
b[1][2] = 10
@test a[1][2] == 10

is true for copyto! but false for recursivecopy!. The fallback behaviors of copyto!, which can cause results to alias, would give bugs then if added in recursivecopy! which expects results to not alias. One result of this is that you could for example have the saves of the ODE solve alias each other, so all of the outputs in the time series would be the same array rather than snapshots in time, if this aliasing occurred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants