@@ -42,39 +42,47 @@ like `copy!` on arrays of scalars.
4242"""
4343function recursivecopy! end
4444
45- for type in [AbstractArray, AbstractVectorOfArray]
46- @eval function recursivecopy! (b:: $type{T, N} ,
47- a:: $type{T2, N} ) where {T <: StaticArraysCore.StaticArray ,
48- T2 <: StaticArraysCore.StaticArray ,
49- N}
50- @inbounds for i in eachindex (a)
51- # TODO : Check for `setindex!`` and use `copy!(b[i],a[i])` or `b[i] = a[i]`, see #19
52- b[i] = copy (a[i])
53- end
45+ function recursivecopy! (b:: AbstractArray{T, N} , a:: AbstractArray{T2, N} ) where {T <: StaticArraysCore.StaticArray ,
46+ T2 <: StaticArraysCore.StaticArray ,
47+ N}
48+ @inbounds for i in eachindex (a)
49+ # TODO : Check for `setindex!`` and use `copy!(b[i],a[i])` or `b[i] = a[i]`, see #19
50+ b[i] = copy (a[i])
5451 end
52+ end
5553
56- @eval function recursivecopy! (b:: $type{T, N} ,
57- a:: $type{T2, N} ) where {T <: Enum , T2 <: Enum , N}
58- copyto! (b, a)
59- end
54+ function recursivecopy! (b:: AbstractArray{T, N} ,
55+ a:: AbstractArray{T2, N} ) where {T <: Enum , T2 <: Enum , N}
56+ copyto! (b, a)
57+ end
58+
59+ function recursivecopy! (b:: AbstractArray{T, N} ,
60+ a:: AbstractArray{T2, N} ) where {T <: Number , T2 <: Number , N}
61+ copyto! (b, a)
62+ end
6063
61- @eval function recursivecopy! (b:: $type{T, N} ,
62- a:: $type{T2, N} ) where {T <: Number , T2 <: Number , N}
64+ function recursivecopy! (b:: AbstractArray{T, N} ,
65+ a:: AbstractArray{T2, N} ) where {T <: Union{AbstractArray, AbstractVectorOfArray} ,
66+ T2 <: Union{AbstractArray, AbstractVectorOfArray} , N}
67+ if ArrayInterface. ismutable (T)
68+ @inbounds for i in eachindex (b, a)
69+ recursivecopy! (b[i], a[i])
70+ end
71+ else
6372 copyto! (b, a)
6473 end
74+ return b
75+ end
6576
66- @eval function recursivecopy! (b:: $type{T, N} ,
67- a:: $type{T2, N} ) where {T <: Union{AbstractArray, AbstractVectorOfArray} ,
68- T2 <: Union{AbstractArray, AbstractVectorOfArray} , N}
69- if ArrayInterface. ismutable (T)
70- @inbounds for i in eachindex (b, a)
71- recursivecopy! (b[i], a[i])
72- end
73- else
74- copyto! (b, a)
77+ function recursivecopy! (b:: AbstractVectorOfArray , a:: AbstractVectorOfArray )
78+ if ArrayInterface. ismutable (eltype (b. u))
79+ @inbounds for i in eachindex (b. u, a. u)
80+ recursivecopy! (b. u[i], a. u[i])
7581 end
76- return b
82+ else
83+ copyto! (b. u, a. u)
7784 end
85+ return b
7886end
7987
8088"""
0 commit comments