pub struct Exactly;Expand description
Exact comparison, as a tolerance of 0 gives, through plain IEEE comparisons and floor.
Trait Implementations§
impl Copy for Exactly
Source§impl Tolerant for Exactly
impl Tolerant for Exactly
Source§fn close<F: Float>(self, _: F, _: F) -> bool
fn close<F: Float>(self, _: F, _: F) -> bool
Whether
x and y lie within the tolerance of each other: |x-y| is less than the tolerance times the larger of |x| and |y|. NaN and the infinities are close to nothing. less and less_equal read it without equal’s x == y, because x < y already implies x != y, and x <= y already holds where x == y.Source§fn floor_in<F: Float, O: Ops<F> + ?Sized>(self, o: &O, y: O::V) -> O::V
fn floor_in<F: Float, O: Ops<F> + ?Sized>(self, o: &O, y: O::V) -> O::V
floor through o: the formula that the Floor, Ceil and Residue objects give compiled code (Facts::formula).Source§fn equal<F: Float>(self, x: F, y: F) -> bool
fn equal<F: Float>(self, x: F, y: F) -> bool
Whether
x equals y: it is y, or close to it. NaN equals nothing, as in IEEE, and an infinity equals only itself.Source§fn floor<F: Float>(self, y: F) -> F
fn floor<F: Float>(self, y: F) -> F
The floor of
y: the whole number nearest to y, unless it lies above y and doesn’t equal it. Then the whole number below. A floor or ceiling that is zero is 0, never -0, as BPL’s numbers give it.Source§fn ceil<F: Float>(self, y: F) -> F
fn ceil<F: Float>(self, y: F) -> F
The ceiling of
y: the whole number nearest to y, unless it lies below y and doesn’t equal it. Then the whole number above.Source§fn matches<F: Float>(self, x: F, y: F) -> bool
fn matches<F: Float>(self, x: F, y: F) -> bool
Whether
x and y match: they are equal, or both are NaN. A search that must find NaN compares with matches.Source§fn less<F: Float>(self, x: F, y: F) -> bool
fn less<F: Float>(self, x: F, y: F) -> bool
Whether
x is below y and doesn’t equal it. Comparisons with NaN are false.Source§fn less_equal<F: Float>(self, x: F, y: F) -> bool
fn less_equal<F: Float>(self, x: F, y: F) -> bool
Whether
x is below y or equals it. Comparisons with NaN are false.Source§fn greater<F: Float>(self, x: F, y: F) -> bool
fn greater<F: Float>(self, x: F, y: F) -> bool
Whether
x is above y and doesn’t equal it. Comparisons with NaN are false.Source§fn greater_equal<F: Float>(self, x: F, y: F) -> bool
fn greater_equal<F: Float>(self, x: F, y: F) -> bool
Whether
x is above y or equals it. Comparisons with NaN are false.Source§fn compare<F: Float>(self, x: F, y: F) -> Option<Ordering>
fn compare<F: Float>(self, x: F, y: F) -> Option<Ordering>
The order of
x and y, which is Equal when they are equal. None when either is NaN.Source§fn residue<F: Float>(self, x: F, y: F) -> F
fn residue<F: Float>(self, x: F, y: F) -> F
y modulo x, through recipe::residue: y - x·floor(y/x) from this tolerance’s floor of the quotient, rounded once where the target fuses multiply-add. At nonzero tolerance, a product equal to y within tolerance leaves no remainder. x = 0 gives y.Source§fn residue_in<F: Float, O: Ops<F> + ?Sized>(
self,
o: &O,
x: O::V,
y: O::V,
) -> O::V
fn residue_in<F: Float, O: Ops<F> + ?Sized>( self, o: &O, x: O::V, y: O::V, ) -> O::V
residue through o.Source§fn nearest_whole<F: Float>(self, y: F) -> (F, bool)
fn nearest_whole<F: Float>(self, y: F) -> (F, bool)
The whole number nearest
y, and whether y equals it within this tolerance.fn nearest_whole_in<F: Float, O: Ops<F> + ?Sized>( self, o: &O, y: O::V, ) -> (O::V, O::B)
Source§fn range<F: Float>(self, c: F) -> Option<(F, F)>
fn range<F: Float>(self, c: F) -> Option<(F, F)>
The floats equal to
c, as (lo, hi): equal(x, c) holds exactly when lo <= x && x <= hi. Comparing many floats with c then takes two plain comparisons for each, in a loop that vectorizes. None when c is NaN, which equals nothing.Source§fn gcd<F: Float>(self, x: F, y: F) -> F
fn gcd<F: Float>(self, x: F, y: F) -> F
The greatest common divisor of
x and y: the larger magnitude divided by the numerator of the first convergent of the ratio of the magnitudes that equals the ratio. It computes in f64 and rounds. NaN when either argument is NaN or infinite. Whole magnitudes whose product is below 1e14 take integer gcd, which gives the same result at any tolerance up to the default.Auto Trait Implementations§
impl Forget for Exactly
impl Freeze for Exactly
impl RefUnwindSafe for Exactly
impl Send for Exactly
impl Sync for Exactly
impl Unpin for Exactly
impl UnsafeUnpin for Exactly
impl UnwindSafe for Exactly
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> TolerantComplex for Twhere
T: Tolerant,
impl<T> TolerantComplex for Twhere
T: Tolerant,
Source§fn complex_equal<R: Native>(self, x: Complex<R>, y: Complex<R>) -> bool
fn complex_equal<R: Native>(self, x: Complex<R>, y: Complex<R>) -> bool
Whether
x equals y: the magnitude of x-y is at most the tolerance times the larger magnitude, as Dyalog APL defines it. A number with an infinite or NaN part equals only itself, as IEEE compares it. A tolerance of 0 compares the parts exactly.Source§fn squared_equal<R: Native>(self, x: Complex<R>, y: Complex<R>) -> (bool, bool)
fn squared_equal<R: Native>(self, x: Complex<R>, y: Complex<R>) -> (bool, bool)
complex_equal through squared magnitudes, |x-y|² ≤ t² max(|x|², |y|²), with no branch or square root, and whether that test decides it. A tolerance of 0 compares the parts exactly, which always decides. Otherwise the test decides wherever the larger squared magnitude lies between 2^-800 and 2^1000 at f64, or 2^-80 and 2^120 at f32. In that range no square overflows, and t² times one doesn’t underflow. A NaN part gives false, as IEEE compares it.Source§fn scaled_equal<R: Native>(self, x: Complex<R>, y: Complex<R>) -> bool
fn scaled_equal<R: Native>(self, x: Complex<R>, y: Complex<R>) -> bool
complex_equal from the magnitudes themselves, which norm computes without overflow or underflow, for the pairs that squared_equal leaves undecided.Source§fn complex_floor<R: Native>(self, y: Complex<R>) -> Complex<R>
fn complex_floor<R: Native>(self, y: Complex<R>) -> Complex<R>
McDonnell’s complex floor: the floors of both parts, plus 1 on the part with the larger fraction when the fractions add up to 1.
fn complex_ceil<R: Native>(self, y: Complex<R>) -> Complex<R>
Source§fn complex_residue<R: Native>(self, x: Complex<R>, y: Complex<R>) -> Complex<R>
fn complex_residue<R: Native>(self, x: Complex<R>, y: Complex<R>) -> Complex<R>
y modulo x for complex numbers. A quotient equal to a Gaussian integer leaves no remainder. x = 0 gives y.Source§fn complex_gcd<R: Native>(self, x: Complex<R>, y: Complex<R>) -> Complex<R>
fn complex_gcd<R: Native>(self, x: Complex<R>, y: Complex<R>) -> Complex<R>
The greatest common divisor of
x and y as complex numbers, by Euclid’s algorithm with the quotient rounded to the nearest Gaussian integer. It stops once the remainder is within the tolerance of the larger magnitude, and turns the result into the first quadrant, real part above 0. Two real numbers give gcd. A non-finite argument, or a remainder that stops shrinking, gives NaN.