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§
Required Methods§
Sourcefn eval(&self, x: Input) -> AdicResult<Self::Output>
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§
Sourcefn compose<F, CInput>(self, inner: F) -> ComposedMapping<CInput, Self, F>
fn compose<F, CInput>(self, inner: F) -> ComposedMapping<CInput, Self, F>
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));