Skip to main content

TropicalScalar

Trait TropicalScalar 

Source
pub trait TropicalScalar:
    Copy
    + Clone
    + Send
    + Sync
    + Debug
    + Display
    + PartialOrd
    + 'static
    + Sized {
    // Required methods
    fn scalar_zero() -> Self;
    fn scalar_one() -> Self;
    fn scalar_add(self, rhs: Self) -> Self;
    fn scalar_mul(self, rhs: Self) -> Self;
    fn pos_infinity() -> Self;
    fn neg_infinity() -> Self;
    fn scalar_max(self, rhs: Self) -> Self;
    fn scalar_min(self, rhs: Self) -> Self;

    // Provided methods
    fn is_drifted_neg_zero(self) -> bool { ... }
    fn is_drifted_pos_zero(self) -> bool { ... }
}
Expand description

Trait for scalar types that can be used as underlying values in tropical numbers.

Required Methods§

Source

fn scalar_zero() -> Self

The additive identity (standard arithmetic).

Source

fn scalar_one() -> Self

The multiplicative identity (standard arithmetic).

Source

fn scalar_add(self, rhs: Self) -> Self

Standard arithmetic addition.

Source

fn scalar_mul(self, rhs: Self) -> Self

Standard arithmetic multiplication.

Source

fn pos_infinity() -> Self

Positive infinity (for MinPlus zero).

Source

fn neg_infinity() -> Self

Negative infinity (for MaxPlus zero).

Source

fn scalar_max(self, rhs: Self) -> Self

Maximum of two values.

Source

fn scalar_min(self, rhs: Self) -> Self

Minimum of two values.

Provided Methods§

Source

fn is_drifted_neg_zero(self) -> bool

Whether self is an in-band integer sentinel that has drifted off the canonical negative tropical zero (-∞).

Integer tropical zeros use a finite sentinel plus a guard-free +, so a no-contribution cell’s value lands in “infinity territory” (past neg_infinity() / 2) without being exactly the sentinel. This is used at GEMM write-back to canonicalize the argmax index of such cells.

Exact-infinity representations (floats) never drift, and narrow / unsigned integers are out of the headroom-sentinel scheme, so the default is false — only i32/i64 override it, which lets the canonicalization branch fold away entirely for every other monomorphization.

Source

fn is_drifted_pos_zero(self) -> bool

Positive (+∞) counterpart of TropicalScalar::is_drifted_neg_zero.

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 TropicalScalar for bool

Source§

fn scalar_zero() -> Self

Source§

fn scalar_one() -> Self

Source§

fn scalar_add(self, rhs: Self) -> Self

Source§

fn scalar_mul(self, rhs: Self) -> Self

Source§

fn pos_infinity() -> Self

Source§

fn neg_infinity() -> Self

Source§

fn scalar_max(self, rhs: Self) -> Self

Source§

fn scalar_min(self, rhs: Self) -> Self

Source§

impl TropicalScalar for f32

Source§

fn scalar_zero() -> Self

Source§

fn scalar_one() -> Self

Source§

fn scalar_add(self, rhs: Self) -> Self

Source§

fn scalar_mul(self, rhs: Self) -> Self

Source§

fn pos_infinity() -> Self

Source§

fn neg_infinity() -> Self

Source§

fn scalar_max(self, rhs: Self) -> Self

Source§

fn scalar_min(self, rhs: Self) -> Self

Source§

impl TropicalScalar for f64

Source§

fn scalar_zero() -> Self

Source§

fn scalar_one() -> Self

Source§

fn scalar_add(self, rhs: Self) -> Self

Source§

fn scalar_mul(self, rhs: Self) -> Self

Source§

fn pos_infinity() -> Self

Source§

fn neg_infinity() -> Self

Source§

fn scalar_max(self, rhs: Self) -> Self

Source§

fn scalar_min(self, rhs: Self) -> Self

Source§

impl TropicalScalar for i8

Source§

fn scalar_zero() -> Self

Source§

fn scalar_one() -> Self

Source§

