Skip to main content

InvMonoid

Trait InvMonoid 

Source
pub trait InvMonoid:
    MulMonoid
    + Div<Output = Self>
    + DivAssign {
    // Required method
    fn inverse(&self) -> Self;
}
Expand description

Represents a Multiplicative Monoid with the additional property that every element has a multiplicative inverse.

This trait effectively defines the “inverse” operation within a multiplicative context, sitting between MulMonoid and MulGroup in the hierarchy.

§Mathematical Definition

An InvMonoid is a MulMonoid where for every element a, there exists an element a⁻¹ such that a * a⁻¹ = 1 and a⁻¹ * a = 1.

§Justification for Deviation (for floating-point types)

In pure mathematics, the zero element does not have a multiplicative inverse. To align with standard floating-point behavior (IEEE 754), implementations for types that can be zero (like f32, f64) should handle this case gracefully by returning Infinity or NaN rather than panicking.

Required Methods§

Source

fn inverse(&self) -> Self

Computes the multiplicative inverse of an element.

For a non-zero element a, its inverse a⁻¹ is the unique element such that a * a⁻¹ = 1.

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.

Implementors§

Source§

impl<T> InvMonoid for T
where T: MulMonoid + Div<Output = Self> + DivAssign + One + Clone,