Skip to content

Commit

Permalink
Generate reverse for StaticVector types (#802)
Browse files Browse the repository at this point in the history
  • Loading branch information
OTDE authored Jun 22, 2020
1 parent 94ce5e2 commit 68b10c2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ reshape(a::Array, ::Size{S}) where {S} = SizedArray{Tuple{S...}}(a)
@inline copy(a::StaticArray) = typeof(a)(Tuple(a))
@inline copy(a::SizedArray) = typeof(a)(copy(a.data))

@inline reverse(v::StaticVector) = typeof(v)(reverse(Tuple(v)))
@inline reverse(v::StaticVector) = typeof(v)(_reverse(v))

@generated function _reverse(v::StaticVector{N,T}) where {N,T}
return Expr(:tuple, (:(v[$i]) for i = N:(-1):1)...)
end

# TODO permutedims?

Expand Down

0 comments on commit 68b10c2

Please sign in to comment.