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§
sourcefn try_from_iters<Jmp: IntoIterator<Item = X>, Fnc: IntoIterator<Item = F>>(
jumps: Jmp,
funcs: Fnc
) -> Result<Self, PcwFnError>
fn try_from_iters<Jmp: IntoIterator<Item = X>, Fnc: IntoIterator<Item = F>>(
jumps: Jmp,
funcs: Fnc
) -> Result<Self, PcwFnError>
Try constructing a new piecewise function from iterators over jumps and functions.
sourcefn add_segment(&mut self, jump: X, func: F)
fn add_segment(&mut self, jump: X, func: F)
Add another segment to the piecewise function at the back.
sourcefn into_jumps_and_funcs(self) -> (Self::JmpIter, Self::FncIter)
fn into_jumps_and_funcs(self) -> (Self::JmpIter, Self::FncIter)
Deconstruct a piecewise function into sequences of functions and jumps.
Provided Methods§
sourcefn into_jumps(self) -> Self::JmpIter
fn into_jumps(self) -> Self::JmpIter
Turn the function into an owned iterator over the jumps.
sourcefn into_funcs(self) -> Self::FncIter
fn into_funcs(self) -> Self::FncIter
Turn the function into an owned iterator over the functions.
sourcefn segment_count(&self) -> usize
fn segment_count(&self) -> usize
How many segments the function consists of.
sourcefn combine<Rhs, G, Out, H>(self, rhs: Rhs, action: impl FnMut(F, G) -> H) -> Outwhere
X: Ord,
F: Clone,
G: Clone,
Rhs: PcwFn<X, G>,
Out: PcwFn<X, H>,
fn combine<Rhs, G, Out, H>(self, rhs: Rhs, action: impl FnMut(F, G) -> H) -> Outwhere
X: Ord,
F: Clone,
G: Clone,
Rhs: PcwFn<X, G>,
Out: PcwFn<X, H>,
Combine two piecewise functions using a pointwise action to obtain another piecewise function.
sourcefn resample_to<PcwOut, G>(
self,
other: impl PcwFn<X, G>,
combine: impl FnMut(F, F) -> F
) -> PcwOutwhere
F: Clone,
PcwOut: PcwFn<X, F>,
fn resample_to<PcwOut, G>(
self,
other: impl PcwFn<X, G>,
combine: impl FnMut(F, F) -> F
) -> PcwOutwhere
F: Clone,
PcwOut: PcwFn<X, F>,
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.
sourcefn func_at(&self, x: &X) -> &F
fn func_at(&self, x: &X) -> &F
Find the function that locally defines the piecewise function at some point x
of
the domain.
sourcefn func_at_mut(&mut self, x: &X) -> &mut F
fn func_at_mut(&mut self, x: &X) -> &mut F
Find the function that locally defines the piecewise function at some point x
of
the domain.