Trait Numeric

Source
pub trait Numeric:
    Copy
    + Abs
    + Max
    + Min
    + Clamp
    + Remainder
    + CubePrimitive
    + IntoRuntime
    + LaunchArgExpand<CompilationArg = ()>
    + ScalarArgSettings
    + ExpandElementBaseInit
    + Into<ExpandElementTyped<Self>>
    + CubeIndexMut<u32, Output = Self>
    + CubeIndexMut<ExpandElementTyped<u32>, Output = Self>
    + NumCast
    + AddAssign
    + SubAssign
    + MulAssign
    + DivAssign
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Div<Output = Self>
    + PartialOrd
    + PartialEq {
    // Required methods
    fn min_value() -> Self;
    fn max_value() -> Self;

    // Provided methods
    fn __expand_min_value(scope: &mut Scope) -> <Self as CubeType>::ExpandType { ... }
    fn __expand_max_value(scope: &mut Scope) -> <Self as CubeType>::ExpandType { ... }
    fn from_int(val: i64) -> Self { ... }
    fn from_vec<const D: usize>(_vec: [u32; D]) -> Self { ... }
    fn __expand_from_int(
        scope: &mut Scope,
        val: ExpandElementTyped<i64>,
    ) -> <Self as CubeType>::ExpandType { ... }
    fn __expand_from_vec<const D: usize>(
        scope: &mut Scope,
        vec: [u32; D],
    ) -> <Self as CubeType>::ExpandType { ... }
}
Expand description

Type that encompasses both (unsigned or signed) integers and floats Used in kernels that should work for both.

Required Methods§

Source

fn min_value() -> Self

Source

fn max_value() -> Self

Provided Methods§

Source

fn __expand_min_value(scope: &mut Scope) -> <Self as CubeType>::ExpandType

Source

fn __expand_max_value(scope: &mut Scope) -> <Self as CubeType>::ExpandType

Source

fn from_int(val: i64) -> Self

Create a new constant numeric.

Note: since this must work for both integer and float only the less expressive of both can be created (int) If a number with decimals is needed, use Float::new.

This method panics when unexpanded. For creating an element with a val, use the new method of the sub type.

Source

fn from_vec<const D: usize>(_vec: [u32; D]) -> Self

Source

fn __expand_from_int( scope: &mut Scope, val: ExpandElementTyped<i64>, ) -> <Self as CubeType>::ExpandType

Source

fn __expand_from_vec<const D: usize>( scope: &mut Scope, vec: [u32; D], ) -> <Self as CubeType>::ExpandType

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 Numeric for f32

Source§

fn min_value() -> Self

Source§

fn max_value() -> Self

Source§

impl Numeric for f64

Source§

fn min_value() -> Self

Source§

fn max_value() -> Self

Source§

impl Numeric for i8

Source§

fn min_value() -> Self

Source§

fn max_value() -> Self

Source§

impl Numeric for i16

Source§

fn min_value() -> Self

Source§

fn max_value() -> Self

Source§

impl Numeric for i32

Source§

fn min_value() -> Self

Source§

fn max_value() -> Self

Source§

impl Numeric for i64

Source§

fn min_value() -> Self

Source§

fn max_value() -> Self

Source§

impl Numeric for u8

Source§

fn min_value() -> Self

Source§

fn max_value() -> Self

Source§

impl Numeric for u16

Source§

fn min_value() -> Self

Source§

fn max_value() -> Self

Source§

impl Numeric for u32

Source§

fn min_value() -> Self

Source§

fn max_value() -> Self

Source§

impl Numeric for u64

Source§

fn min_value() -> Self

Source§

fn max_value() -> Self

Source§

impl Numeric for bf16

Source§

fn min_value() -> Self

Source§

fn max_value() -> Self

Source§

impl Numeric for f16

Source§

fn min_value() -> Self

Source§

fn max_value() -> Self

Implementors§

Source§

impl Numeric for flex32

Source§

impl Numeric for tf32

Source§

impl<const POS: u8> Numeric for FloatExpand<POS>

Source§

impl<const POS: u8> Numeric for IntExpand<POS>