Struct noisy_float::NoisyFloat
[−]
[src]
#[repr(C)]pub struct NoisyFloat<F: Float, C: FloatChecker<F>> { /* fields omitted */ }
A floating point number with a restricted set of legal values.
Typical users will not need to access this struct directly, but
can instead use the type aliases found in the module noisy_float::types
.
However, this struct together with a FloatChecker
implementation can be used
to define custom behavior.
The underlying float type is F
, usually f32
or f64
.
Valid values for the float are determined by the float checker C
.
If an invalid value would ever be returned from a method on this type,
the method will panic instead, using either assert!
or debug_assert!
as defined by the float checker.
The exception to this rule is for methods that return an Option
containing
a NoisyFloat
, in which case the result would be None
if the value is invalid.
Methods
impl<F: Float, C: FloatChecker<F>> NoisyFloat<F, C>
[src]
fn new(value: F) -> Self
[src]
Constructs a NoisyFloat
with the given value.
Uses the FloatChecker
to assert that the value is valid.
fn try_new(value: F) -> Option<Self>
[src]
Tries to construct a NoisyFloat
with the given value.
Returns None
if the value is invalid.
fn from_f32(value: f32) -> Self
[src]
Constructs a NoisyFloat
with the given f32
value.
May panic not only by the FloatChecker
but also
by unwrapping the result of a NumCast
invocation for type F
,
although the later should not occur in normal situations.
fn from_f64(value: f64) -> Self
[src]
Constructs a NoisyFloat
with the given f64
value.
May panic not only by the FloatChecker
but also
by unwrapping the result of a NumCast
invocation for type F
,
although the later should not occur in normal situations.
fn raw(self) -> F
[src]
Returns the underlying float value.
Trait Implementations
impl<F: Float, C: FloatChecker<F>> Clone for NoisyFloat<F, C>
[src]
fn clone(&self) -> Self
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<F: Float, C: FloatChecker<F>> Copy for NoisyFloat<F, C>
[src]
impl<F: Float, C: FloatChecker<F>> PartialEq<F> for NoisyFloat<F, C>
[src]
fn eq(&self, other: &F) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<F: Float, C: FloatChecker<F>> PartialEq for NoisyFloat<F, C>
[src]
fn eq(&self, other: &Self) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<F: Float, C: FloatChecker<F>> Eq for NoisyFloat<F, C>
[src]
impl<F: Float, C: FloatChecker<F>> PartialOrd<F> for NoisyFloat<F, C>
[src]
fn partial_cmp(&self, other: &F) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &F) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &F) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &F) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &F) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<F: Float, C: FloatChecker<F>> PartialOrd for NoisyFloat<F, C>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Self) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Self) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Self) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Self) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<F: Float, C: FloatChecker<F>> Ord for NoisyFloat<F, C>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.22.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.22.0[src]
Compares and returns the minimum of two values. Read more
impl<F: Float, C: FloatChecker<F>> Add<F> for NoisyFloat<F, C>
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: F) -> Self
[src]
Performs the +
operation.
impl<F: Float, C: FloatChecker<F>> Add for NoisyFloat<F, C>
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self
[src]
Performs the +
operation.
impl<F: Float, C: FloatChecker<F>> Sub<F> for NoisyFloat<F, C>
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: F) -> Self
[src]
Performs the -
operation.
impl<F: Float, C: FloatChecker<F>> Sub for NoisyFloat<F, C>
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: Self) -> Self
[src]
Performs the -
operation.
impl<F: Float, C: FloatChecker<F>> Mul<F> for NoisyFloat<F, C>
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: F) -> Self
[src]
Performs the *
operation.
impl<F: Float, C: FloatChecker<F>> Mul for NoisyFloat<F, C>
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: Self) -> Self
[src]
Performs the *
operation.
impl<F: Float, C: FloatChecker<F>> Div<F> for NoisyFloat<F, C>
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, rhs: F) -> Self
[src]
Performs the /
operation.
impl<F: Float, C: FloatChecker<F>> Div for NoisyFloat<F, C>
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, rhs: Self) -> Self
[src]
Performs the /
operation.
impl<F: Float, C: FloatChecker<F>> Rem<F> for NoisyFloat<F, C>
[src]
type Output = Self
The resulting type after applying the %
operator.
fn rem(self, rhs: F) -> Self
[src]
Performs the %
operation.
impl<F: Float, C: FloatChecker<F>> Rem for NoisyFloat<F, C>
[src]
type Output = Self
The resulting type after applying the %
operator.
fn rem(self, rhs: Self) -> Self
[src]
Performs the %
operation.
impl<F: Float + AddAssign, C: FloatChecker<F>> AddAssign<F> for NoisyFloat<F, C>
[src]
fn add_assign(&mut self, rhs: F)
[src]
Performs the +=
operation.
impl<F: Float + AddAssign, C: FloatChecker<F>> AddAssign for NoisyFloat<F, C>
[src]
fn add_assign(&mut self, rhs: Self)
[src]
Performs the +=
operation.
impl<F: Float + SubAssign, C: FloatChecker<F>> SubAssign<F> for NoisyFloat<F, C>
[src]
fn sub_assign(&mut self, rhs: F)
[src]
Performs the -=
operation.
impl<F: Float + SubAssign, C: FloatChecker<F>> SubAssign for NoisyFloat<F, C>
[src]
fn sub_assign(&mut self, rhs: Self)
[src]
Performs the -=
operation.
impl<F: Float + MulAssign, C: FloatChecker<F>> MulAssign<F> for NoisyFloat<F, C>
[src]
fn mul_assign(&mut self, rhs: F)
[src]
Performs the *=
operation.
impl<F: Float + MulAssign, C: FloatChecker<F>> MulAssign for NoisyFloat<F, C>
[src]
fn mul_assign(&mut self, rhs: Self)
[src]
Performs the *=
operation.
impl<F: Float + DivAssign, C: FloatChecker<F>> DivAssign<F> for NoisyFloat<F, C>
[src]
fn div_assign(&mut self, rhs: F)
[src]
Performs the /=
operation.
impl<F: Float + DivAssign, C: FloatChecker<F>> DivAssign for NoisyFloat<F, C>
[src]
fn div_assign(&mut self, rhs: Self)
[src]
Performs the /=
operation.
impl<F: Float + RemAssign, C: FloatChecker<F>> RemAssign<F> for NoisyFloat<F, C>
[src]
fn rem_assign(&mut self, rhs: F)
[src]
Performs the %=
operation.
impl<F: Float + RemAssign, C: FloatChecker<F>> RemAssign for NoisyFloat<F, C>
[src]
fn rem_assign(&mut self, rhs: Self)
[src]
Performs the %=
operation.
impl<F: Float, C: FloatChecker<F>> Neg for NoisyFloat<F, C>
[src]
type Output = Self
The resulting type after applying the -
operator.
fn neg(self) -> Self
[src]
Performs the unary -
operation.
impl<F: Float, C: FloatChecker<F>> Zero for NoisyFloat<F, C>
[src]
fn zero() -> Self
[src]
Returns the additive identity element of Self
, 0
. Read more
fn is_zero(&self) -> bool
[src]
Returns true
if self
is equal to the additive identity.
impl<F: Float, C: FloatChecker<F>> One for NoisyFloat<F, C>
[src]
impl<F: Float, C: FloatChecker<F>> Num for NoisyFloat<F, C>
[src]
type FromStrRadixErr = F::FromStrRadixErr
fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
[src]
Convert from a string and radix <= 36. Read more
impl<F: Float, C: FloatChecker<F>> ToPrimitive for NoisyFloat<F, C>
[src]
fn to_i64(&self) -> Option<i64>
[src]
Converts the value of self
to an i64
.
fn to_u64(&self) -> Option<u64>
[src]
Converts the value of self
to an u64
.
fn to_isize(&self) -> Option<isize>
[src]
Converts the value of self
to an isize
.
fn to_i8(&self) -> Option<i8>
[src]
Converts the value of self
to an i8
.
fn to_i16(&self) -> Option<i16>
[src]
Converts the value of self
to an i16
.
fn to_i32(&self) -> Option<i32>
[src]
Converts the value of self
to an i32
.
fn to_usize(&self) -> Option<usize>
[src]
Converts the value of self
to a usize
.
fn to_u8(&self) -> Option<u8>
[src]
Converts the value of self
to an u8
.
fn to_u16(&self) -> Option<u16>
[src]
Converts the value of self
to an u16
.
fn to_u32(&self) -> Option<u32>
[src]
Converts the value of self
to an u32
.
fn to_f32(&self) -> Option<f32>
[src]
Converts the value of self
to an f32
.
fn to_f64(&self) -> Option<f64>
[src]
Converts the value of self
to an f64
.
impl<F: Float, C: FloatChecker<F>> NumCast for NoisyFloat<F, C>
[src]
fn from<T: ToPrimitive>(n: T) -> Option<Self>
[src]
Creates a number from another value that can be converted into a primitive via the ToPrimitive
trait. Read more
impl<F: Float, C: FloatChecker<F>> Float for NoisyFloat<F, C>
[src]
fn nan() -> Self
[src]
Returns the NaN
value. Read more
fn infinity() -> Self
[src]
Returns the infinite value. Read more
fn neg_infinity() -> Self
[src]
Returns the negative infinite value. Read more
fn neg_zero() -> Self
[src]
Returns -0.0
. Read more
fn min_value() -> Self
[src]
Returns the smallest finite value that this type can represent. Read more
fn min_positive_value() -> Self
[src]
Returns the smallest positive, normalized value that this type can represent. Read more
fn max_value() -> Self
[src]
Returns the largest finite value that this type can represent. Read more
fn is_nan(self) -> bool
[src]
Returns true
if this value is NaN
and false otherwise. Read more
fn is_infinite(self) -> bool
[src]
Returns true
if this value is positive infinity or negative infinity and false otherwise. Read more
fn is_finite(self) -> bool
[src]
Returns true
if this number is neither infinite nor NaN
. Read more
fn is_normal(self) -> bool
[src]
Returns true
if the number is neither zero, infinite, [subnormal][subnormal], or NaN
. Read more
fn classify(self) -> FpCategory
[src]
Returns the floating point category of the number. If only one property is going to be tested, it is generally faster to use the specific predicate instead. Read more
fn floor(self) -> Self
[src]
Returns the largest integer less than or equal to a number. Read more
fn ceil(self) -> Self
[src]
Returns the smallest integer greater than or equal to a number. Read more
fn round(self) -> Self
[src]
Returns the nearest integer to a number. Round half-way cases away from 0.0
. Read more
fn trunc(self) -> Self
[src]
Return the integer part of a number. Read more
fn fract(self) -> Self
[src]
Returns the fractional part of a number. Read more
fn abs(self) -> Self
[src]
Computes the absolute value of self
. Returns Float::nan()
if the number is Float::nan()
. Read more
fn signum(self) -> Self
[src]
Returns a number that represents the sign of self
. Read more
fn is_sign_positive(self) -> bool
[src]
Returns true
if self
is positive, including +0.0
, Float::infinity()
, and with newer versions of Rust f64::NAN
. Read more
fn is_sign_negative(self) -> bool
[src]
Returns true
if self
is negative, including -0.0
, Float::neg_infinity()
, and with newer versions of Rust -f64::NAN
. Read more
fn mul_add(self, a: Self, b: Self) -> Self
[src]
Fused multiply-add. Computes (self * a) + b
with only one rounding error. This produces a more accurate result with better performance than a separate multiplication operation followed by an add. Read more
fn recip(self) -> Self
[src]
Take the reciprocal (inverse) of a number, 1/x
. Read more
fn powi(self, n: i32) -> Self
[src]
Raise a number to an integer power. Read more
fn powf(self, n: Self) -> Self
[src]
Raise a number to a floating point power. Read more
fn sqrt(self) -> Self
[src]
Take the square root of a number. Read more
fn exp(self) -> Self
[src]
Returns e^(self)
, (the exponential function). Read more
fn exp2(self) -> Self
[src]
Returns 2^(self)
. Read more
fn ln(self) -> Self
[src]
Returns the natural logarithm of the number. Read more
fn log(self, base: Self) -> Self
[src]
Returns the logarithm of the number with respect to an arbitrary base. Read more
fn log2(self) -> Self
[src]
Returns the base 2 logarithm of the number. Read more
fn log10(self) -> Self
[src]
Returns the base 10 logarithm of the number. Read more
fn max(self, other: Self) -> Self
[src]
Returns the maximum of the two numbers. Read more
fn min(self, other: Self) -> Self
[src]
Returns the minimum of the two numbers. Read more
fn abs_sub(self, other: Self) -> Self
[src]
The positive difference of two numbers. Read more
fn cbrt(self) -> Self
[src]
Take the cubic root of a number. Read more
fn hypot(self, other: Self) -> Self
[src]
Calculate the length of the hypotenuse of a right-angle triangle given legs of length x
and y
. Read more
fn sin(self) -> Self
[src]
Computes the sine of a number (in radians). Read more
fn cos(self) -> Self
[src]
Computes the cosine of a number (in radians). Read more
fn tan(self) -> Self
[src]
Computes the tangent of a number (in radians). Read more
fn asin(self) -> Self
[src]
Computes the arcsine of a number. Return value is in radians in the range [-pi/2, pi/2] or NaN if the number is outside the range [-1, 1]. Read more
fn acos(self) -> Self
[src]
Computes the arccosine of a number. Return value is in radians in the range [0, pi] or NaN if the number is outside the range [-1, 1]. Read more
fn atan(self) -> Self
[src]
Computes the arctangent of a number. Return value is in radians in the range [-pi/2, pi/2]; Read more
fn atan2(self, other: Self) -> Self
[src]
Computes the four quadrant arctangent of self
(y
) and other
(x
). Read more
fn sin_cos(self) -> (Self, Self)
[src]
Simultaneously computes the sine and cosine of the number, x
. Returns (sin(x), cos(x))
. Read more
fn exp_m1(self) -> Self
[src]
Returns e^(self) - 1
in a way that is accurate even if the number is close to zero. Read more
fn ln_1p(self) -> Self
[src]
Returns ln(1+n)
(natural logarithm) more accurately than if the operations were performed separately. Read more
fn sinh(self) -> Self
[src]
Hyperbolic sine function. Read more
fn cosh(self) -> Self
[src]
Hyperbolic cosine function. Read more
fn tanh(self) -> Self
[src]
Hyperbolic tangent function. Read more
fn asinh(self) -> Self
[src]
Inverse hyperbolic sine function. Read more
fn acosh(self) -> Self
[src]
Inverse hyperbolic cosine function. Read more
fn atanh(self) -> Self
[src]
Inverse hyperbolic tangent function. Read more
fn integer_decode(self) -> (u64, i16, i8)
[src]
Returns the mantissa, base 2 exponent, and sign as integers, respectively. The original number can be recovered by sign * mantissa * 2 ^ exponent
. The floating point encoding is documented in the [Reference][floating-point]. Read more
fn to_degrees(self) -> Self
[src]
Converts radians to degrees. Read more
fn to_radians(self) -> Self
[src]
Converts degrees to radians. Read more
fn epsilon() -> Self
[src]
Returns epsilon, a small positive value. Read more
impl<F: Float + FloatConst, C: FloatChecker<F>> FloatConst for NoisyFloat<F, C>
[src]
fn E() -> Self
[src]
Return Euler’s number.
fn FRAC_1_PI() -> Self
[src]
Return 1.0 / π
.
fn FRAC_1_SQRT_2() -> Self
[src]
Return 1.0 / sqrt(2.0)
.
fn FRAC_2_PI() -> Self
[src]
Return 2.0 / π
.
fn FRAC_2_SQRT_PI() -> Self
[src]
Return 2.0 / sqrt(π)
.
fn FRAC_PI_2() -> Self
[src]
Return π / 2.0
.
fn FRAC_PI_3() -> Self
[src]
Return π / 3.0
.
fn FRAC_PI_4() -> Self
[src]
Return π / 4.0
.
fn FRAC_PI_6() -> Self
[src]
Return π / 6.0
.
fn FRAC_PI_8() -> Self
[src]
Return π / 8.0
.
fn LN_10() -> Self
[src]
Return ln(10.0)
.
fn LN_2() -> Self
[src]
Return ln(2.0)
.
fn LOG10_E() -> Self
[src]
Return log10(e)
.
fn LOG2_E() -> Self
[src]
Return log2(e)
.
fn PI() -> Self
[src]
Return Archimedes’ constant.
fn SQRT_2() -> Self
[src]
Return sqrt(2.0)
.
impl<F: Float, C: FloatChecker<F>> Sum for NoisyFloat<F, C>
[src]
fn sum<I>(iter: I) -> Self where
I: Iterator<Item = Self>,
[src]
I: Iterator<Item = Self>,
Method which takes an iterator and generates Self
from the elements by "summing up" the items. Read more
impl<F: Float, C: FloatChecker<F>> Product for NoisyFloat<F, C>
[src]
fn product<I>(iter: I) -> Self where
I: Iterator<Item = Self>,
[src]
I: Iterator<Item = Self>,
Method which takes an iterator and generates Self
from the elements by multiplying the items. Read more
impl<F: Float> From<NoisyFloat<F, FiniteChecker>> for NoisyFloat<F, NumChecker>
[src]
fn from(value: NoisyFloat<F, FiniteChecker>) -> Self
[src]
Performs the conversion.
impl<F: Float + Default, C: FloatChecker<F>> Default for NoisyFloat<F, C>
[src]
impl<F: Float + Debug, C: FloatChecker<F>> Debug for NoisyFloat<F, C>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter.
impl<F: Float + Display, C: FloatChecker<F>> Display for NoisyFloat<F, C>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter. Read more
impl<F: Float + LowerExp, C: FloatChecker<F>> LowerExp for NoisyFloat<F, C>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter.