Recursive Array Functions
These are functions designed for recursive arrays, like arrays of arrays, and do not require that the RecursiveArrayTools types are used.
Function List
RecursiveArrayTools.recursivecopy — Function
recursivecopy(a)Copy a recursively. This acts like deepcopy for nested arrays and like copy for arrays of scalar values.
Examples
original = [[1, 2], [3, 4]]
copied = recursivecopy(original)
copied[1][1] = 10
original[1][1] == 1RecursiveArrayTools.recursivecopy! — Function
recursivecopy!(dest, src)Copy src recursively into dest. This acts like deepcopy! for nested arrays and like copy! for arrays of scalar values. dest and src must have matching dimensionality; use recursivecopyto! for linear copying between different shapes.
Examples
dest = [zeros(2), zeros(2)]
src = [[1.0, 2.0], [3.0, 4.0]]
recursivecopy!(dest, src)RecursiveArrayTools.recursivecopyto! — Function
recursivecopyto!(dest, src) -> destCopy src recursively into dest in linear, column-major order. This acts like deepcopy! for nested arrays and like copyto! for arrays of scalar values.
Unlike recursivecopy!, this does not require matching dimensions or axes. Use it when copying between different shapes is intentional.
Examples
dest = zeros(2, 2)
recursivecopyto!(dest, [1.0, 2.0, 3.0, 4.0])RecursiveArrayTools.recursivefill! — Function
recursivefill!(dest, value)Fill every scalar element of the nested container dest with value.
Examples
dest = [zeros(2), zeros(3)]
recursivefill!(dest, 1.0)RecursiveArrayTools.vecvecapply — Function
vecvecapply(f, v)Flatten the nested array v and call f on the resulting vector.
Examples
vecvecapply(sum, [[1, 2], [3, 4]]) == 10RecursiveArrayTools.copyat_or_push! — Function
copyat_or_push!(a, i, x[, perform_copy = true]) -> nothingRecursively copy x into a[i] when that element exists, or append a recursive copy of x otherwise. Set perform_copy = false to assign or append x directly.
Examples
values = [[1, 2]]
copyat_or_push!(values, 2, [3, 4])
values == [[1, 2], [3, 4]]RecursiveArrayTools.vecvec_to_mat — Function
vecvec_to_mat(vecvec)Convert a vector of equal-length vectors into a dense matrix whose rows are the input vectors.
Examples
vecvec_to_mat([[1, 2], [3, 4]]) == [1 2; 3 4]RecursiveArrayTools.recursive_one — Function
recursive_one(a)Return one for the scalar value at the bottom of the nested container a.
Examples
recursive_one([[2.0]]) == 1.0RecursiveArrayTools.recursive_mean — Function
recursive_mean(x)Compute a mean value through recursive array containers without requiring Statistics.mean.
Examples
recursive_mean([[1.0, 3.0], [3.0, 5.0]]) == [2.0, 4.0]RecursiveArrayTools.recursive_bottom_eltype — Function
recursive_bottom_eltype(x)Return the scalar element type at the bottom of nested array-like element types.
Examples
recursive_bottom_eltype(Vector{Vector{Float32}}) === Float32RecursiveArrayTools.recursive_unitless_bottom_eltype — Function
recursive_unitless_bottom_eltype(a)Return the unitless scalar type at the bottom of the nested container type a.
Examples
recursive_unitless_bottom_eltype(Vector{Vector{Float64}}) === Float64RecursiveArrayTools.recursive_unitless_eltype — Function
recursive_unitless_eltype(a)Return the element type of a after recursively removing units from its scalar type.
RecursiveArrayTools.vecarr_to_vectors — Function
vecarr_to_vectors(A::AbstractVectorOfArray)Collect the component time series of A as one vector per component.
Examples
A = VectorOfArray([[1, 2], [3, 4]])
vecarr_to_vectors(A) == [[1, 3], [2, 4]]RecursiveArrayTools.tuples — Function
tuples(A::DiffEqArray)Return the saved time/state pairs of A as (t, u) tuples.
Examples
A = DiffEqArray([[1.0], [2.0]], [0.0, 1.0])
tuples(A) == [(0.0, [1.0]), (1.0, [2.0])]