@@ -504,14 +504,9 @@ function SymbolicIndexingInterface.get_parameter_timeseries_collection(A::Abstra
504504 return get_discretes (A)
505505end
506506
507- Base. IndexStyle (A:: AbstractVectorOfArray ) = Base. IndexStyle (typeof (A))
508507Base. IndexStyle (:: Type{<:AbstractVectorOfArray} ) = IndexCartesian ()
509508
510- # lastindex with dimension: use size(VA, d) since we now use rectangular interpretation
511- # RaggedEnd is still used internally for ragged column access via A.u
512- @inline function Base. lastindex (VA:: AbstractVectorOfArray , d:: Integer )
513- return size (VA, Int (d))
514- end
509+ # # lastindex inherited from AbstractArray (uses size)
515510
516511# # Linear indexing: convert to Cartesian and dispatch to the N-ary getindex
517512Base. @propagate_inbounds function Base. getindex (A:: AbstractVectorOfArray{T, N} , i:: Int ) where {T, N}
@@ -1030,17 +1025,17 @@ end
10301025 end
10311026end
10321027
1033- # Handle mixed Int + CartesianIndex by flattening to plain indices
1034- # This is needed for sum(A; dims=d) and similar operations
1035- Base. @propagate_inbounds function Base. getindex (
1036- A:: AbstractVectorOfArray , i:: Int , ci:: CartesianIndex
1037- )
1028+ # # Mixed Int + CartesianIndex (needed for sum(A; dims=d) etc.)
1029+ # # Use @inline to avoid invalidation issues with overly broad signatures
1030+ @inline Base. @propagate_inbounds function Base. getindex (
1031+ A:: AbstractVectorOfArray{T, N} , i:: Int , ci:: CartesianIndex
1032+ ) where {T, N}
10381033 return A[i, Tuple (ci)... ]
10391034end
10401035
1041- Base. @propagate_inbounds function Base. setindex! (
1042- A:: AbstractVectorOfArray , v, i:: Int , ci:: CartesianIndex
1043- )
1036+ @inline Base. @propagate_inbounds function Base. setindex! (
1037+ A:: AbstractVectorOfArray{T, N} , v, i:: Int , ci:: CartesianIndex
1038+ ) where {T, N}
10441039 return A[i, Tuple (ci)... ] = v
10451040end
10461041
@@ -1164,9 +1159,7 @@ end
11641159 end
11651160 return (leading... , length (VA. u))
11661161end
1167- @inline Base. size (VA:: AbstractVectorOfArray , i) = size (VA)[i]
11681162@inline Base. size (A:: Adjoint{T, <:AbstractVectorOfArray} ) where {T} = reverse (size (A. parent))
1169- @inline Base. size (A:: Adjoint{T, <:AbstractVectorOfArray} , i) where {T} = size (A)[i]
11701163
11711164Base. @propagate_inbounds function Base. setindex! (
11721165 VA:: AbstractVectorOfArray{T, N} , v,
@@ -1319,36 +1312,14 @@ function Base.SubArray(parent::AbstractVectorOfArray, indices::Tuple)
13191312 Base. ensure_indexable (indices), Base. index_dimsum (indices... )
13201313 )
13211314end
1322- Base . isassigned (VA :: AbstractVectorOfArray , idxs ... ) = checkbounds (Bool, VA, idxs ... )
1315+ # # isassigned, ndims, eltype inherited from AbstractArray
13231316function Base. check_parent_index_match (
13241317 :: RecursiveArrayTools.AbstractVectorOfArray{T, N} , :: NTuple{N, Bool}
13251318 ) where {T, N}
13261319 return nothing
13271320end
1328- # ndims and eltype inherited from AbstractArray{T, N}
13291321
1330- # checkbounds: Use size(VA) for bounds checking (which uses max sizes for ragged).
1331- # This means indices within the "virtual" rectangular shape are valid,
1332- # and out-of-ragged-bounds returns zero on getindex.
1333- # The default AbstractArray checkbounds handles most cases via size(VA).
1334- # We only need a custom method for RaggedEnd/RaggedRange indices.
1335- function Base. checkbounds (:: Type{Bool} , VA:: AbstractVectorOfArray , idx... )
1336- if _has_ragged_end (idx... )
1337- return _checkbounds_ragged (Bool, VA, idx... )
1338- end
1339- # For non-ragged indices, delegate to the standard AbstractArray checkbounds
1340- # which uses axes(VA) derived from size(VA)
1341- s = size (VA)
1342- if length (idx) == length (s)
1343- return all (checkbounds (Bool, Base. OneTo (s[d]), idx[d]) for d in 1 : length (s))
1344- elseif length (idx) == 1
1345- # Linear index
1346- return checkbounds (Bool, 1 : prod (s), idx[1 ])
1347- else
1348- # Let Julia's standard machinery handle it
1349- return Base. checkbounds_indices (Bool, axes (VA), idx)
1350- end
1351- end
1322+ # # checkbounds inherited from AbstractArray (uses axes derived from size)
13521323function Base. copyto! (
13531324 dest:: AbstractVectorOfArray{T, N} ,
13541325 src:: AbstractVectorOfArray{T2, N}
@@ -1381,45 +1352,13 @@ function Base.copyto!(
13811352 copyto! (dest. u, src)
13821353 return dest
13831354end
1384- # Required for broadcasted setindex! when slicing across subarrays
1385- # E.g. if `va = VectorOfArray([rand(3, 3) for i in 1:5])`
1386- # Need this method for `va[2, :, :] .= 3.0`
1387- Base. @propagate_inbounds function Base. maybeview (A:: AbstractVectorOfArray , I... )
1388- return view (A, I... )
1389- end
1355+ # # maybeview inherited from AbstractArray
13901356
1391- # Operations
1392- function Base. isapprox (
1393- A:: AbstractVectorOfArray ,
1394- B:: Union{AbstractVectorOfArray, AbstractArray} ;
1395- kwargs...
1396- )
1397- return all (isapprox .(A, B; kwargs... ))
1398- end
1399-
1400- function Base. isapprox (A:: AbstractArray , B:: AbstractVectorOfArray ; kwargs... )
1401- return all (isapprox .(A, B; kwargs... ))
1402- end
1403-
1404- for op in [:(Base.:- ), :(Base.:+ )]
1405- @eval function ($ op)(A:: AbstractVectorOfArray , B:: AbstractVectorOfArray )
1406- return ($ op). (A, B)
1407- end
1408- end
1357+ # # isapprox inherited from AbstractArray
14091358
1410- for op in [:(Base.:/ ), :(Base.:\ ), :(Base.:* )]
1411- if op != = :(Base.:/ )
1412- @eval ($ op)(A:: Number , B:: AbstractVectorOfArray ) = ($ op). (A, B)
1413- end
1414- if op != = :(Base.:\ )
1415- @eval ($ op)(A:: AbstractVectorOfArray , B:: Number ) = ($ op). (A, B)
1416- end
1417- end
1359+ # # Arithmetic (+, -, *, /) inherited from AbstractArray / broadcasting
14181360
1419- function Base. CartesianIndices (VA:: AbstractVectorOfArray )
1420- # Use size(VA) which handles ragged arrays via maximum sizes
1421- return CartesianIndices (size (VA))
1422- end
1361+ # # CartesianIndices inherited from AbstractArray (uses axes/size)
14231362
14241363# Tools for creating similar objects
14251364# eltype is inherited from AbstractArray{T, N}
@@ -1492,21 +1431,18 @@ function Base.fill!(VA::AbstractVectorOfArray, x)
14921431 return VA
14931432end
14941433
1495- Base . reshape (A :: AbstractVectorOfArray , dims ... ) = Base . reshape ( Array (A), dims ... )
1434+ # # reshape inherited from AbstractArray
14961435
14971436# any/all inherited from AbstractArray (iterates over all elements including ragged zeros)
14981437
14991438# conversion tools
15001439vecarr_to_vectors (VA:: AbstractVectorOfArray ) = [VA[i, :] for i in eachindex (VA. u[1 ])]
1501- Base. vec (VA:: AbstractVectorOfArray ) = vec (convert (Array, VA)) # Allocates
1502- # Convert to dense Array, zero-padding ragged arrays
1503- function Base. convert (:: Type{Array} , VA:: AbstractVectorOfArray )
1504- return Array (VA)
1505- end
1440+ # # vec inherited from AbstractArray
1441+ # # convert(Array, VA) inherited from AbstractArray (calls Array(VA))
15061442
15071443# sum, prod inherited from AbstractArray
15081444
1509- @inline Base . adjoint (VA :: AbstractVectorOfArray ) = Adjoint (VA)
1445+ # # adjoint inherited from AbstractArray
15101446
15111447# linear algebra
15121448ArrayInterface. issingular (va:: AbstractVectorOfArray ) = ArrayInterface. issingular (Matrix (va))
0 commit comments