Skip to content

Commit dc597a4

Browse files
jlchanChrisRackauckas
authored andcommitted
add support for VectorOfArray(AbstractArray{<:AbstractArray})
1 parent 758ac84 commit dc597a4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/vector_of_array.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ Additionally, the `convert(Array,VA::AbstractVectorOfArray)` function is provide
2727
the `VectorOfArray` into a matrix/tensor. Also, `vecarr_to_vectors(VA::AbstractVectorOfArray)`
2828
returns a vector of the series for each component, that is, `A[i,:]` for each `i`.
2929
A plot recipe is provided, which plots the `A[i,:]` series.
30+
31+
There is also support for `VectorOfArray` with constructed from multi-dimensional arrays
32+
```julia
33+
VectorOfArray(u::AbstractArray{AT}) where {T, N, AT <: AbstractArray{T, N}}
34+
```
35+
where `IndexStyle(typeof(u)) isa IndexLinear`.
3036
"""
3137
mutable struct VectorOfArray{T, N, A} <: AbstractVectorOfArray{T, N, A}
3238
u::A # A <: AbstractVector{<: AbstractArray{T, N - 1}}
@@ -150,6 +156,13 @@ function VectorOfArray(vec::AbstractVector{VT}) where {T, N, VT <: AbstractArray
150156
VectorOfArray{T, N + 1, typeof(vec)}(vec)
151157
end
152158

159+
# allow multi-dimensional arrays as long as they're linearly indexed
160+
function VectorOfArray(array::AbstractArray{AT}) where {T, N, AT <: AbstractArray{T, N}}
161+
@assert IndexStyle(typeof(array)) isa IndexLinear
162+
163+
return VectorOfArray{T, N + 1, typeof(array)}(array)
164+
end
165+
153166
function DiffEqArray(vec::AbstractVector{T},
154167
ts::AbstractVector,
155168
::NTuple{N, Int},

0 commit comments

Comments
 (0)