Trait FloatExt

Source
pub trait FloatExt: Sized + Sealed {
Show 24 methods // Required methods fn cospi(self) -> Self; fn error_function(self) -> Self; fn complementary_error_function(self) -> Self; fn inv_complementary_error_function(self) -> Self; fn scaled_complementary_error_function(self) -> Self; fn frexp(self) -> (Self, i32); fn unbiased_exp(self) -> i32; fn j0(self) -> Self; fn j1(self) -> Self; fn jn(self, order: i32) -> Self; fn ldexp(self, exp: i32) -> Self; fn log_gamma(self) -> Self; fn log1p(self) -> Self; fn norm_cdf(self) -> Self; fn inv_norm_cdf(self) -> Self; fn rcbrt(self) -> Self; fn saturate(self) -> Self; fn scale_by_n(self, exp: i32) -> Self; fn sincospi(self) -> (Self, Self); fn sinpi(self) -> Self; fn gamma(self) -> Self; fn y0(self) -> Self; fn y1(self) -> Self; fn yn(self, order: i32) -> Self;
}
Expand description

Extension trait for f32 and f64 which provides high level functions for low level intrinsics for common math operations. You should generally use these functions over “manual” implementations because they are often much faster.

Note that these link to libdevice intrinsics, so these functions cannot be used in cpu code, or they will fail to link.

Required Methods§

Source

fn cospi(self) -> Self

The cosine of self * pi (measured in radians).

Source

fn error_function(self) -> Self

The value of the error function 2/\sqrt{pi} \int_0^x e^{-t^2} dt.

Source

fn complementary_error_function(self) -> Self

The value of the complementary error function 1 - [error_function](Self::error_function).

Source

fn inv_complementary_error_function(self) -> Self

Tries to find the value of x that satisfies Self = complementary_error_function(x). Where Self is in the interval [0, 2].

Source

fn scaled_complementary_error_function(self) -> Self

The value of the scaled complementary error function, e^x^2 * self.complementary_error_function().

Source

fn frexp(self) -> (Self, i32)

Decomposes self into a fractional component (which will be either 0, or in the range of 0.5..1.0) and an exponent. Aka, self = fractional * 2^exponent.

Source

fn unbiased_exp(self) -> i32

The unbiased integer exponent of self.

Source

fn j0(self) -> Self

The value of the bessel function of the first kind of order 0 for self. J_0(self).

Source

fn j1(self) -> Self

The value of the bessel function of the first kind of order 1 for self. J_1(self).

Source

fn jn(self, order: i32) -> Self

The value of the bessel function of the first kind of order n for self. J_n(self).

Source

fn ldexp(self, exp: i32) -> Self

The value of self * 2^exp.

Source

fn log_gamma(self) -> Self

The natural logarithm of the absolute value of the gamma function. log_e (\int_0^\inf e^-t t^{x-1} dt)

Source

fn log1p(self) -> Self

The natural logarithm of 1 + self, log_e(1 + self)

Source

fn norm_cdf(self) -> Self

The cumulative distribution function of the standard normal distribution for self. \phi(self).

Source

fn inv_norm_cdf(self) -> Self

The inverse cumulative distribution function of the standard normal distribution for self. \phi^-1(self). This function is defined for input values in the interval (0, 1).

Source

fn rcbrt(self) -> Self

The reciprocal cube root of self.

Source

fn saturate(self) -> Self

Clamp self to [+0.0, 1.0].

Source

fn scale_by_n(self, exp: i32) -> Self

Scales self by 2^n (self * 2^n) efficiently.

Source

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

The sine and cosine of self * pi (measured in radians).

Source

fn sinpi(self) -> Self

The sine of self * pi (measured in radians).

Source

fn gamma(self) -> Self

The gamma function of self, \int_0^\inf e^-t t^{x-1} dt.

Source

fn y0(self) -> Self

The value of the bessel function of the second kind of order 0 for self. Y_0(self).

Source

fn y1(self) -> Self

The value of the bessel function of the second kind of order 1 for self. Y_1(self).

Source

fn yn(self, order: i32) -> Self

The value of the bessel function of the second kind of order n for self. Y_n(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 FloatExt for f32

Source§

fn cospi(self) -> Self

Source§

fn error_function(self) -> Self

Source§

fn complementary_error_function(self) -> Self

Source§

fn inv_complementary_error_function(self) -> Self

Source§

fn scaled_complementary_error_function(self) -> Self

Source§

fn frexp(self) -> (Self, i32)

Source§

fn unbiased_exp(self) -> i32

Source§

fn j0(self) -> Self

Source§

fn j1(self) -> Self

Source§

fn jn(self, order: i32) -> Self

Source§

fn ldexp(self, exp: i32) -> Self

Source§

fn log_gamma(self) -> Self

Source§

fn log1p(self) -> Self

Source§

fn norm_cdf(self) -> Self

Source§

fn inv_norm_cdf(self) -> Self

Source§

fn rcbrt(self) -> Self

Source§

fn saturate(self) -> Self

Source§

fn scale_by_n(self, exp: i32) -> Self

Source§

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

Source§

fn sinpi(self) -> Self

Source§

fn gamma(self) -> Self

Source§

fn y0(self) -> Self

Source§

fn y1(self) -> Self

Source§

fn yn(self, order: i32) -> Self

Source§

impl FloatExt for f64

Source§

fn cospi(self) -> Self

Source§

fn error_function(self) -> Self

Source§

fn complementary_error_function(self) -> Self

Source§

fn inv_complementary_error_function(self) -> Self

Source§

fn scaled_complementary_error_function(self) -> Self

Source§

fn frexp(self) -> (Self, i32)

Source§

fn unbiased_exp(self) -> i32

Source§

fn j0(self) -> Self

Source§

fn j1(self) -> Self

Source§

fn jn(self, order: i32) -> Self

Source§

fn ldexp(self, exp: i32) -> Self

Source§

fn log_gamma(self) -> Self

Source§

fn log1p(self) -> Self

Source§

fn norm_cdf(self) -> Self

Source§

fn inv_norm_cdf(self) -> Self

Source§

fn rcbrt(self) -> Self

Source§

fn saturate(self) -> Self

Source§

fn scale_by_n(self, exp: i32) -> Self

Source§

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

Source§

fn sinpi(self) -> Self

Source§

fn gamma(self) -> Self

Source§

fn y0(self) -> Self

Source§

fn y1(self) -> Self

Source§

fn yn(self, order: i32) -> Self

Implementors§