fn scalar_add(self, rhs: Self) -> Self

Source§

fn scalar_mul(self, rhs: Self) -> Self

Source§

fn scalar_max(self, rhs: Self) -> Self

Source§

fn scalar_min(self, rhs: Self) -> Self

Source§

fn pos_infinity() -> Self

Source§

fn neg_infinity() -> Self

Source§

impl TropicalScalar for i16

Source§

fn scalar_zero() -> Self

Source§

fn scalar_one() -> Self

Source§

fn scalar_add(self, rhs: Self) -> Self

Source§

fn scalar_mul(self, rhs: Self) -> Self

Source§

fn scalar_max(self, rhs: Self) -> Self

Source§

fn scalar_min(self, rhs: Self) -> Self

Source§

fn pos_infinity() -> Self

Source§

fn neg_infinity() -> Self

Source§

impl TropicalScalar for i32

Source§

fn scalar_zero() -> Self

Source§

fn scalar_one() -> Self

Source§

fn scalar_add(self, rhs: Self) -> Self

Source§

fn scalar_mul(self, rhs: Self) -> Self

Source§

fn scalar_max(self, rhs: Self) -> Self

Source§

fn scalar_min(self, rhs: Self) -> Self

Source§

fn pos_infinity() -> Self

Source§

fn neg_infinity() -> Self

Source§

fn is_drifted_neg_zero(self) -> bool

Source§

fn is_drifted_pos_zero(self) -> bool

Source§

impl TropicalScalar for i64

Source§

fn scalar_zero() -> Self

Source§

fn scalar_one() -> Self

Source§

fn scalar_add(self, rhs: Self) -> Self

Source§

fn scalar_mul(self, rhs: Self) -> Self

Source§

fn scalar_max(self, rhs: Self) -> Self

Source§

fn scalar_min(self, rhs: Self) -> Self

Source§

fn pos_infinity() -> Self

Source§

fn neg_infinity() -> Self

Source§

fn is_drifted_neg_zero(self) -> bool

Source§

fn is_drifted_pos_zero(self) -> bool

Source§

impl TropicalScalar for u8

Source§

fn scalar_zero() -> Self

Source§

fn scalar_one() -> Self

Source§

fn scalar_add(self, rhs: Self) -> Self

Source§

fn scalar_mul(self, rhs: Self) -> Self

Source§

fn scalar_max(self, rhs: Self) -> Self

Source§

fn scalar_min(self, rhs: Self) -> Self

Source§

fn pos_infinity() -> Self

Source§

fn neg_infinity() -> Self

Source§

impl TropicalScalar for u16

Source§

fn scalar_zero() -> Self

Source§

fn scalar_one() -> Self

Source§

fn scalar_add(self, rhs: Self) -> Self

Source§

fn scalar_mul(self, rhs: Self) -> Self

Source§

fn scalar_max(self, rhs: Self) -> Self

Source§

fn scalar_min(self, rhs: Self) -> Self

Source§

fn pos_infinity() -> Self

Source§

fn neg_infinity() -> Self

Source§

impl TropicalScalar for u32

Source§

fn scalar_zero() -> Self

Source§

fn scalar_one() -> Self

Source§

fn scalar_add(self, rhs: Self) -> Self

Source§

fn scalar_mul(self, rhs: Self) -> Self

Source§

fn scalar_max(self, rhs: Self) -> Self

Source§

fn scalar_min(self, rhs: Self) -> Self

Source§

fn pos_infinity() -> Self

Source§

fn neg_infinity() -> Self

Source§

impl TropicalScalar for u64

Source§

fn scalar_zero() -> Self

Source§

fn scalar_one() -> Self

Source§

fn scalar_add(self, rhs: Self) -> Self

Source§

fn scalar_mul(self, rhs: Self) -> Self

Source§

fn scalar_max(self, rhs: Self) -> Self

Source§

fn scalar_min(self, rhs: Self) -> Self

Source§

fn pos_infinity() -> Self

Source§

fn neg_infinity() -> Self

Implementors§