Skip to main content

Algebraic

Trait Algebraic 

Source
pub trait Algebraic: Sized {
    type Output;

    // Required methods
    fn algebraic_add(self, rhs: Self) -> Self::Output;
    fn algebraic_sub(self, rhs: Self) -> Self::Output;
    fn algebraic_mul(self, rhs: Self) -> Self::Output;
    fn algebraic_div(self, rhs: Self) -> Self::Output;
    fn algebraic_rem(self, rhs: Self) -> Self::Output;
}
Expand description

Arithmetic with an “algebraic” license: the compiler may reassociate, use reciprocal shortcuts, or contract into fused operations.

std’s algebraic_* methods (unstable float_algebraic) allow any result reachable by real-number-algebra rewrites. The plain IEEE operation is one such result, so the primitive impls here simply perform it — a conforming implementation that loses only the optimization license until std’s intrinsics stabilize and the impls can delegate.

Required Associated Types§

Source

type Output

The (owned) result type.

Required Methods§

Source

fn algebraic_add(self, rhs: Self) -> Self::Output

Addition with algebraic rewrite license.

Source

fn algebraic_sub(self, rhs: Self) -> Self::Output

Subtraction with algebraic rewrite license.

Source

fn algebraic_mul(self, rhs: Self) -> Self::Output

Multiplication with algebraic rewrite license.

Source

fn algebraic_div(self, rhs: Self) -> Self::Output

Division with algebraic rewrite license.

Source

fn algebraic_rem(self, rhs: Self) -> Self::Output

Remainder with algebraic rewrite license.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Algebraic for f32

Source§

type Output = f32

Source§

fn algebraic_add(self, rhs: Self) -> f32

Source§

fn algebraic_sub(self, rhs: Self) -> f32

Source§

fn algebraic_mul(self, rhs: Self) -> f32

Source§

fn algebraic_div(self, rhs: Self) -> f32

Source§

fn algebraic_rem(self, rhs: Self) -> f32

Source§

impl Algebraic for f64

Source§

type Output = f64

Source§

fn algebraic_add(self, rhs: Self) -> f64

Source§

fn algebraic_sub(self, rhs: Self) -> f64

Source§

fn algebraic_mul(self, rhs: Self) -> f64

Source§

fn algebraic_div(self, rhs: Self) -> f64

Source§

fn algebraic_rem(self, rhs: Self) -> f64

Implementors§