@@ -2,7 +2,8 @@ module RecursiveArrayToolsRaggedArrays
22
33import RecursiveArrayTools: RecursiveArrayTools, AbstractRaggedVectorOfArray,
44 AbstractRaggedDiffEqArray, VectorOfArray, DiffEqArray,
5- AbstractVectorOfArray, AbstractDiffEqArray, AllObserved
5+ AbstractVectorOfArray, AbstractDiffEqArray, AllObserved,
6+ recursivefill!, recursivecopy!
67using SymbolicIndexingInterface
78using SymbolicIndexingInterface: ParameterTimeseriesCollection, ParameterIndexingProxy,
89 ScalarSymbolic, ArraySymbolic, NotSymbolic, Timeseries, SymbolCache
@@ -1725,4 +1726,39 @@ end
17251726# Re-export has_discretes and get_discretes for the non-ragged types
17261727has_discretes (:: TT ) where {TT <: AbstractDiffEqArray } = hasfield (TT, :discretes )
17271728
1729+ function recursivecopy! (b:: AbstractRaggedVectorOfArray , a:: AbstractRaggedVectorOfArray )
1730+ @inbounds for i in eachindex (b. u, a. u)
1731+ if ArrayInterface. ismutable (b. u[i]) || b. u[i] isa AbstractRaggedVectorOfArray
1732+ recursivecopy! (b. u[i], a. u[i])
1733+ else
1734+ b. u[i] = copy (a. u[i])
1735+ end
1736+ end
1737+ return b
1738+ end
1739+
1740+ function recursivefill! (
1741+ b:: AbstractRaggedVectorOfArray{T, N} ,
1742+ a:: T2
1743+ ) where {T <: Union{Number, Bool} , T2 <: Union{Number, Bool} , N}
1744+ return fill! (b, a)
1745+ end
1746+
1747+ function recursivefill! (
1748+ b:: AbstractRaggedVectorOfArray{T, N} ,
1749+ a:: T2
1750+ ) where {T <: StaticArraysCore.SArray , T2 <: Union{Number, Bool} , N}
1751+ @inbounds for arr in b. u, i in eachindex (arr)
1752+ arr[i] = map (_ -> a, arr[i])
1753+ end
1754+ return b
1755+ end
1756+
1757+ function recursivefill! (b:: AbstractRaggedVectorOfArray{T, N} , a) where {T <: AbstractArray , N}
1758+ @inbounds for arr in b. u
1759+ recursivefill! (arr, a)
1760+ end
1761+ return b
1762+ end
1763+
17281764end # module RecursiveArrayToolsRaggedArrays
0 commit comments