Skip to main content

Mapping

Trait Mapping 

Source
pub trait Mapping<Input> {
    type Output;

    // Required method
    fn eval(&self, x: Input) -> AdicResult<Self::Output>;

    // Provided method
    fn compose<F, CInput>(self, inner: F) -> ComposedMapping<CInput, Self, F>
       where F: Mapping<CInput, Output = Input>,
             Self: Sized { ... }
}
Expand description

Trait for functions

Required Associated Types§

Source

type Output

Output for this Mapping

Required Methods§

Source

fn eval(&self, x: Input) -> AdicResult<Self::Output>

Evaluates the Mapping at the given value x

let series = PowerSeries::new(vec![1, 2, 3, 4, 5]);
assert_eq!(series.eval(5), Ok(1 + 2 * 5 + 3 * 25 + 4 * 125 + 5 * 625));

Provided Methods§

Source

fn compose<F, CInput>(self, inner: F) -> ComposedMapping<CInput, Self, F>
where F: Mapping<CInput, Output = Input>, Self: Sized,

Creates a composed function self o inner

// (5x + 1) o (x + 2) => (5x + 11)
let f1 = PowerSeries::new(vec![1, 5]);
let f2 = PowerSeries::new(vec![2, 1]);
let composed = f1.compose(f2);
let expected = PowerSeries::new(vec![11, 5]);
assert_eq!(composed.eval(1), expected.eval(1));
assert_eq!(composed.eval(10), expected.eval(10));

Implementors§

Source§

impl<In, Out, F> Mapping<In> for F
where F: Fn(In) -> Out,

Source§

type Output = Out

Source§

impl<Input, F, G> Mapping<Input> for ComposedMapping<Input, F, G>
where F: Mapping<G::Output>, G: Mapping<Input>,

Source§

type Output = <F as Mapping<<G as Mapping<Input>>::Output>>::Output

Source§

impl<T> Mapping<T> for PowerSeries<'_, T>
where T: Clone + LocalZero + LocalOne + Mul<Output = T>,

Source§

impl<T, U> Mapping<U> for Polynomial<T>
where T: Clone + LocalZero, U: Clone + LocalZero + LocalOne + Mul<T, Output = U>,