This is a super lightweight package that exports two functions: index
and slice
. These functions have helped to ease the burden of handling messy indexing into trajectory data vectors of the form
where each element dim = n + m
, we can use slice
and index
, to extract what we want from
- extract
$z_t$ :zₜ = Z⃗[slice(t, dim)]
- extract
$x_t$ :xₜ = Z⃗[slice(t, 1:n, dim)]
- extract
$u_t$ :uₜ = Z⃗[slice(t, (1:m) .+ n, dim)]
- extract
$i$ -th component of$x_t$ :xₜⁱ = Z⃗[index(t, i, dim)]
- extract
$j$ -th component of$u_t$ :uₜʲ = Z⃗[index(t, j + n, dim)]
With this, the user is still responsible for keeping track of the component indices for
This package is not yet registered. To install, use the following command:
using Pkg
Pkg.add(url="https://github.com/aarontrowbridge/TrajectoryIndexingUtils.jl", rev="main")
index(t::Int, dim::Int) -> zₜ[dim]
index(t::Int, pos::Int, dim::Int) -> zₜ[pos]
slice(t::Int, dim::Int; stretch=0) -> zₜ[1:dim + stretch] # can be used to extract, e.g., [xₜ; xₜ₊₁], with stretch = dim
slice(t::Int, pos::Int, dim::Int) -> zₜ[1:pos]
slice(t::Int, pos1::Int, pos2::Int, dim::Int) -> zₜ[pos1:pos2]
slice(t::Int, indices::AbstractVector{Int}, dim::Int) -> zₜ[indices]
slice(ts::UnitRange{Int}, dim::Int) -> vec(zₜ for t ∈ ts)
- Add tests
- Add examples
- Add documentation
- Add methods that take in trajectory vector as the first argument
- Add
block
function for accessing blocks of matrices with trajectory structure, e.g. jacobians & hessians