RealImpl

Struct RealImpl 

Source
pub struct RealImpl<T: Float>(/* private fields */);
Expand description

Wrapper around T that checks for valid values (panics on NaN/Inf)

Implementations§

Source§

impl<T: Float> RealImpl<T>

Source

pub fn new(value: T) -> Self

Create a new value, panics if not finite

Source

pub fn new_unchecked(value: T) -> Self

Create a new value without checking

Source

pub fn raw(self) -> T

Get raw value

Source§

impl<T: Float> RealImpl<T>

Source

pub const PI: Self = <Self as Real>::PI

Archimedes’ constant (π)

Source

pub fn acos(self) -> Self

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].

Source

pub fn asin(self) -> Self

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].

Source

pub fn atan(self) -> Self

Computes the arctangent of a number.

Return value is in radians in the range [-pi/2, pi/2];

Source

pub fn atan2(y: Self, x: Self) -> Self

Computes the four quadrant arctangent of self (y) and other (x) in radians.

  • x = 0, y = 0: 0
  • x >= 0: arctan(y/x) -> [-pi/2, pi/2]
  • y >= 0: arctan(y/x) + pi -> (pi/2, pi]
  • y < 0: arctan(y/x) - pi -> (-pi, -pi/2)
Source

pub fn ceil(self) -> Self

Returns the smallest integer greater than or equal to a number.

Source

pub fn cos(self) -> Self

Computes the cosine of a number (in radians).

Source

pub fn div_euclid(self, other: Self) -> Self

Calculates Euclidean division, the matching method for rem_euclid.

This computes the integer n such that self = n * rhs + self.rem_euclid(rhs). In other words, the result is self / rhs rounded to the integer n such that self >= n * rhs.

Source

pub fn exp(self) -> Self

Returns e^(self), (the exponential function).

Source

pub fn floor(self) -> Self

Returns the largest integer less than or equal to self.

Source

pub fn fract(self) -> Self

Returns the fractional part of self.

Source

pub fn ln(self) -> Self

Returns the natural logarithm of the number.

Source

pub fn log(self, base: Self) -> Self

Returns the logarithm of the number with respect to an arbitrary base.

Source

pub fn log10(self) -> Self

Returns the base 10 logarithm of the number.

Source

pub fn log2(self) -> Self

Returns the base 2 logarithm of the number.

Source

pub fn powf(self, n: Self) -> Self

Raises a number to a floating point power.

Source

pub fn powi(self, n: i32) -> Self

Raises a number to an integer power.

Source

pub fn recip(self) -> Self

Takes the reciprocal (inverse) of a number, 1/x

Source

pub fn rem_euclid(self, other: Self) -> Self

Calculates the least nonnegative remainder of self (mod rhs).

In particular, the return value r satisfies 0.0 <= r < rhs.abs() in most cases. However, due to a floating point round-off error it can result in r == rhs.abs(), violating the mathematical definition, if self is much smaller than rhs.abs() in magnitude and self < 0.0. This result is not an element of the function’s codomain, but it is the closest floating point number in the real numbers and thus fulfills the property self == self.div_euclid(rhs) * rhs + self.rem_euclid(rhs) approximately.

Source

pub fn round(self) -> Self

Returns the nearest integer to self. Round half-way cases away from 0.0.

Source

pub fn signum(self) -> Self

Returns a number that represents the sign of self.

  • 1.0 if the number is positive, +0.0 or INFINITY
  • -1.0 if the number is negative, -0.0 or NEG_INFINITY
  • NaN if the number is NaN
Source

pub fn sin(self) -> Self

Computes the sine of a number (in radians).

Source

pub fn sin_cos(self) -> (Self, Self)

Simultaneously computes the sine and cosine of the number, x. Returns (sin(x), cos(x)).

Source

pub fn sqrt(self) -> Self

Returns the square root of a number.

Returns NaN if self is a negative number other than -0.0.

Source

pub fn tan(self) -> Self

Computes the tangent of a number (in radians).

