@@ -15,12 +15,12 @@ function Base.Array(VA::AbstractVectorOfArray)
1515 Array (reshape (reduce (hcat,vecs),size (VA. u[1 ])... ,length (VA. u)))
1616end
1717
18- VectorOfArray (vec:: AbstractVector{T} , dims :: NTuple{N} ) where {T, N} = VectorOfArray {eltype(T), N, typeof(vec)} (vec)
18+ VectorOfArray (vec:: AbstractVector{T} , :: NTuple{N} ) where {T, N} = VectorOfArray {eltype(T), N, typeof(vec)} (vec)
1919# Assume that the first element is representative of all other elements
2020VectorOfArray (vec:: AbstractVector ) = VectorOfArray (vec, (size (vec[1 ])... , length (vec)))
2121VectorOfArray (vec:: AbstractVector{VT} ) where {T, N, VT<: AbstractArray{T, N} } = VectorOfArray {T, N+1, typeof(vec)} (vec)
2222
23- DiffEqArray (vec:: AbstractVector{T} , ts, dims :: NTuple{N} ) where {T, N} = DiffEqArray {eltype(T), N, typeof(vec), typeof(ts)} (vec, ts)
23+ DiffEqArray (vec:: AbstractVector{T} , ts, :: NTuple{N} ) where {T, N} = DiffEqArray {eltype(T), N, typeof(vec), typeof(ts)} (vec, ts)
2424# Assume that the first element is representative of all other elements
2525DiffEqArray (vec:: AbstractVector ,ts:: AbstractVector ) = DiffEqArray (vec, ts, (size (vec[1 ])... , length (vec)))
2626DiffEqArray (vec:: AbstractVector{VT} ,ts:: AbstractVector ) where {T, N, VT<: AbstractArray{T, N} } = DiffEqArray {T, N+1, typeof(vec), typeof(ts)} (vec, ts)
@@ -94,7 +94,11 @@ recursivecopy(VA::VectorOfArray) = VectorOfArray(copy.(VA.u))
9494# For DiffEqArray it ignores ts and fills only u
9595function Base. fill! (VA:: AbstractVectorOfArray , x)
9696 for i in eachindex (VA)
97- fill! (VA[i], x)
97+ if VA[i] isa AbstractArray
98+ fill! (VA[i], x)
99+ else
100+ VA[i] = x
101+ end
98102 end
99103 return VA
100104end
@@ -160,17 +164,22 @@ Broadcast.BroadcastStyle(::VectorOfArrayStyle{M}, ::VectorOfArrayStyle{N}) where
160164Broadcast. BroadcastStyle (:: Type{<:AbstractVectorOfArray{T,N}} ) where {T,N} = VectorOfArrayStyle {N} ()
161165
162166@inline function Base. copy (bc:: Broadcast.Broadcasted{<:VectorOfArrayStyle} )
167+ bc = Broadcast. flatten (bc)
163168 N = narrays (bc)
164- x = unpack_voa (bc, 1 )
165169 VectorOfArray (map (1 : N) do i
166170 copy (unpack_voa (bc, i))
167171 end )
168172end
169173
170174@inline function Base. copyto! (dest:: AbstractVectorOfArray , bc:: Broadcast.Broadcasted{<:VectorOfArrayStyle} )
175+ bc = Broadcast. flatten (bc)
171176 N = narrays (bc)
172177 @inbounds for i in 1 : N
173- copyto! (dest[i], unpack_voa (bc, i))
178+ if dest[i] isa AbstractArray
179+ copyto! (dest[i], unpack_voa (bc, i))
180+ else
181+ dest[i] = copy (unpack_voa (bc, i))
182+ end
174183 end
175184 dest
176185end
0 commit comments