pub struct TropicalNumber<T>(pub T)
where
T: Float;Expand description
A number in the tropical (max-plus) semiring
Tropical addition is max, tropical multiplication is addition
Tuple Fields§
§0: TImplementations§
Source§impl<T> TropicalNumber<T>where
T: Float,
impl<T> TropicalNumber<T>where
T: Float,
Sourcepub fn neg_infinity() -> TropicalNumber<T>
pub fn neg_infinity() -> TropicalNumber<T>
Additive identity (negative infinity)
Sourcepub fn zero() -> TropicalNumber<T>
pub fn zero() -> TropicalNumber<T>
Multiplicative identity (zero in regular arithmetic)
Sourcepub fn tropical_zero() -> TropicalNumber<T>
pub fn tropical_zero() -> TropicalNumber<T>
Additive identity (same as neg_infinity for tropical)
Sourcepub fn tropical_one() -> TropicalNumber<T>
pub fn tropical_one() -> TropicalNumber<T>
Multiplicative identity (same as zero for tropical)
Sourcepub fn new(value: T) -> TropicalNumber<T>
pub fn new(value: T) -> TropicalNumber<T>
Create from regular number
Sourcepub fn is_infinity(&self) -> bool
pub fn is_infinity(&self) -> bool
Check if this is infinite (either positive or negative)
Sourcepub fn tropical_add(self, other: TropicalNumber<T>) -> TropicalNumber<T>
pub fn tropical_add(self, other: TropicalNumber<T>) -> TropicalNumber<T>
Tropical addition (max operation)
Sourcepub fn tropical_mul(self, other: TropicalNumber<T>) -> TropicalNumber<T>
pub fn tropical_mul(self, other: TropicalNumber<T>) -> TropicalNumber<T>
Tropical multiplication (addition)
Sourcepub fn tropical_pow(self, n: T) -> TropicalNumber<T>
pub fn tropical_pow(self, n: T) -> TropicalNumber<T>
Tropical power (scalar multiplication)
Sourcepub fn from_log_prob(log_p: T) -> TropicalNumber<T>
pub fn from_log_prob(log_p: T) -> TropicalNumber<T>
Convert from log-probability to tropical number
Source§impl TropicalNumber<f64>
impl TropicalNumber<f64>
pub const ZERO: TropicalNumber<f64>
pub const ONE: TropicalNumber<f64>
Source§impl TropicalNumber<f32>
impl TropicalNumber<f32>
pub const ZERO: TropicalNumber<f32>
pub const ONE: TropicalNumber<f32>
Trait Implementations§
Source§impl<T> Add for TropicalNumber<T>where
T: Float,
impl<T> Add for TropicalNumber<T>where
T: Float,
Source§type Output = TropicalNumber<T>
type Output = TropicalNumber<T>
The resulting type after applying the
+ operator.Source§fn add(self, other: TropicalNumber<T>) -> TropicalNumber<T>
fn add(self, other: TropicalNumber<T>) -> TropicalNumber<T>
Performs the
+ operation. Read moreSource§impl<T> Clone for TropicalNumber<T>
impl<T> Clone for TropicalNumber<T>
Source§fn clone(&self) -> TropicalNumber<T>
fn clone(&self) -> TropicalNumber<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Debug for TropicalNumber<T>
impl<T> Debug for TropicalNumber<T>
Source§impl<T> Mul for TropicalNumber<T>where
T: Float,
impl<T> Mul for TropicalNumber<T>where
T: Float,
Source§type Output = TropicalNumber<T>
type Output = TropicalNumber<T>
The resulting type after applying the
* operator.Source§fn mul(self, other: TropicalNumber<T>) -> TropicalNumber<T>
fn mul(self, other: TropicalNumber<T>) -> TropicalNumber<T>
Performs the
* operation. Read moreSource§impl<T> Neg for TropicalNumber<T>where
T: Float,
impl<T> Neg for TropicalNumber<T>where
T: Float,
Source§type Output = TropicalNumber<T>
type Output = TropicalNumber<T>
The resulting type after applying the
- operator.Source§fn neg(self) -> TropicalNumber<T>
fn neg(self) -> TropicalNumber<T>
Performs the unary
- operation. Read moreSource§impl<T> PartialEq for TropicalNumber<T>
impl<T> PartialEq for TropicalNumber<T>
Source§impl<T> PartialOrd for TropicalNumber<T>where
T: PartialOrd + Float,
impl<T> PartialOrd for TropicalNumber<T>where
T: PartialOrd + Float,
impl<T> Copy for TropicalNumber<T>
impl<T> StructuralPartialEq for TropicalNumber<T>where
T: Float,
Auto Trait Implementations§
impl<T> Freeze for TropicalNumber<T>where
T: Freeze,
impl<T> RefUnwindSafe for TropicalNumber<T>where
T: RefUnwindSafe,
impl<T> Send for TropicalNumber<T>where
T: Send,
impl<T> Sync for TropicalNumber<T>where
T: Sync,
impl<T> Unpin for TropicalNumber<T>where
T: Unpin,
impl<T> UnwindSafe for TropicalNumber<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.