pub struct RealImpl<T>(/* private fields */)
where
T: Float;
Expand description
Wrapper around T that checks for valid values (panics on NaN/Inf)
Implementations§
§impl<T> RealImpl<T>where
T: Float,
impl<T> RealImpl<T>where
T: Float,
pub fn new_unchecked(value: T) -> RealImpl<T>
pub fn new_unchecked(value: T) -> RealImpl<T>
Create a new value without checking
pub fn raw(self) -> T
pub fn raw(self) -> T
Get raw value
§impl<T> RealImpl<T>where
T: Float,
impl<T> RealImpl<T>where
T: Float,
pub fn acos(self) -> RealImpl<T>
pub fn acos(self) -> RealImpl<T>
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].
pub fn asin(self) -> RealImpl<T>
pub fn asin(self) -> RealImpl<T>
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].
pub fn atan(self) -> RealImpl<T>
pub fn atan(self) -> RealImpl<T>
Computes the arctangent of a number.
Return value is in radians in the range [-pi/2, pi/2];
pub fn atan2(y: RealImpl<T>, x: RealImpl<T>) -> RealImpl<T>
pub fn atan2(y: RealImpl<T>, x: RealImpl<T>) -> RealImpl<T>
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)
pub fn div_euclid(self, other: RealImpl<T>) -> RealImpl<T>
pub fn div_euclid(self, other: RealImpl<T>) -> RealImpl<T>
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.
pub fn log(self, base: RealImpl<T>) -> RealImpl<T>
pub fn log(self, base: RealImpl<T>) -> RealImpl<T>
Returns the logarithm of the number with respect to an arbitrary base.
pub fn rem_euclid(self, other: RealImpl<T>) -> RealImpl<T>
pub fn rem_euclid(self, other: RealImpl<T>) -> RealImpl<T>
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.
pub fn round(self) -> RealImpl<T>
pub fn round(self) -> RealImpl<T>
Returns the nearest integer to self
.
Round half-way cases away from 0.0
.
pub fn signum(self) -> RealImpl<T>
pub fn signum(self) -> RealImpl<T>
Returns a number that represents the sign of self
.
1.0
if the number is positive,+0.0
orINFINITY
-1.0
if the number is negative,-0.0
orNEG_INFINITY
- NaN if the number is NaN
pub fn sin_cos(self) -> (RealImpl<T>, RealImpl<T>)
pub fn sin_cos(self) -> (RealImpl<T>, RealImpl<T>)
Simultaneously computes the sine and cosine of the number, x
.
Returns (sin(x), cos(x))
.
Trait Implementations§
§impl<T> AddAssign for RealImpl<T>where
T: Float,
impl<T> AddAssign for RealImpl<T>where
T: Float,
§fn add_assign(&mut self, rhs: RealImpl<T>)
fn add_assign(&mut self, rhs: RealImpl<T>)
+=
operation. Read more§impl<'de> Deserialize<'de> for RealImpl<f32>
impl<'de> Deserialize<'de> for RealImpl<f32>
§fn deserialize<D>(
deserializer: D
) -> Result<RealImpl<f32>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<RealImpl<f32>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl<'de> Deserialize<'de> for RealImpl<f64>
impl<'de> Deserialize<'de> for RealImpl<f64>
§fn deserialize<D>(
deserializer: D
) -> Result<RealImpl<f64>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<RealImpl<f64>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl<T> DivAssign for RealImpl<T>where
T: Float,
impl<T> DivAssign for RealImpl<T>where
T: Float,
§fn div_assign(&mut self, rhs: RealImpl<T>)
fn div_assign(&mut self, rhs: RealImpl<T>)
/=
operation. Read more§impl<T> MulAssign for RealImpl<T>where
T: Float,
impl<T> MulAssign for RealImpl<T>where
T: Float,
§fn mul_assign(&mut self, rhs: RealImpl<T>)
fn mul_assign(&mut self, rhs: RealImpl<T>)
*=
operation. Read more§impl<T> Ord for RealImpl<T>where
T: Float,
impl<T> Ord for RealImpl<T>where
T: Float,
§impl<T> PartialEq for RealImpl<T>
impl<T> PartialEq for RealImpl<T>
§impl<T> PartialOrd for RealImpl<T>where
T: Float,
impl<T> PartialOrd for RealImpl<T>where
T: Float,
§fn partial_cmp(&self, other: &RealImpl<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &RealImpl<T>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more§impl<T> Real for RealImpl<T>where
T: Float,
impl<T> Real for RealImpl<T>where
T: Float,
§fn div_euclid(self, other: RealImpl<T>) -> RealImpl<T>
fn div_euclid(self, other: RealImpl<T>) -> RealImpl<T>
§fn log(self, base: RealImpl<T>) -> RealImpl<T>
fn log(self, base: RealImpl<T>) -> RealImpl<T>
§fn rem_euclid(self, other: RealImpl<T>) -> RealImpl<T>
fn rem_euclid(self, other: RealImpl<T>) -> RealImpl<T>
self (mod rhs)
. Read more§fn round(self) -> RealImpl<T>
fn round(self) -> RealImpl<T>
self
.
Round half-way cases away from 0.0
.§impl<T> SampleUniform for RealImpl<T>where
T: Float + SampleUniform,
impl<T> SampleUniform for RealImpl<T>where
T: Float + SampleUniform,
§type Sampler = UniformReal<T>
type Sampler = UniformReal<T>
UniformSampler
implementation supporting type X
.§impl<T> Serialize for RealImpl<T>
impl<T> Serialize for RealImpl<T>
§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
§impl<T> SubAssign for RealImpl<T>where
T: Float,
impl<T> SubAssign for RealImpl<T>where
T: Float,
§fn sub_assign(&mut self, rhs: RealImpl<T>)
fn sub_assign(&mut self, rhs: RealImpl<T>)
-=
operation. Read moreimpl<T> Copy for RealImpl<T>
impl<T> Eq for RealImpl<T>where
T: Float,
impl<T> StructuralPartialEq for RealImpl<T>where
T: Float,
Auto Trait Implementations§
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§
§impl<T> Approx for Twhere
T: Float,
impl<T> Approx for Twhere
T: Float,
§fn approx_distance_to(&self, other: &T) -> f32
fn approx_distance_to(&self, other: &T) -> f32
§fn approx_eq(&self, other: &Self) -> bool
fn approx_eq(&self, other: &Self) -> bool
§fn approx_eq_eps(&self, other: &Self, eps: f32) -> bool
fn approx_eq_eps(&self, other: &Self, eps: f32) -> bool
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
§impl<T> Clamp for Twhere
T: PartialOrd,
impl<T> Clamp for Twhere
T: PartialOrd,
§fn clamp_range(self, range: impl FixedRangeBounds<Self>) -> Selfwhere
Self: Clone,
fn clamp_range(self, range: impl FixedRangeBounds<Self>) -> Selfwhere
Self: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> CompatExt for T
impl<T> CompatExt for T
source§impl<T> Configurable for T
impl<T> Configurable for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Float for Twhere
T: Real,
impl<T> Float for Twhere
T: Real,
§fn div_euclid(self, other: T) -> T
fn div_euclid(self, other: T) -> T
§fn rem_euclid(self, other: T) -> T
fn rem_euclid(self, other: T) -> T
self (mod rhs)
. Read more§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
source§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