TropicalMinPlus

Struct TropicalMinPlus 

Source
#[repr(transparent)]
pub struct TropicalMinPlus<T: TropicalScalar>(pub T);
Expand description

TropicalMinPlus semiring: (ℝ ∪ {+∞}, min, +)

  • Addition (⊕) = min
  • Multiplication (⊗) = +
  • Zero = +∞
  • One = 0

This is used for:

  • Shortest path algorithms (Dijkstra, Floyd-Warshall)
  • Dynamic programming with minimum cost

Tuple Fields§

§0: T

Implementations§

Source§

impl<T: TropicalScalar> TropicalMinPlus<T>

Source

pub fn new(value: T) -> Self

Create a new TropicalMinPlus value.

Trait Implementations§

Source§

impl<T: TropicalScalar> Add for TropicalMinPlus<T>

Source§

type Output = TropicalMinPlus<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: Clone + TropicalScalar> Clone for TropicalMinPlus<T>

Source§

fn clone(&self) -> TropicalMinPlus<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: TropicalScalar> Debug for TropicalMinPlus<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: TropicalScalar> Default for TropicalMinPlus<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: TropicalScalar> Display for TropicalMinPlus<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: TropicalScalar> From<T> for TropicalMinPlus<T>

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl KernelDispatch for TropicalMinPlus<f32>

Source§

unsafe fn dispatch_gemm( m: usize, n: usize, k: usize, a: *const f32, lda: usize, trans_a: Transpose, b: *const f32, ldb: usize, trans_b: Transpose, c: *mut Self, ldc: usize, )

Dispatch to the appropriate kernel based on CPU features.
Source§

impl KernelDispatch for TropicalMinPlus<f64>

Source§

unsafe fn dispatch_gemm( m: usize, n: usize, k: usize, a: *const Self::Scalar, lda: usize, trans_a: Transpose, b: *const Self::Scalar, ldb: usize, trans_b: Transpose, c: *mut Self, ldc: usize, )

Dispatch to the appropriate kernel based on CPU features.
Source§

impl KernelDispatch for TropicalMinPlus<i32>

Source§

unsafe fn dispatch_gemm( m: usize, n: usize, k: usize, a: *const Self::Scalar, lda: usize, trans_a: Transpose, b: *const Self::Scalar, ldb: usize, trans_b: Transpose, c: *mut Self, ldc: usize, )

Dispatch to the appropriate kernel based on CPU features.
Source§

impl KernelDispatch for TropicalMinPlus<i64>

Source§

unsafe fn dispatch_gemm( m: usize, n: usize, k: usize, a: *const Self::Scalar, lda: usize, trans_a: Transpose, b: *const Self::Scalar, ldb: usize, trans_b: Transpose, c: *mut Self, ldc: usize, )

Dispatch to the appropriate kernel based on CPU features.
Source§

impl Microkernel<TropicalMinPlus<f32>> for Avx2MinPlusF32Kernel

Source§

const MR: usize = 8

Rows of the microkernel (typically 4-8 for f32).
Source§

const NR: usize = 8

Columns of the microkernel (typically 4-8 for f32).
Source§

unsafe fn execute( &self, mr: usize, nr: usize, k: usize, a: *const f32, b: *const f32, c: *mut TropicalMinPlus<f32>, ldc: usize, )

Execute the microkernel. Read more
Source§

impl<T: TropicalScalar> Mul for TropicalMinPlus<T>

Source§

type Output = TropicalMinPlus<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: PartialEq + TropicalScalar> PartialEq for TropicalMinPlus<T>

Source§

fn eq(&self, other: &TropicalMinPlus<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: TropicalScalar> SimdTropical for TropicalMinPlus<T>

Source§

const SIMD_AVAILABLE: bool = true

Whether SIMD operations are available for this type.
Source§

const SIMD_WIDTH: usize = 8

The SIMD width in elements.
Source§

impl<T: TropicalScalar> TropicalSemiring for TropicalMinPlus<T>

Source§

type Scalar = T

The underlying scalar type.
Source§

fn tropical_zero() -> Self

Returns the additive identity (zero element for ⊕).
Source§

fn tropical_one() -> Self

Returns the multiplicative identity (one element for ⊗).
Source§

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

Tropical addition (⊕).
Source§

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

Tropical multiplication (⊗).
Source§

fn value(&self) -> T

Get the underlying scalar value.
Source§

fn from_scalar(s: T) -> Self

Create from a scalar value.
Source§

impl<T: TropicalScalar> TropicalWithArgmax for TropicalMinPlus<T>

Source§

type Index = u32

The index type used for argmax tracking.
Source§

fn tropical_add_argmax( self, self_idx: u32, rhs: Self, rhs_idx: u32, ) -> (Self, u32)

Tropical addition with argmax tracking. Read more
Source§

impl<T: Copy + TropicalScalar> Copy for TropicalMinPlus<T>

Source§

impl<T: TropicalScalar> StructuralPartialEq for TropicalMinPlus<T>

Auto Trait Implementations§

§

impl<T> Freeze for TropicalMinPlus<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for TropicalMinPlus<T>
where T: RefUnwindSafe,

§

impl<T> Send for TropicalMinPlus<T>

§

impl<T> Sync for TropicalMinPlus<T>

§

impl<T> Unpin for TropicalMinPlus<T>
where T: Unpin,

§

impl<T> UnwindSafe for TropicalMinPlus<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.