Trait cgmath::ApproxEq

source ·
pub trait ApproxEq: Sized {
    type Epsilon;

    // Required methods
    fn default_epsilon() -> Self::Epsilon;
    fn default_max_relative() -> Self::Epsilon;
    fn default_max_ulps() -> u32;
    fn relative_eq(
        &self,
        other: &Self,
        epsilon: Self::Epsilon,
        max_relative: Self::Epsilon
    ) -> bool;
    fn ulps_eq(
        &self,
        other: &Self,
        epsilon: Self::Epsilon,
        max_ulps: u32
    ) -> bool;

    // Provided methods
    fn relative_ne(
        &self,
        other: &Self,
        epsilon: Self::Epsilon,
        max_relative: Self::Epsilon
    ) -> bool { ... }
    fn ulps_ne(
        &self,
        other: &Self,
        epsilon: Self::Epsilon,
        max_ulps: u32
    ) -> bool { ... }
}
Expand description

Equality comparisons based on floating point tolerances.

Required Associated Types§

source

type Epsilon

Used for specifying relative comparisons.

Required Methods§

source

fn default_epsilon() -> Self::Epsilon

The default tolerance to use when testing values that are close together.

This is used when no epsilon value is supplied to the relative_eq or ulps_eq macros.

source

fn default_max_relative() -> Self::Epsilon

The default relative tolerance for testing values that are far-apart.

This is used when no max_relative value is supplied to the relative_eq macro.

source

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart.

This is used when no max_relative value is supplied to the relative_eq macro.

source

fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

A test for equality that uses a relative comparison if the values are far apart.

source

fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.

Provided Methods§

source

fn relative_ne( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

The inverse of ApproxEq::relative_eq.

source

fn ulps_ne(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of ApproxEq::ulps_eq.

Implementations on Foreign Types§

source§

impl ApproxEq for f64

§

type Epsilon = f64

source§

fn default_epsilon() -> f64

source§

fn default_max_relative() -> f64

source§

fn default_max_ulps() -> u32

source§

fn relative_eq(&self, other: &f64, epsilon: f64, max_relative: f64) -> bool

source§

fn ulps_eq(&self, other: &f64, epsilon: f64, max_ulps: u32) -> bool

source§

impl ApproxEq for f32

§

type Epsilon = f32

source§

fn default_epsilon() -> f32

source§

fn default_max_relative() -> f32

source§

fn default_max_ulps() -> u32

source§

fn relative_eq(&self, other: &f32, epsilon: f32, max_relative: f32) -> bool

source§

fn ulps_eq(&self, other: &f32, epsilon: f32, max_ulps: u32) -> bool

source§

impl<'a, T> ApproxEq for &'a Twhere T: ApproxEq,

§

type Epsilon = <T as ApproxEq>::Epsilon

source§

fn default_epsilon() -> <&'a T as ApproxEq>::Epsilon

source§

fn default_max_relative() -> <&'a T as ApproxEq>::Epsilon

source§

fn default_max_ulps() -> u32

source§

fn relative_eq( &self, other: &&'a T, epsilon: <T as ApproxEq>::Epsilon, max_relative: <T as ApproxEq>::Epsilon ) -> bool

source§

fn ulps_eq( &self, other: &&'a T, epsilon: <T as ApproxEq>::Epsilon, max_ulps: u32 ) -> bool

source§

impl<'a, T> ApproxEq for &'a mut Twhere T: ApproxEq,

§

type Epsilon = <T as ApproxEq>::Epsilon

source§

fn default_epsilon() -> <&'a mut T as ApproxEq>::Epsilon

source§

fn default_max_relative() -> <&'a mut T as ApproxEq>::Epsilon

source§

fn default_max_ulps() -> u32

source§

fn relative_eq( &self, other: &&'a mut T, epsilon: <T as ApproxEq>::Epsilon, max_relative: <T as ApproxEq>::Epsilon ) -> bool

source§

fn ulps_eq( &self, other: &&'a mut T, epsilon: <T as ApproxEq>::Epsilon, max_ulps: u32 ) -> bool

Implementors§

source§

impl<A: Angle> ApproxEq for Euler<A>

§

type Epsilon = <A as ApproxEq>::Epsilon

source§

impl<S, R, E: BaseFloat> ApproxEq for Decomposed<S, R>where S: ApproxEq<Epsilon = E> + VectorSpace, S::Scalar: ApproxEq<Epsilon = E>, R: ApproxEq<Epsilon = E>,

§

type Epsilon = E

source§

impl<S: BaseFloat> ApproxEq for Basis2<S>

§

type Epsilon = <S as ApproxEq>::Epsilon

source§

impl<S: BaseFloat> ApproxEq for Basis3<S>

§

type Epsilon = <S as ApproxEq>::Epsilon

source§

impl<S: BaseFloat> ApproxEq for Deg<S>

§

type Epsilon = <S as ApproxEq>::Epsilon

source§

impl<S: BaseFloat> ApproxEq for Matrix2<S>

§

type Epsilon = <S as ApproxEq>::Epsilon

source§

impl<S: BaseFloat> ApproxEq for Matrix3<S>

§

type Epsilon = <S as ApproxEq>::Epsilon

source§

impl<S: BaseFloat> ApproxEq for Matrix4<S>

§

type Epsilon = <S as ApproxEq>::Epsilon

source§

impl<S: BaseFloat> ApproxEq for Point1<S>

§

type Epsilon = <S as ApproxEq>::Epsilon

source§

impl<S: BaseFloat> ApproxEq for Point2<S>

§

type Epsilon = <S as ApproxEq>::Epsilon

source§

impl<S: BaseFloat> ApproxEq for Point3<S>

§

type Epsilon = <S as ApproxEq>::Epsilon

source§

impl<S: BaseFloat> ApproxEq for Quaternion<S>

§

type Epsilon = <S as ApproxEq>::Epsilon

source§

impl<S: BaseFloat> ApproxEq for Rad<S>

§

type Epsilon = <S as ApproxEq>::Epsilon

source§

impl<S: BaseFloat> ApproxEq for Vector1<S>

§

type Epsilon = <S as ApproxEq>::Epsilon

source§

impl<S: BaseFloat> ApproxEq for Vector2<S>

§

type Epsilon = <S as ApproxEq>::Epsilon

source§

impl<S: BaseFloat> ApproxEq for Vector3<S>

§

type Epsilon = <S as ApproxEq>::Epsilon

source§

impl<S: BaseFloat> ApproxEq for Vector4<S>

§

type Epsilon = <S as ApproxEq>::Epsilon