pub trait Semiring {
type Scalar: Scalar;
// Required methods
fn zero() -> Self::Scalar;
fn one() -> Self::Scalar;
fn add(a: Self::Scalar, b: Self::Scalar) -> Self::Scalar;
fn mul(a: Self::Scalar, b: Self::Scalar) -> Self::Scalar;
}Expand description
Semiring trait for algebra-generic operations.
Defines the four fundamental operations needed for tensor contractions under a given algebra:
zero(): Additive identityone(): Multiplicative identityadd(a, b): Semiring addition (e.g.,+for Standard,maxfor MaxPlus)mul(a, b): Semiring multiplication (e.g.,*for Standard,+for MaxPlus)
§Examples
Standard arithmetic:
zero() = 0,one() = 1,add = +,mul = *
Tropical (MaxPlus) semiring (in external crate):
zero() = -∞,one() = 0,add = max,mul = +
Required Associated Types§
Required Methods§
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.