Source

pub fn from_f32(x: f32) -> Self

Convert an f32 into Self

Source

pub fn as_f32(self) -> f32

Convert self into an f32

Trait Implementations§

Source§

impl<T: Float> Add for RealImpl<T>

Source§

type Output = RealImpl<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
Source§

impl<T: Float> AddAssign for RealImpl<T>

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<T: Clone + Float> Clone for RealImpl<T>

Source§

fn clone(&self) -> RealImpl<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Float> Debug for RealImpl<T>

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for RealImpl<f32>

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'de> Deserialize<'de> for RealImpl<f64>

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: Float> Display for RealImpl<T>

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Float> Div for RealImpl<T>

Source§

type Output = RealImpl<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self

Performs the / operation. Read more
Source§

impl<T: Float> DivAssign for RealImpl<T>

Source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
Source§

impl<T: Float> Mul for RealImpl<T>

Source§

type Output = RealImpl<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
Source§

impl<T: Float> MulAssign for RealImpl<T>

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl<T: Float> Neg for RealImpl<T>

Source§

type Output = RealImpl<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<T: Float> Num for RealImpl<T>

Source§

fn signum(self) -> Self

Returns a number representing sign of self.
Source§

fn abs(self) -> Self

Calculate absolute value
Source§

impl<T: Float> Ord for RealImpl<T>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq + Float> PartialEq for RealImpl<T>

Source§

fn eq(&self, other: &RealImpl<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Float> PartialOrd for RealImpl<T>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: Float> Real for RealImpl<T>

Source§

const PI: Self

Archimedes’ constant (π)
Source§

fn acos(self) -> Self

Computes the arccosine of a number. Read more
Source§

fn asin(self) -> Self

Computes the arcsine of a number. Read more
Source§

fn atan(self) -> Self

Computes the arctangent of a number. Read more
Source§

fn atan2(y: Self, x: Self) -> Self

Computes the four quadrant arctangent of self (y) and other (x) in radians. Read more
Source§

fn ceil(self) -> Self

Returns the smallest integer greater than or equal to a number.
Source§

fn cos(self) -> Self

Computes the cosine of a number (in radians).
Source§

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

Calculates Euclidean division, the matching method for rem_euclid. Read more
Source§

fn exp(self) -> Self

Returns e^(self), (the exponential function).
Source§

fn floor(self) -> Self

Returns the largest integer less than or equal to self.
Source§

fn fract(self) -> Self

Returns the fractional part of self.
Source§

fn ln(self) -> Self

Returns the natural logarithm of the number.
Source§

fn log(self, base: Self) -> Self

Returns the logarithm of the number with respect to an arbitrary base.
Source§

fn log10(self) -> Self

Returns the base 10 logarithm of the number.
Source§

fn log2(self) -> Self

Returns the base 2 logarithm of the number.
Source§

fn powf(self, n: Self) -> Self

Raises a number to a floating point power.
Source§

fn powi(self, n: i32) -> Self

Raises a number to an integer power.
Source§

fn recip(self) -> Self

Takes the reciprocal (inverse) of a number, 1/x
Source§

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

Calculates the least nonnegative remainder of self (mod rhs). Read more
Source§

fn round(self) -> Self

Returns the nearest integer to self. Round half-way cases away from 0.0.
Source§

fn sin(self) -> Self

Computes the sine of a number (in radians).
Source§

fn sin_cos(self) -> (Self, Self)

Simultaneously computes the sine and cosine of the number, x. Returns (sin(x), cos(x)).
Source§

fn sqrt(self) -> Self

Returns the square root of a number. Read more
Source§

fn tan(self) -> Self

Computes the tangent of a number (in radians).
Source§

fn from_f32(x: f32) -> Self

Convert an f32 into Self
Source§

fn as_f32(self) -> f32

Convert self into an f32
Source§

impl<T: Float + SampleUniform> SampleUniform for RealImpl<T>

Source§

type Sampler = UniformReal<T>

The UniformSampler implementation supporting type X.
Source§

impl<T> Serialize for RealImpl<T>
where T: Serialize + Float,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: Float> Sub for RealImpl<T>

Source§

type Output = RealImpl<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more
Source§

impl<T: Float> SubAssign for RealImpl<T>

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl TryFrom<f32> for RealImpl<f32>

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: f32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<f64> for RealImpl<f64>

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: f64) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T: Float> UNum for RealImpl<T>

