MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / FloatExt

Interface FloatExt

crates/cuda_std/src/float_ext.rs:19–71  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

17/// Note that these link to libdevice intrinsics, so these functions cannot be used in cpu code,
18/// or they will fail to link.
19pub trait FloatExt: Sized + private::Sealed {
20 /// The cosine of `self * pi` (measured in radians).
21 fn cospi(self) -> Self;
22 /// The value of the error function `2/\sqrt{pi} \int_0^x e^{-t^2} dt`.
23 fn error_function(self) -> Self;
24 /// The value of the complementary error function `1 - [error_function](Self::error_function)`.
25 fn complementary_error_function(self) -> Self;
26 /// Tries to find the value of `x` that satisfies `Self = complementary_error_function(x)`. Where
27 /// `Self` is in the interval [`0`, `2`].
28 fn inv_complementary_error_function(self) -> Self;
29 /// The value of the scaled complementary error function, `e^x^2 * self.complementary_error_function()`.
30 fn scaled_complementary_error_function(self) -> Self;
31 /// Decomposes self into a fractional component (which will be either 0, or in the range of 0.5..1.0) and an exponent.
32 /// Aka, `self = fractional * 2^exponent`.
33 fn frexp(self) -> (Self, i32);
34 /// The unbiased integer exponent of self.
35 fn unbiased_exp(self) -> i32;
36 /// The value of the bessel function of the first kind of order 0 for self. `J_0(self)`.
37 fn j0(self) -> Self;
38 /// The value of the bessel function of the first kind of order 1 for self. `J_1(self)`.
39 fn j1(self) -> Self;
40 /// The value of the bessel function of the first kind of order n for self. `J_n(self)`.
41 fn jn(self, order: i32) -> Self;
42 /// The value of `self * 2^exp`.
43 fn ldexp(self, exp: i32) -> Self;
44 /// The natural logarithm of the absolute value of the gamma function. `log_e (\int_0^\inf e^-t t^{x-1} dt)`
45 fn log_gamma(self) -> Self;
46 /// The natural logarithm of `1 + self`, `log_e(1 + self)`
47 fn log1p(self) -> Self;
48 /// The cumulative distribution function of the standard normal distribution for self. `\phi(self)`.
49 fn norm_cdf(self) -> Self;
50 /// The inverse cumulative distribution function of the standard normal distribution for self. `\phi^-1(self)`.
51 /// This function is defined for input values in the interval (0, 1).
52 fn inv_norm_cdf(self) -> Self;
53 /// The reciprocal cube root of self.
54 fn rcbrt(self) -> Self;
55 /// Clamp self to [+0.0, 1.0].
56 fn saturate(self) -> Self;
57 /// Scales self by `2^n` (`self * 2^n`) efficiently.
58 fn scale_by_n(self, exp: i32) -> Self;
59 /// The sine and cosine of `self * pi` (measured in radians).
60 fn sincospi(self) -> (Self, Self);
61 /// The sine of `self * pi` (measured in radians).
62 fn sinpi(self) -> Self;
63 /// The gamma function of self, `\int_0^\inf e^-t t^{x-1} dt`.
64 fn gamma(self) -> Self;
65 /// The value of the bessel function of the second kind of order 0 for self. `Y_0(self)`.
66 fn y0(self) -> Self;
67 /// The value of the bessel function of the second kind of order 1 for self. `Y_1(self)`.
68 fn y1(self) -> Self;
69 /// The value of the bessel function of the second kind of order n for self. `Y_n(self)`.
70 fn yn(self, order: i32) -> Self;
71}
72
73impl FloatExt for f64 {
74 fn cospi(self) -> Self {

Callers

nothing calls this directly

Implementers 1

float_ext.rscrates/cuda_std/src/float_ext.rs

Calls

no outgoing calls

Tested by

no test coverage detected