Trait pcw_fn::PcwFn

source ·
pub trait PcwFn<X: PartialOrd, F>: Functor<F> + Sized {
    type JmpIter: Iterator<Item = X>;
    type FncIter: Iterator<Item = F>;

Show 16 methods fn jumps(&self) -> &[X] ; fn funcs(&self) -> &[F] ; fn funcs_mut(&mut self) -> &mut [F] ; fn try_from_iters<Jmp: IntoIterator<Item = X>, Fnc: IntoIterator<Item = F>>(
        jumps: Jmp,
        funcs: Fnc
    ) -> Result<Self, PcwFnError>; fn add_segment(&mut self, jump: X, func: F); fn into_jumps_and_funcs(self) -> (Self::JmpIter, Self::FncIter); fn global(f: F) -> Self { ... } fn into_jumps(self) -> Self::JmpIter { ... } fn into_funcs(self) -> Self::FncIter { ... } fn segment_count(&self) -> usize { ... } fn combine<Rhs, G, Out, H>(
        self,
        rhs: Rhs,
        action: impl FnMut(F, G) -> H
    ) -> Out
    where
        X: Ord,
        F: Clone,
        G: Clone,
        Rhs: PcwFn<X, G>,
        Out: PcwFn<X, H>
, { ... } fn resample_to<PcwOut, G>(
        self,
        other: impl PcwFn<X, G>,
        combine: impl FnMut(F, F) -> F
    ) -> PcwOut
    where
        F: Clone,
        PcwOut: PcwFn<X, F>
, { ... } fn func_at(&self, x: &X) -> &F { ... } fn func_at_mut(&mut self, x: &X) -> &mut F { ... } fn eval<Y>(&self, x: X) -> Y
    where
        F: Fn(X) -> Y
, { ... } fn eval_mut<Y>(&mut self, x: X) -> Y
    where
        F: FnMut(X) -> Y
, { ... }
}
Expand description

A piecewise function given by ╭ f₁(x) if x < x₀ │ f₂(x) if x₀ ≤ x < x₁ f(x) = ┤ f₃(x) if x₁ ≤ x < x₂ │ ⋮ ⋮ ╰ fₙ(x) if xₙ ≤ x for all x ∈ X where f₁,…,fₙ : X -> Y, and x₀ < x₁ < … < xₙ from some strictly totally ordered set X (so X is Ord). Note that the fᵢ are not necessarily distinct.

We’ll call the collection of all xᵢ the jump positions, or simply jumps of the piecewise function.

Required Associated Types§

Required Methods§

Get a reference to the jumps.

Get a reference to the funcs in order.

Get a mutable reference to the jumps.

Try constructing a new piecewise function from iterators over jumps and functions.

Add another segment to the piecewise function at the back.

Deconstruct a piecewise function into sequences of functions and jumps.

Provided Methods§

A function that’s globally given by a single function f.

Turn the function into an owned iterator over the jumps.

Turn the function into an owned iterator over the functions.

How many segments the function consists of.

Combine two piecewise functions using a pointwise action to obtain another piecewise function.

Resample self to the segments of other: replace the jumps of self with those of other and if that leaves multiple functions on a single segment combine them using the provided combine function.

Find the function that locally defines the piecewise function at some point x of the domain.

Find the function that locally defines the piecewise function at some point x of the domain.

Evaluate the function at some point x of the domain.

Mutably evaluate the function at some point x of the domain.

Implementors§