Struct geng::prelude::RealImpl

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,

pub fn new(value: T) -> RealImpl<T>

Create a new value, panics if not finite

pub fn new_unchecked(value: T) -> RealImpl<T>

Create a new value without checking

pub fn raw(self) -> T

Get raw value

§

impl<T> RealImpl<T>
where T: Float,

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

Archimedes’ constant (π)

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>

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>

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>

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 ceil(self) -> RealImpl<T>

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

pub fn cos(self) -> RealImpl<T>

Computes the cosine of a number (in radians).

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 exp(self) -> RealImpl<T>

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

pub fn floor(self) -> RealImpl<T>

Returns the largest integer less than or equal to self.

pub fn fract(self) -> RealImpl<T>

Returns the fractional part of self.

pub fn ln(self) -> RealImpl<T>

Returns the natural logarithm of the number.

pub fn log(self, base: RealImpl<T>) -> RealImpl<T>

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

pub fn log10(self) -> RealImpl<T>

Returns the base 10 logarithm of the number.

pub fn log2(self) -> RealImpl<T>

Returns the base 2 logarithm of the number.

pub fn powf(self, n: RealImpl<T>) -> RealImpl<T>

Raises a number to a floating point power.

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

Raises a number to an integer power.

pub fn recip(self) -> RealImpl<T>

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

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>

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

pub fn signum(self) -> RealImpl<T>

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

pub fn sin(self) -> RealImpl<T>

Computes the sine of a number (in radians).

pub fn sin_cos(self) -> (RealImpl<T>, RealImpl<T>)

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

pub fn sqrt(self) -> RealImpl<T>

Returns the square root of a number.

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

pub fn tan(self) -> RealImpl<T>

Computes the tangent of a number (in radians).

pub fn from_f32(x: f32) -> RealImpl<T>

Convert an f32 into Self

pub fn as_f32(self) -> f32

Convert self into an f32

Trait Implementations§

§

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

§

type Output = RealImpl<T>

The resulting type after applying the + operator.
§

fn add(self, rhs: RealImpl<T>) -> RealImpl<T>

Performs the + operation. Read more
§

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

§

fn add_assign(&mut self, rhs: RealImpl<T>)

Performs the += operation. Read more
§

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

§

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

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
§

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

§

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

Formats the value using the given formatter. Read more
§

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

§

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

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

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

§

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

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

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

§

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

Formats the value using the given formatter. Read more
§

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

§

type Output = RealImpl<T>

The resulting type after applying the / operator.
§

fn div(self, rhs: RealImpl<T>) -> RealImpl<T>

Performs the / operation. Read more
§

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

§

fn div_assign(&mut self, rhs: RealImpl<T>)

Performs the /= operation. Read more
§

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

§

type Output = RealImpl<T>

The resulting type after applying the * operator.
§

fn mul(self, rhs: RealImpl<T>) -> RealImpl<T>

Performs the * operation. Read more
§

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

§

fn mul_assign(&mut self, rhs: RealImpl<T>)

Performs the *= operation. Read more
§

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

§

type Output = RealImpl<T>

The resulting type after applying the - operator.
§

fn neg(self) -> RealImpl<T>

Performs the unary - operation. Read more
§

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

§

fn signum(self) -> RealImpl<T>

Returns a number representing sign of self.
§

fn abs(self) -> Self

Calculate absolute value
§

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

§

fn cmp(&self, other: &RealImpl<T>) -> 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 + PartialOrd,

Restrict a value to a certain interval. Read more
§

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

§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

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

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

§

fn partial_cmp(&self, other: &RealImpl<T>) -> 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

This method 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

This method 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

This method 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

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

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

§

const PI: RealImpl<T> = _

Archimedes’ constant (π)
§

fn acos(self) -> RealImpl<T>

Computes the arccosine of a number. Read more
§

fn asin(self) -> RealImpl<T>

Computes the arcsine of a number. Read more
§

fn atan(self) -> RealImpl<T>

Computes the arctangent of a number. Read more
§

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

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

fn ceil(self) -> RealImpl<T>

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

fn cos(self) -> RealImpl<T>

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

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

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

fn exp(self) -> RealImpl<T>

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

fn floor(self) -> RealImpl<T>

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

fn fract(self) -> RealImpl<T>

Returns the fractional part of self.
§

fn ln(self) -> RealImpl<T>

Returns the natural logarithm of the number.
§

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

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

fn log10(self) -> RealImpl<T>

Returns the base 10 logarithm of the number.
§

fn log2(self) -> RealImpl<T>

Returns the base 2 logarithm of the number.
§

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

