Struct EvalTrait

Source
pub struct EvalTrait<T: ?Sized, U>(/* private fields */);
Expand description

A trait struct used for multi-point evaluation of polynomials.

Typically, T will be a type which implements PolyTraits and U will be the type of evaluation point. If the combination of T and U is meaningful, then EvalTrait<T,U> should implement EvalTypes; this indicates that polynomials under trait T can be evaluated at points of type U.

The purpose of this is to allow a polynomial with coefficients of one type (say, integers) to be evaluated at a point with another type (say, complex numbers, or integers modulo a prime).

type Eval = EvalTrait<ClassicalTraits<i32>, f32>;
let coeffs = [1, 0, -2];
let pts = [0.5, -1.5];
let info = Eval::prep(pts.iter().copied());
let mut result = Vec::new();
Eval::post(&mut result, &coeffs, &info);
assert_eq!(result, vec![0.5, -3.5]);

This is essentially a work-around for a problem better solved by GATs. (At the time of this writing, GAT is merged in nightly rust but not stable.)

Trait Implementations§

Source§

impl<T: Debug + ?Sized, U: Debug> Debug for EvalTrait<T, U>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C, U> EvalTypes for EvalTrait<ClassicalTraits<C>, U>
where C: Clone, U: Clone + Zero + MulAssign + AddAssign, DefConv<C, U>: OneWay<Source = C, Dest = U>,

Source§

type Coeff = C

Coefficient type of the polynomial being evaluated.
Source§

type Eval = U

Type of the evaluation point(s) and the output(s) of the polynomial evaluation.
Source§

type EvalInfo = Vec<U>

Opaque type to hold pre-processing results.
Source§

fn prep(pts: impl Iterator<Item = Self::Eval>) -> Self::EvalInfo

Pre-processing for multi-point evaluation. Read more
Source§

fn post( out: &mut impl Extend<Self::Eval>, coeffs: &[Self::Coeff], info: &Self::EvalInfo, ) -> Result<()>

Multi-point evaluation after pre-processing.

Auto Trait Implementations§

§

impl<T, U> Freeze for EvalTrait<T, U>
where T: ?Sized,

§

impl<T, U> RefUnwindSafe for EvalTrait<T, U>

§

impl<T, U> Send for EvalTrait<T, U>
where T: Send + ?Sized, U: Send,

§

impl<T, U> Sync for EvalTrait<T, U>
where T: Sync + ?Sized, U: Sync,

§

impl<T, U> Unpin for EvalTrait<T, U>
where T: Unpin + ?Sized, U: Unpin,

§

impl<T, U> UnwindSafe for EvalTrait<T, U>
where T: UnwindSafe + ?Sized, U: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.