Skip to content

Public API

This page lists exported symbols of CTBase.Interpolation.


From CTBase.Interpolation

CTBase.Interpolation [Module]

CTBase.Interpolation Module
julia
Interpolation

Interpolation utilities for the Control Toolbox (CT) ecosystem.

Public API

  • ctinterpolate: linear interpolation with flat extrapolation

  • ctinterpolate_constant: piecewise-constant (steppost) interpolation

ConstantInterpolant [Struct]

CTBase.Interpolation.ConstantInterpolant Type

Alias for a piecewise-constant Interpolant.

Interpolant [Struct]

CTBase.Interpolation.Interpolant Type
julia
struct Interpolant{M<:CTBase.Interpolation.AbstractInterpolation, TX, TF} <: Function

Callable 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
julia
ctinterpolate(
    x,
    f
) -> CTBase.Interpolation.LinearInterpolant

Return 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 values f are defined.

  • f: A vector of values to interpolate.

Returns

A callable LinearInterpolant that can be evaluated at new points.

Example

julia
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
julia
ctinterpolate_constant(
    x,
    f
) -> CTBase.Interpolation.ConstantInterpolant

Return 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_i for all t ∈ [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 values f are defined.

  • f: A vector of values to interpolate.

Returns

A callable ConstantInterpolant that can be evaluated at new points.

Example

julia
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))