Raises a number to a floating point power.
§

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

Raises a number to an integer power.
§

fn recip(self) -> RealImpl<T>

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

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

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

fn round(self) -> RealImpl<T>

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

fn sin(self) -> RealImpl<T>

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

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

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

fn sqrt(self) -> RealImpl<T>

Returns the square root of a number. Read more
§

fn tan(self) -> RealImpl<T>

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

fn from_f32(x: f32) -> RealImpl<T>

Convert an f32 into Self
§

fn as_f32(self) -> f32

Convert self into an f32
§

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

§

type Sampler = UniformReal<T>

The UniformSampler implementation supporting type X.
§

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

§

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

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

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

§

type Output = RealImpl<T>

The resulting type after applying the - operator.
§

fn sub(self, rhs: RealImpl<T>) -> RealImpl<T>

Performs the - operation. Read more
§

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

§

fn sub_assign(&mut self, rhs: RealImpl<T>)

Performs the -= operation. Read more
§

impl TryFrom<f32> for RealImpl<f32>

§

type Error = &'static str

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

fn try_from( value: f32 ) -> Result<RealImpl<f32>, <RealImpl<f32> as TryFrom<f32>>::Error>

Performs the conversion.
§

impl TryFrom<f64> for RealImpl<f64>

§

type Error = &'static str

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

fn try_from( value: f64 ) -> Result<RealImpl<f64>, <RealImpl<f64> as TryFrom<f64>>::Error>

Performs the conversion.
§

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

§

const ZERO: RealImpl<T> = _

Additive identity
§

const ONE: RealImpl<T> = _

Multiplicative identity
§

fn sqr(self) -> Self

Calculate squared value (self * self)
§

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

§

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§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn approx_distance_to(&self, other: &T) -> f32

Get an approximated distance between two values
§

fn approx_eq(&self, other: &Self) -> bool

Check if values are approximately equal using DEFAULT_EPS
§

fn approx_eq_eps(&self, other: &Self, eps: f32) -> bool

Check if values are approximately equal using supplied eps value
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
§

impl<T> Clamp for T
where T: PartialOrd,

§

fn clamp_range(self, range: impl FixedRangeBounds<Self>) -> Self
where Self: Clone,

Clamps a value in range. Read more
§

fn clamp_abs(self, max: Self) -> Self
where Self: Neg<Output = Self> + Copy,

Clamp the absolute value. Same as self.clamp_range(-max..=max)
§

fn clamp_max(self, max: Self) -> Self

Clamp by maximum value Read more
§

fn clamp_min(self, min: Self) -> Self

Clamp by minimum value Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
source§

impl<T> Configurable for T
where T: ToString + Clone,

§

type Config = ShowValue<T>

source§

fn config(theme: &Rc<Theme>, value: T) -> ShowValue<T>

§

impl<T> Diff for T
where T: Debug + Serialize + DeserializeOwned + Sync + Send + Copy + PartialEq + 'static + Unpin,

§

type Delta = T

Object representing the difference between two states of Self
§

fn diff(&self, to: &T) -> T

Calculate the difference between two states
§

fn update(&mut self, new_value: &T)

Update the state using the delta Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

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

source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

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

§

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

Archimedes’ constant (π)
§

fn acos(self) -> T

Computes the arccosine of a number. Read more
§

fn asin(self) -> T

Computes the arcsine of a number. Read more
§

fn atan(self) -> T

Computes the arctangent of a number. Read more
§

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

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

fn ceil(self) -> T

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

fn cos(self) -> T

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

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

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

fn exp(self) -> T

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

fn floor(self) -> T

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

fn fract(self) -> T

Returns the fractional part of self.
§

fn ln(self) -> T

Returns the natural logarithm of the number.
§

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

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

fn log10(self) -> T

Returns the base 10 logarithm of the number.
§

fn log2(self) -> T

Returns the base 2 logarithm of the number.
§

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

Raises a number to a floating point power.
§

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

Raises a number to an integer power.
§

fn recip(self) -> T

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

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

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

fn round(self) -> T

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

fn sin(self) -> T

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

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

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

fn sqrt(self) -> T

Returns the square root of a number. Read more
§

fn tan(self) -> T

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

fn from_f32(x: f32) -> T

Convert an f32 into Self
§

fn as_f32(self) -> f32

Convert self into an f32
§

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.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
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,

§

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
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

source§

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

source§

default 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>,

§

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>,

§

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

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

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

§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

source§

impl<T> Message for T
where T: Debug + Serialize + for<'de> Deserialize<'de> + Send + 'static + Unpin,