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>
impl<T: Float> RealImpl<T>
Sourcepub fn acos(self) -> Self
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].
Sourcepub fn asin(self) -> Self
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].
Sourcepub fn atan(self) -> Self
pub fn atan(self) -> Self
Computes the arctangent of a number.
Return value is in radians in the range [-pi/2, pi/2];
Sourcepub fn atan2(y: Self, x: Self) -> Self
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:0x >= 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)
Sourcepub fn div_euclid(self, other: Self) -> Self
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.
Sourcepub fn log(self, base: Self) -> Self
pub fn log(self, base: Self) -> Self
Returns the logarithm of the number with respect to an arbitrary base.
Sourcepub fn rem_euclid(self, other: Self) -> Self
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.
Sourcepub fn round(self) -> Self
pub fn round(self) -> Self
Returns the nearest integer to self.
Round half-way cases away from 0.0.
Sourcepub fn signum(self) -> Self
pub fn signum(self) -> Self
Returns a number that represents the sign of self.
1.0if the number is positive,+0.0orINFINITY-1.0if the number is negative,-0.0orNEG_INFINITY- NaN if the number is NaN
Sourcepub fn sin_cos(self) -> (Self, Self)
pub fn sin_cos(self) -> (Self, Self)
Simultaneously computes the sine and cosine of the number, x.
Returns (sin(x), cos(x)).
Trait Implementations§
Source§impl<T: Float> AddAssign for RealImpl<T>
impl<T: Float> AddAssign for RealImpl<T>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl<'de> Deserialize<'de> for RealImpl<f32>
impl<'de> Deserialize<'de> for RealImpl<f32>
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for RealImpl<f64>
impl<'de> Deserialize<'de> for RealImpl<f64>
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<T: Float> DivAssign for RealImpl<T>
impl<T: Float> DivAssign for RealImpl<T>
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/= operation. Read moreSource§impl<T: Float> MulAssign for RealImpl<T>
impl<T: Float> MulAssign for RealImpl<T>
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*= operation. Read moreSource§impl<T: Float> Ord for RealImpl<T>
impl<T: Float> Ord for RealImpl<T>
Source§impl<T: Float> PartialOrd for RealImpl<T>
impl<T: Float> PartialOrd for RealImpl<T>
Source§impl<T: Float> Real for RealImpl<T>
impl<T: Float> Real for RealImpl<T>
Source§fn div_euclid(self, other: Self) -> Self
fn div_euclid(self, other: Self) -> Self
Source§fn log(self, base: Self) -> Self
fn log(self, base: Self) -> Self
Source§fn rem_euclid(self, other: Self) -> Self
fn rem_euclid(self, other: Self) -> Self
self (mod rhs). Read moreSource§fn round(self) -> Self
fn round(self) -> Self
self.
Round half-way cases away from 0.0.Source§impl<T: Float + SampleUniform> SampleUniform for RealImpl<T>
impl<T: Float + SampleUniform> SampleUniform for RealImpl<T>
Source§type Sampler = UniformReal<T>
type Sampler = UniformReal<T>
UniformSampler implementation supporting type X.Source§impl<T: Float> SubAssign for RealImpl<T>
impl<T: Float> SubAssign for RealImpl<T>
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read moreimpl<T: Copy + Float> Copy for RealImpl<T>
impl<T: Float> Eq for RealImpl<T>
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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Float for Twhere
T: Real,
impl<T> Float for Twhere
T: Real,
Source§fn div_euclid(self, other: T) -> T
fn div_euclid(self, other: T) -> T
Source§fn log(self, base: T) -> T
fn log(self, base: T) -> T
Source§fn rem_euclid(self, other: T) -> T
fn rem_euclid(self, other: T) -> T
self (mod rhs). Read moreSource§impl<Borrowed> SampleBorrow<Borrowed> for Borrowedwhere
Borrowed: SampleUniform,
impl<Borrowed> SampleBorrow<Borrowed> for Borrowedwhere
Borrowed: SampleUniform,
Source§fn borrow(&self) -> &Borrowed
fn borrow(&self) -> &Borrowed
Borrow::borrow