Skip to main content

Real

Trait Real 

pub trait Real:
    Copy
    + Debug
    + PartialOrd
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Div<Output = Self>
    + Neg<Output = Self>
    + AddAssign
    + SubAssign
    + MulAssign
    + Sum
    + 'static {
    const ZERO: Self;
    const ONE: Self;
    const EPSILON: Self;

    // Required methods
    fn from_f64(x: f64) -> Self;
    fn to_f64(self) -> f64;
    fn abs(self) -> Self;
    fn sqrt(self) -> Self;
    fn recip(self) -> Self;
    fn mul_add(self, a: Self, b: Self) -> Self;
    fn is_finite(self) -> bool;
    fn max(self, other: Self) -> Self;
    fn min(self, other: Self) -> Self;
}
Expand description

The scalar type of every container and factorization of the crate.

Implemented for f64; xingo-extprec implements it for its extended types (trilha L2). A total order is required (pivot search and pivot tests), so intervals are not Real (D-0080, Q2). See the module documentation for the requirements (R1)–(R4).

Required Associated Constants§

const ZERO: Self

The additive identity.

const ONE: Self

The multiplicative identity.

const EPSILON: Self

Machine epsilon of the type (2⁻⁵² for f64).

Required Methods§

fn from_f64(x: f64) -> Self

The value of an f64 (exact for f64 and the extended types).

fn to_f64(self) -> f64

The nearest f64 (lossy for the extended types).

fn abs(self) -> Self

|x|.

fn sqrt(self) -> Self

√x.

fn recip(self) -> Self

1 / x.

fn mul_add(self, a: Self, b: Self) -> Self

self · a + b with a single rounding where the type allows.

fn is_finite(self) -> bool

true iff the value is neither infinite nor NaN.

fn max(self, other: Self) -> Self

The larger of two values, with the NaN rule of f64::max.

fn min(self, other: Self) -> Self

The smaller of two values, with the NaN rule of f64::min.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

§

impl Real for f64

§

const ZERO: f64 = 0.0

§

const ONE: f64 = 1.0

§

const EPSILON: f64 = f64::EPSILON

§

fn from_f64(x: f64) -> f64

§

fn to_f64(self) -> f64

§

fn abs(self) -> f64

§

fn sqrt(self) -> f64

§

fn recip(self) -> f64

§

fn mul_add(self, a: f64, b: f64) -> f64

§

fn is_finite(self) -> bool

§

fn max(self, other: f64) -> f64

§

fn min(self, other: f64) -> f64

Implementors§