- Notifications
You must be signed in to change notification settings - Fork0
Tools for easily handling objects like arrays of arrays and deeper nestings
License
rdeits/RecursiveArrayTools.jl
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
RecursiveArrayTools.jl is a set of tools for dealing with recursive arrays likearrays of arrays. The current functionality includes:
VectorOfArray(u::AbstractVector)
AVectorOfArray is an array which has the underlying data structureVector{AbstractArray{T}}(but hopefully concretely typed!). This wrapper over such data structures allows one to lazilyact like it's a higher dimensional vector, and easily convert to different forms. The indexingstructure is:
A[i]# Returns the ith array in the vector of arraysA[j,i]# Returns the jth component in the ith arrayA[j1,...,jN,i]# Returns the (j1,...,jN) component of the ith array
which presents itself as a column-major matrix with the columns being the arrays from the vector.TheAbstractArray interface is implemented, giving access tocopy,push,append!, etc. functionwhich act appropriate. Points to note are:
- The length is the number of vectors, or
length(A.u)whereuis the vector of arrays. - Iteration follows the linear index and goes over the vectors
Additionally, thevecarr_to_arr(VA::AbstractVectorOfArray) function is provided which transformstheVectorOfArray into a matrix/tensor. Also,vecarr_to_vectors(VA::AbstractVectorOfArray)returns a vector of the series for each component, that isA[i,:] for eachi.A plot recipe is provided which plots theA[i,:] series.
Related to theVectorOfArray is theDiffEqArray
DiffEqArray(u::AbstractVector,t::AbstractVector)
This is aVectorOfArray which storesA.t which matchesA.u. This will plot(A.t[i],A[i,:]). The functiontuples(diffeq_arr) returns tuples of(t,u).
ArrayPartition(x::AbstractArray...)
AnArrayPartitionA is an array which is made up of different arraysA.x.These index like a single array, but each subarray may have a different type.However, broadcast is overloaded to loop in an efficient manner, meaning thatA .+= 2.+B is type-stable in its computations, even ifA.x[i] andA.x[j]do not match types. A full array interface is included for completeness, whichallows this array type to be used in place of a standard array in places wheresuch a type stable broadcast may be needed. One example is in heterogeneousdifferential equations forDifferentialEquations.jl.
AnArrayPartition acts like a single array.A[i] indexes through the firstarray, then the second, etc. all linearly. ButA.x is where the arrays are stored.Thus for
using RecursiveArrayToolsA=ArrayPartition(y,z)
We would haveA.x[1]==y andA.x[2]==z. Broadcasting likef.(A) is efficient.
recursivecopy!(b::Array{T,N},a::Array{T,N})
A recursivecopy! function. Acts like adeepcopy! on arrays of arrays, butlikecopy! on arrays of scalars.
vecvec_to_mat(vecvec)Takes in a vector of vectors, returns a matrix.
vecvecapply(f::Base.Callable,v)
Callsf on each element of a vecvecv.
copyat_or_push!{T}(a::AbstractVector{T},i::Int,x)
Ifi<length(x), it's simply arecursivecopy! to theith element. Otherwise it willpush! adeepcopy.
recursive_one(a)Callsone on the bottom container to get the "true element one type"
mean{T<:AbstractArray}(vecvec::Vector{T})mean{T<:AbstractArray}(matarr::Matrix{T},region=0)
Generalized mean functions for vectors of arrays and matrix of arrays.
About
Tools for easily handling objects like arrays of arrays and deeper nestings
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Languages
- Julia100.0%