@@ -220,6 +220,9 @@ Base.IndexStyle(::Type{<:AbstractVectorOfArray}) = IndexCartesian()
220
220
@inline function Base. eachindex (VA:: AbstractVectorOfArray )
221
221
return eachindex (VA. u)
222
222
end
223
+ @inline function Base. eachindex (:: IndexLinear , VA:: AbstractVectorOfArray{T,N,<:AbstractVector{T}} ) where {T, N}
224
+ return eachindex (IndexLinear (), VA. u)
225
+ end
223
226
@inline Base. IteratorSize (:: Type{<:AbstractVectorOfArray} ) = Base. HasLength ()
224
227
@inline Base. first (VA:: AbstractVectorOfArray ) = first (VA. u)
225
228
@inline Base. last (VA:: AbstractVectorOfArray ) = last (VA. u)
@@ -245,7 +248,11 @@ __parameterless_type(T) = Base.typename(T).wrapper
245
248
Base. @propagate_inbounds function _getindex (A:: AbstractVectorOfArray{T, N} ,
246
249
:: NotSymbolic , I:: Colon... ) where {T, N}
247
250
@assert length (I) == ndims (A. u[1 ]) + 1
248
- vecs = vec .(A. u)
251
+ vecs = if N == 1
252
+ A. u
253
+ else
254
+ vec .(A. u)
255
+ end
249
256
return Adapt. adapt (__parameterless_type (T),
250
257
reshape (reduce (hcat, vecs), size (A. u[1 ])... , length (A. u)))
251
258
end
@@ -496,6 +503,16 @@ function Base.stack(VA::AbstractVectorOfArray; dims = :)
496
503
end
497
504
498
505
# AbstractArray methods
506
+ function Base. view (A:: AbstractVectorOfArray{T,N,<:AbstractVector{T}} , I:: Vararg{Any, M} ) where {T,N,M}
507
+ @inline
508
+ if length (I) == 1
509
+ J = map (i-> Base. unalias (A,i), to_indices (A, I))
510
+ elseif length (I) == 2 && (I[1 ] == Colon () || I[1 ] == 1 )
511
+ J = map (i-> Base. unalias (A,i), to_indices (A, Base. tail (I)))
512
+ end
513
+ @boundscheck checkbounds (A, J... )
514
+ SubArray (IndexStyle (A), A, J, Base. index_dimsum (J... ))
515
+ end
499
516
function Base. view (A:: AbstractVectorOfArray , I:: Vararg{Any,M} ) where {M}
500
517
@inline
501
518
J = map (i-> Base. unalias (A,i), to_indices (A, I))
509
526
Base. isassigned (VA:: AbstractVectorOfArray , idxs... ) = checkbounds (Bool, VA, idxs... )
510
527
Base. check_parent_index_match (:: RecursiveArrayTools.AbstractVectorOfArray{T,N} , :: NTuple{N,Bool} ) where {T,N} = nothing
511
528
Base. ndims (:: AbstractVectorOfArray{T, N} ) where {T, N} = N
529
+
530
+ function Base. checkbounds (:: Type{Bool} , VA:: AbstractVectorOfArray{T, N, <:AbstractVector{T}} , idxs... ) where {T, N}
531
+ if length (idxs) == 2 && (idxs[1 ] == Colon () || idxs[1 ] == 1 )
532
+ return checkbounds (Bool, VA. u, idxs[2 ])
533
+ end
534
+ return checkbounds (Bool, VA. u, idxs... )
535
+ end
512
536
function Base. checkbounds (:: Type{Bool} , VA:: AbstractVectorOfArray , idx... )
513
537
if checkbounds (Bool, VA. u, last (idx))
514
538
if last (idx) isa Integer
0 commit comments