rand_distr

Trait Float

Source
pub trait Float:
    Copy
    + Sized
    + PartialOrd
    + Neg<Output = Self>
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Div<Output = Self>
    + AddAssign
    + SubAssign
    + MulAssign
    + DivAssign {
    // Required methods
    fn pi() -> Self;
    fn from(x: f64) -> Self;
    fn to_u64(self) -> Option<u64>;
    fn abs(self) -> Self;
    fn floor(self) -> Self;
    fn exp(self) -> Self;
    fn ln(self) -> Self;
    fn sqrt(self) -> Self;
    fn powf(self, power: Self) -> Self;
    fn tan(self) -> Self;
    fn log_gamma(self) -> Self;
}
Expand description

Trait for floating-point scalar types

This allows many distributions to work with f32 or f64 parameters and is potentially extensible. Note however that the Exp1 and StandardNormal distributions are implemented exclusively for f32 and f64.

The bounds and methods are based purely on internal requirements, and will change as needed.

Required Methods§

Source

fn pi() -> Self

The constant π

Source

fn from(x: f64) -> Self

Support approximate representation of a f64 value

Source

fn to_u64(self) -> Option<u64>

Support converting to an unsigned integer.

Source

fn abs(self) -> Self

Take the absolute value of self

Source

fn floor(self) -> Self

Take the largest integer less than or equal to self

Source

fn exp(self) -> Self

Take the exponential of self

Source

fn ln(self) -> Self

Take the natural logarithm of self

Source

fn sqrt(self) -> Self

Take square root of self

Source

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

Take self to a floating-point power

Source

fn tan(self) -> Self

Take the tangent of self

Source

fn log_gamma(self) -> Self

Take the logarithm of the gamma function of self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Float for f32

Source§

fn pi() -> Self

Source§

fn from(x: f64) -> Self

Source§

fn to_u64(self) -> Option<u64>

Source§

fn abs(self) -> Self

Source§

fn floor(self) -> Self

Source§

fn exp(self) -> Self

Source§

fn ln(self) -> Self

Source§

fn sqrt(self) -> Self

Source§

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

Source§

fn tan(self) -> Self

Source§

fn log_gamma(self) -> Self

Source§

impl Float for f64

Source§

fn pi() -> Self

Source§

fn from(x: f64) -> Self

Source§

fn to_u64(self) -> Option<u64>

Source§

fn abs(self) -> Self

Source§

fn floor(self) -> Self

Source§

fn exp(self) -> Self

Source§

fn ln(self) -> Self

Source§

fn sqrt(self) -> Self

Source§

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

Source§

fn tan(self) -> Self

Source§

fn log_gamma(self) -> Self

Implementors§