Skip to main content

CoreMath

Trait CoreMath 

Source
pub trait CoreMath: CoreMathWithPolicy {
    // Provided methods
    fn poly<const N: usize>(self, coeffs: &[Self::Element; N]) -> Self { ... }
    fn poly_rev<const N: usize>(self, coeffs: &[Self::Element; N]) -> Self { ... }
    fn poly_rational<const N: usize, const D: usize>(
        self,
        numerator: &[Self::Element; N],
        denominator: &[Self::Element; D],
    ) -> Self { ... }
    fn reciprocal(self) -> Self { ... }
    fn approx_div(self, divisor: Self) -> Self { ... }
    fn inverse_sqrt(self) -> Self { ... }
    fn powi(self, e: i32) -> Self { ... }
    fn powiv(self, e: Self::Signed) -> Self { ... }
}
Expand description

Core Math functions for floating-point vectors using the default policy. This is the core set of mathematical operations that form the basis for more advanced functions.

This trait requires FloatVector via the bounds on CoreMathWithPolicy.

This trait provides the same set of mathematical operations as CoreMathWithPolicy, but uses the DefaultPolicy for all operations. This allows for easier usage when specific policy customization is not required.

Implementors of CoreMathWithPolicy will automatically implement this trait as well.

All methods here have an associated method in CoreMathWithPolicy with a _p suffix that accepts a policy parameter as the first generic argument.

Provided Methods§

Source

fn poly<const N: usize>(self, coeffs: &[Self::Element; N]) -> Self

Computes the polynomial with the given coefficients at self.

This will use fused multiply-add instructions where available for improved performance and accuracy, but falls back to standard operations if not.

Source

fn poly_rev<const N: usize>(self, coeffs: &[Self::Element; N]) -> Self

Computes the polynomial with the given coefficients at self, but with the coefficients in reverse order.

This will use fused multiply-add instructions where available for improved performance and accuracy, but falls back to standard operations if not.

Source

fn poly_rational<const N: usize, const D: usize>( self, numerator: &[Self::Element; N], denominator: &[Self::Element; D], ) -> Self

Computes the ratio of two polynomials at self, given the numerator and denominator coefficients.

Equivalent to poly(numerator) / poly(denominator), but with improved numerical stability in some cases.

This will use fused multiply-add instructions where available for improved performance and accuracy, but falls back to standard operations if not.

Source

fn reciprocal(self) -> Self

Returns the multiplicative inverse of self, which is 1 / self.

If using the policy version, you may select lower precision policies for extra performance, at the cost of accuracy.

Source

fn approx_div(self, divisor: Self) -> Self

Returns the result of dividing self by divisor, i.e., self / divisor.

Depending on the precision policy and available features, this may be optimized to use approximate reciprocal and multiplication for better performance, at the cost of accuracy.

Source

fn inverse_sqrt(self) -> Self

Returns the inverse square root of self, which is 1 / sqrt(self).

If using the policy version, you may select lower precision policies for extra performance, at the cost of accuracy.

Source

fn powi(self, e: i32) -> Self

Returns self raised to the signed integer power of e.

Source

fn powiv(self, e: Self::Signed) -> Self

Returns self raised to the signed integer power of each element in e.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<M> CoreMath for M