@@ -42,39 +42,47 @@ like `copy!` on arrays of scalars.
42
42
"""
43
43
function recursivecopy! end
44
44
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])
54
51
end
52
+ end
55
53
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
60
63
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
63
72
copyto! (b, a)
64
73
end
74
+ return b
75
+ end
65
76
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])
75
81
end
76
- return b
82
+ else
83
+ copyto! (b. u, a. u)
77
84
end
85
+ return b
78
86
end
79
87
80
88
"""
0 commit comments