Skip to main content

Real

Trait Real 

Source
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§

Source

const ZERO: Self

The additive identity.

Source

const ONE: Self

The multiplicative identity.

Source

const EPSILON: Self

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

Required Methods§

Source

fn from_f64(x: f64) -> Self

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

Source

fn to_f64(self) -> f64

The nearest f64 (lossy for the extended types).

Source

fn abs(self) -> Self

|x|.

Source

fn sqrt(self) -> Self

√x.

Source

fn recip(self) -> Self

1 / x.

Source

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

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

Source

fn is_finite(self) -> bool

true iff the value is neither infinite nor NaN.

Source

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

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

Source

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§

Source§

impl Real for f64

Source§

const ZERO: Self = 0.0

Source§

const ONE: Self = 1.0

Source§

const EPSILON: Self = f64::EPSILON

Source§

fn from_f64(x: f64) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn abs(self) -> Self

Source§

fn sqrt(self) -> Self

Source§

fn recip(self) -> Self

Source§

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

Source§

fn is_finite(self) -> bool

Source§

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

Source§

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

Implementors§