Skip to content

Commit fa36501

Browse files
authored
Update vector_of_array.jl
```julia julia> using RecursiveArrayTools, StaticArrays julia> s1 = SVector(1,2); julia> s2 = SVector(3,4); julia> a = VectorOfArray([s1,s2]) VectorOfArray{Int64,2} u: 2-element Array{SVector{2,Int64},1}: [1, 2] [3, 4] # Old behaviour julia> a[:,2] 2-element Array{Int64,1}: 3 4 # New behaviour julia> a[:,2] 2-element SVector{2,Int64}: 3 4 ```
1 parent b1b147c commit fa36501

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/vector_of_array.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ end
4040
# Interface for the two dimensional indexing, a more standard AbstractArray interface
4141
@inline Base.size(VA::AbstractVectorOfArray) = (size(VA.u[1])..., length(VA.u))
4242
@inline Base.getindex{T, N}(VA::AbstractVectorOfArray{T, N}, I::Int...) = VA.u[I[end]][Base.front(I)...]
43+
@inline Base.getindex{T, N}(VA::AbstractVectorOfArray{T, N}, ::Colon, I::Int) = VA.u[I]
4344
@inline Base.setindex!{T, N}(VA::AbstractVectorOfArray{T, N}, v, I::Int...) = VA.u[I[end]][Base.front(I)...] = v
4445

4546
# The iterator will be over the subarrays of the container, not the individual elements

0 commit comments

Comments
 (0)