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§
Sourcefn scalar_zero() -> Self
fn scalar_zero() -> Self
The additive identity (standard arithmetic).
Sourcefn scalar_one() -> Self
fn scalar_one() -> Self
The multiplicative identity (standard arithmetic).
Sourcefn scalar_add(self, rhs: Self) -> Self
fn scalar_add(self, rhs: Self) -> Self
Standard arithmetic addition.
Sourcefn scalar_mul(self, rhs: Self) -> Self
fn scalar_mul(self, rhs: Self) -> Self
Standard arithmetic multiplication.
Sourcefn pos_infinity() -> Self
fn pos_infinity() -> Self
Positive infinity (for MinPlus zero).
Sourcefn neg_infinity() -> Self
fn neg_infinity() -> Self
Negative infinity (for MaxPlus zero).
Sourcefn scalar_max(self, rhs: Self) -> Self
fn scalar_max(self, rhs: Self) -> Self
Maximum of two values.
Sourcefn scalar_min(self, rhs: Self) -> Self
fn scalar_min(self, rhs: Self) -> Self
Minimum of two values.
Provided Methods§
Sourcefn is_drifted_neg_zero(self) -> bool
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.
Sourcefn is_drifted_pos_zero(self) -> bool
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.