MaxMul

Struct MaxMul 

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

Max-times tropical scalar: ⊕ = max, ⊗ = ×.

Used for probabilistic models where you want the most likely path (Viterbi algorithm with probabilities in [0, 1]).

§Examples

use tenferro_tropical::MaxMul;

let a = MaxMul(0.3_f64);
let b = MaxMul(0.7_f64);

// Tropical addition = max
let c = a + b;   // MaxMul(0.7)

// Tropical multiplication = ordinary multiplication
let d = a * b;   // MaxMul(0.21)

Tuple Fields§

§0: T

Trait Implementations§

Source§

impl<T: Copy + PartialOrd> Add for MaxMul<T>

Source§

fn add(self, _rhs: Self) -> Self

Tropical addition: max(a, b).

Source§

type Output = MaxMul<T>

The resulting type after applying the + operator.
Source§

impl<T: Clone> Clone for MaxMul<T>

Source§

fn clone(&self) -> MaxMul<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: Debug> Debug for MaxMul<T>

Source§

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

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

impl<T: Display> Display for MaxMul<T>

Source§

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

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

impl HasAlgebra for MaxMul<f32>

Source§

type Algebra = MaxMulAlgebra

The algebra associated with this scalar type.
Source§

impl HasAlgebra for MaxMul<f64>

Source§

type Algebra = MaxMulAlgebra

The algebra associated with this scalar type.
Source§

impl<T: Copy + Mul<Output = T>> Mul for MaxMul<T>

Source§

fn mul(self, _rhs: Self) -> Self

Tropical multiplication: a × b (ordinary multiplication).

Source§

type Output = MaxMul<T>

The resulting type after applying the * operator.
Source§

impl<T: Float> One for MaxMul<T>

Source§

fn one() -> Self

Multiplicative identity: 1.

Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
Source§

impl<T: PartialEq> PartialEq for MaxMul<T>

Source§

fn eq(&self, other: &MaxMul<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: PartialOrd> PartialOrd for MaxMul<T>

Source§

fn partial_cmp(&self, other: &MaxMul<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: Float> Zero for MaxMul<T>

Source§

fn zero() -> Self

Additive identity: 0 (for max, 0 is the identity when values are non-negative).

Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Source§

impl<T: Copy> Copy for MaxMul<T>

Source§

impl<T> StructuralPartialEq for MaxMul<T>

Auto Trait Implementations§

§

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

§

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

§

impl<T> Send for MaxMul<T>
where T: Send,

§

impl<T> Sync for MaxMul<T>
where T: Sync,

§

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

§

impl<T> UnwindSafe for MaxMul<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> 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.
Source§

impl<T> Scalar for T
where T: Send + Sync + Add<Output = T> + Mul<Output = T> + Copy + Zero + One + PartialEq,

§

impl<T> ScalarBase for T
where T: Send + Sync + Mul<Output = T> + Add<Output = T> + Copy + Zero + One + PartialEq,