Public API
This page lists exported symbols of CTBase.Interpolation.
From CTBase.Interpolation
CTBase.Interpolation [Module]
CTBase.Interpolation Module
InterpolationInterpolation utilities for the Control Toolbox (CT) ecosystem.
Public API
ctinterpolate: linear interpolation with flat extrapolationctinterpolate_constant: piecewise-constant (steppost) interpolation
ConstantInterpolant [Struct]
CTBase.Interpolation.ConstantInterpolant Type
Alias for a piecewise-constant Interpolant.
Interpolant [Struct]
CTBase.Interpolation.Interpolant Type
struct Interpolant{M<:CTBase.Interpolation.AbstractInterpolation, TX, TF} <: FunctionCallable interpolant of method M over nodes x with values f.
Interpolant subtypes Function: an instance interp is evaluated as interp(t). The method M (a subtype of AbstractInterpolation) is a compile-time trait parameter that selects the evaluation rule, so the call is type-stable.
Fields
x::TX: nodes at which the values are defined.f::TF: values to interpolate.
Construction
Build instances through the factories ctinterpolate (linear) and ctinterpolate_constant (piecewise-constant), or directly via the aliases LinearInterpolant / ConstantInterpolant.
LinearInterpolant [Struct]
CTBase.Interpolation.LinearInterpolant Type
Alias for a linear Interpolant.
ctinterpolate [Function]
CTBase.Interpolation.ctinterpolate Function
ctinterpolate(
x,
f
) -> CTBase.Interpolation.LinearInterpolantReturn a linear interpolation function for the data f defined at points x.
This creates a one-dimensional linear Interpolant with flat extrapolation beyond the bounds of x (returns f[1] for t < x[1] and f[end] for t >= x[end]).
Arguments
x: A vector of points at which the valuesfare defined.f: A vector of values to interpolate.
Returns
A callable LinearInterpolant that can be evaluated at new points.
Example
julia> x = [0.0, 1.0, 2.0]
julia> f = [1.0, 2.0, 3.0]
julia> interp = ctinterpolate(x, f)
julia> interp(0.5) # Returns 1.5 (linear interpolation)
julia> interp(-1.0) # Returns 1.0 (flat extrapolation)
julia> interp(3.0) # Returns 3.0 (flat extrapolation)ctinterpolate_constant [Function]
CTBase.Interpolation.ctinterpolate_constant Function
ctinterpolate_constant(
x,
f
) -> CTBase.Interpolation.ConstantInterpolantReturn a piecewise-constant interpolation function for the data f defined at points x.
This creates a right-continuous piecewise-constant Interpolant: the value at knot x[i] is held constant on the interval [x[i], x[i+1}).
This implements the standard steppost behavior for optimal control:
u(t_i) = u_i(value at the knot)u(t) = u_ifor allt ∈ [t_i, t_{i+1})Right-continuous:
lim_{t→t_i^+} u(t) = u(t_i)
Arguments
x: A vector of points at which the valuesfare defined.f: A vector of values to interpolate.
Returns
A callable ConstantInterpolant that can be evaluated at new points.
Example
julia> x = [0.0, 1.0, 2.0]
julia> f = [1.0, 2.0, 3.0]
julia> interp = ctinterpolate_constant(x, f)
julia> interp(0.0) # Returns 1.0 (value at x[1])
julia> interp(0.5) # Returns 1.0 (held from x[1] on [0.0, 1.0))
julia> interp(1.0) # Returns 2.0 (value at x[2], right-continuous)
julia> interp(1.5) # Returns 2.0 (held from x[2] on [1.0, 2.0))