Recursive Array Types
The Recursive Array types are types which implement an AbstractArray interface so that recursive arrays can be handled with standard array functionality. For example, wrapped arrays will automatically do things like recurse broadcast, define optimized mapping and iteration functions, and more.
Abstract Types
Concrete Types
RecursiveArrayTools.VectorOfArray — Type
VectorOfArray(u::AbstractVector)Wrap a collection of equally shaped or ragged arrays as one column-major AbstractArray without materializing a dense concatenation. The last index selects an inner array: A[j, i] accesses component j of A.u[i], while A.u[i] returns the stored array itself.
Arguments
u: an indexable collection of inner arrays. The first inner array determines the element type and dimensionality; later arrays may be ragged in size.
Returns
A mutable VectorOfArray with size(A) == (size(A.u[1])..., length(A.u)) for rectangular input. Ragged input is represented by the maximum inner size and reads outside an inner array as zero.
Notes
VectorOfArray implements the AbstractArray interface. Use A.u[i] or A[:, i] to access an inner array; linear indexing A[i] accesses scalar elements in column-major order.
Fields
u: the collection of stored arrays.
Examples
A = VectorOfArray([[1, 2], [3, 4]])
size(A) == (2, 2)
A[2, 1] == 2
Array(A) == [1 3; 2 4]RecursiveArrayTools.DiffEqArray — Type
DiffEqArray(u::AbstractVector, t::AbstractVector; kwargs...)Wrap saved state arrays u and matching time points t as an AbstractDiffEqArray. The result supports the VectorOfArray interface and stores metadata used for symbolic indexing, interpolation, and plotting.
Arguments
u: an indexable collection of saved state arrays.t: the time values corresponding to the entries ofu.
Keyword Arguments
discretes: discrete parameter timeseries, ornothing.variables: variable symbols used to construct symbolic-indexing metadata.parameters: parameter symbols used to construct symbolic-indexing metadata.independent_variables: independent-variable symbols used to construct symbolic-indexing metadata.interp: an interpolation object called asinterp(t, idxs, deriv, p, continuity).dense: whether dense interpolation is available.
Returns
A mutable DiffEqArray with the saved states, times, parameters, and symbolic indexing metadata. Positional overloads additionally accept p and sys when those objects have already been constructed.
Fields
u: the saved state arrays.t: the time corresponding to each entry ofu.p: parameter values associated with the solution.sys: symbolic indexing metadata.discretes: discrete parameter timeseries, ornothing.interp: interpolation object for dense output, ornothing.dense: whether dense interpolation is available.
Examples
t = [0.0, 0.5, 1.0]
u = [[sin(ti), cos(ti)] for ti in t]
A = DiffEqArray(u, t)
A[1, :] == sin.(t)RecursiveArrayTools.ArrayPartition — Type
ArrayPartition(parts...)Wrap arrays with potentially different types as one linear AbstractVector. Indexing traverses the partitions in order, while broadcasting operates partition-by-partition without losing the individual array types.
Arguments
parts...: arrays or scalar values to store as the partitions.copy_x: when constructing from a tuple withVal{true}, copy each partition; the defaultVal{false}preserves the supplied partition objects.
Returns
An ArrayPartition whose element type is the promoted bottom element type of the partitions.
Errors
ArrayPartition{T, S}(undef, n) throws an ArgumentError unless S describes exactly one partition.
Fields
x: the tuple of stored arrays.
Examples
A = ArrayPartition([1, 2], [3.0, 4.0])
A[3] == 3.0
A.x[1] == [1, 2]
collect(A) == [1.0, 2.0, 3.0, 4.0]RecursiveArrayTools.NamedArrayPartition — Type
NamedArrayPartition(; kwargs...)
NamedArrayPartition(x::NamedTuple)Similar to an ArrayPartition but the individual arrays can be accessed via the constructor-specified names. However, unlike ArrayPartition, each individual array must have the same element type.
Arguments
kwargs...: named partitions, for exampleposition = [1.0, 2.0].x: aNamedTuplecontaining the named partitions.
Fields
array_partition: the underlyingArrayPartition.names_to_indices: aNamedTuplemapping each constructor name to its partition index.
Returns
A named linear AbstractVector whose properties access the corresponding partitions.
Errors
Construction asserts that all partitions have the same element type.
Examples
A = NamedArrayPartition(position = [1.0, 2.0], velocity = [3.0, 4.0])
A.position == [1.0, 2.0]
collect(A) == [1.0, 2.0, 3.0, 4.0]Convenience Constructor Types
RecursiveArrayTools.VA — Type
VAShorthand constructor marker for VectorOfArray. Load RecursiveArrayToolsShorthandConstructors to enable VA[arrays...] syntax.
Examples
using RecursiveArrayToolsShorthandConstructors
A = VA[[1, 2], [3, 4]]
A == VectorOfArray([[1, 2], [3, 4]])RecursiveArrayTools.AP — Type
APShorthand constructor marker for ArrayPartition. Load RecursiveArrayToolsShorthandConstructors to enable AP[parts...] syntax.
Examples
using RecursiveArrayToolsShorthandConstructors
A = AP[[1, 2], [3.0, 4.0]]
A == ArrayPartition([1, 2], [3.0, 4.0])Developer Interfaces
AllObserved is intended for packages extending symbolic indexing of differential-equation arrays. Application code should use the ordinary symbolic indexing interface.
RecursiveArrayTools.AllObserved — Type
AllObserved()Sentinel used by symbolic indexing implementations to request all observed variables from an AbstractDiffEqArray. This is a developer interface for packages extending symbolic indexing.