pub trait Inverse<T>: Reduction<T> {
// Required methods
fn inverse(acc: Self::Total, x: T) -> (Self::Total, bool);
fn undo(a: Self::Total, b: Self::Total) -> (Self::Total, bool);
fn alternating(x: &[T]) -> (Self::Total, bool);
// Provided method
fn fits(_: Self::Total) -> bool { ... }
}Expand description
A reduction whose step can be undone, as Alternated folds by it: Sum subtracts, and ScaledProduct and Product divide. An integer difference fits only within i64, a complex quotient only inside the normal range, and a float quotient only where no item, or product of the running mantissa and an item, leaves the normal floats. An alternated fold can then fail where the right fold taken item by item, or its exact result, would fit.
Required Methods§
Sourcefn inverse(acc: Self::Total, x: T) -> (Self::Total, bool)
fn inverse(acc: Self::Total, x: T) -> (Self::Total, bool)
acc with the item x taken away, and whether it fits.
Sourcefn undo(a: Self::Total, b: Self::Total) -> (Self::Total, bool)
fn undo(a: Self::Total, b: Self::Total) -> (Self::Total, bool)
The fold a with the fold b of the next run taken away, and whether it fits.
Sourcefn alternating(x: &[T]) -> (Self::Total, bool)
fn alternating(x: &[T]) -> (Self::Total, bool)
The right fold of the slice x by the inverse, and whether it fits: for sums through a sum at each parity (alternated), and for products through the pairs’ quotients (pairwise).
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl Inverse<i16> for Sum
impl Inverse<i32> for Sum
impl Inverse<i64> for Sum
impl Inverse<u8> for Sum
impl<F> Inverse<Complex<F>> for Productwhere
F: Native,
Product’s inverse on complex numbers, which divides as crate::divide does.