Skip to content

Commit a5f36ee

Browse files
compatibility with static arrays
1 parent 19c0532 commit a5f36ee

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

REQUIRE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ Iterators
33
Compat 0.17.0
44
Juno
55
RecipesBase 0.1.0
6+
StaticArrays

src/RecursiveArrayTools.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ __precompile__()
22

33
module RecursiveArrayTools
44

5-
using Iterators, Compat, Juno, RecipesBase
5+
using Iterators, Compat, Juno, RecipesBase, StaticArrays
66

77
@compat abstract type AbstractVectorOfArray{T, N} <: AbstractArray{T, N} end
88

@@ -13,8 +13,8 @@ module RecursiveArrayTools
1313
export VectorOfArray, DiffEqArray, AbstractVectorOfArray, vecarr_to_arr,
1414
vecarr_to_vectors, tuples
1515

16-
export recursivecopy!, vecvecapply, copyat_or_push!, vecvec_to_mat,
17-
recursive_one, recursive_mean, recursive_eltype
16+
export recursivecopy, recursivecopy!, vecvecapply, copyat_or_push!,
17+
vecvec_to_mat, recursive_one, recursive_mean, recursive_eltype
1818

1919
export ArrayPartition
2020

src/utils.jl

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
1+
function recursivecopy{T<:Number,N}(a::AbstractArray{T,N})
2+
copy(a)
3+
end
4+
5+
function recursivecopy{T<:AbstractArray,N}(a::AbstractArray{T,N})
6+
[recursivecopy(x) for x in a]
7+
end
8+
9+
function recursivecopy!{T<:StaticArray,N}(b::AbstractArray{T,N},a::AbstractArray{T,N})
10+
@inbounds for i in eachindex(a)
11+
b[i] = a[i]
12+
end
13+
end
14+
15+
function recursivecopy!{T<:MArray,N}(b::AbstractArray{T,N},a::AbstractArray{T,N})
16+
@inbounds for i in eachindex(a)
17+
recursivecopy!(b[i],a[i])
18+
end
19+
end
20+
121
function recursivecopy!{T<:Number,N}(b::AbstractArray{T,N},a::AbstractArray{T,N})
2-
@inbounds copy!(b,a)
22+
copy!(b,a)
323
end
424

525
function recursivecopy!{T<:AbstractArray,N}(b::AbstractArray{T,N},a::AbstractArray{T,N})

0 commit comments

Comments
 (0)