Source§

const ZERO: Self

Additive identity
Source§

const ONE: Self

Multiplicative identity
Source§

fn sqr(self) -> Self

Calculate squared value (self * self)
Source§

impl<T: Copy + Float> Copy for RealImpl<T>

Source§

impl<T: Float> Eq for RealImpl<T>

Source§

impl<T: Float> StructuralPartialEq for RealImpl<T>

Auto Trait Implementations§

§

impl<T> Freeze for RealImpl<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for RealImpl<T>
where T: RefUnwindSafe,

§

impl<T> Send for RealImpl<T>
where T: Send,

§

impl<T> Sync for RealImpl<T>
where T: Sync,

§

impl<T> Unpin for RealImpl<T>
where T: Unpin,

§

impl<T> UnwindSafe for RealImpl<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Float for T
where T: Real,

Source§

const PI: T = const PI: Self = <Self as Real>::PI;

Archimedes’ constant (π)
Source§

fn acos(self) -> T

Computes the arccosine of a number. Read more
Source§

fn asin(self) -> T

Computes the arcsine of a number. Read more
Source§

fn atan(self) -> T

Computes the arctangent of a number. Read more
Source§

fn atan2(y: T, x: T) -> T

Computes the four quadrant arctangent of self (y) and other (x) in radians. Read more
Source§

fn ceil(self) -> T

Returns the smallest integer greater than or equal to a number.
Source§

fn cos(self) -> T

Computes the cosine of a number (in radians).
Source§

fn div_euclid(self, other: T) -> T

Calculates Euclidean division, the matching method for rem_euclid. Read more
Source§

fn exp(self) -> T

Returns e^(self), (the exponential function).
Source§

fn floor(self) -> T

Returns the largest integer less than or equal to self.
Source§

fn fract(self) -> T

Returns the fractional part of self.
Source§

fn ln(self) -> T

Returns the natural logarithm of the number.
Source§

fn log(self, base: T) -> T

Returns the logarithm of the number with respect to an arbitrary base.
Source§

fn log10(self) -> T

Returns the base 10 logarithm of the number.
Source§

fn log2(self) -> T

Returns the base 2 logarithm of the number.
Source§

fn powf(self, n: T) -> T

Raises a number to a floating point power.
Source§

fn powi(self, n: i32) -> T

Raises a number to an integer power.
Source§

fn recip(self) -> T

Takes the reciprocal (inverse) of a number, 1/x
Source§

fn rem_euclid(self, other: T) -> T

Calculates the least nonnegative remainder of self (mod rhs). Read more
Source§

fn round(self) -> T

Returns the nearest integer to self. Round half-way cases away from 0.0.
Source§

fn sin(self) -> T

Computes the sine of a number (in radians).
Source§

fn sin_cos(self) -> (T, T)

Simultaneously computes the sine and cosine of the number, x. Returns (sin(x), cos(x)).
Source§

fn sqrt(self) -> T

Returns the square root of a number. Read more
Source§

fn tan(self) -> T

Computes the tangent of a number (in radians).
Source§

fn from_f32(x: f32) -> T

Convert an f32 into Self
Source§

fn as_f32(self) -> f32

Convert self into an f32
Source§

fn is_finite(self) -> bool

Returns true if this number is neither infinite nor NaN.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<Borrowed> SampleBorrow<Borrowed> for Borrowed
where Borrowed: SampleUniform,

Source§

fn borrow(&self) -> &Borrowed

Immutably borrows from an owned value. See Borrow::borrow
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,