TropicalScalar

Trait TropicalScalar 

Source
pub trait TropicalScalar: Scalar {
    type Inner: Scalar + Float + AddAssign + HasAlgebra<Algebra = Standard<Self::Inner>>;

    // Required methods
    fn inner(&self) -> Self::Inner;
    fn from_inner(v: Self::Inner) -> Self;
    fn mul_backward_a(
        a_inner: Self::Inner,
        b_inner: Self::Inner,
        dout: Self::Inner,
    ) -> Self::Inner;
    fn mul_backward_b(
        a_inner: Self::Inner,
        b_inner: Self::Inner,
        dout: Self::Inner,
    ) -> Self::Inner;
}
Expand description

Trait for extracting the inner float type from a tropical scalar wrapper.

This enables generic code that operates on the inner values for backward pass computations.

§Examples

use tenferro_ext_tropical::MaxPlus;
use tenferro_ext_tropical::ad::TropicalScalar;

let x = MaxPlus(3.0_f64);
assert_eq!(x.inner(), 3.0);

Required Associated Types§

Source

type Inner: Scalar + Float + AddAssign + HasAlgebra<Algebra = Standard<Self::Inner>>

The inner floating-point type.

Required Methods§

Source

fn inner(&self) -> Self::Inner

Extract the inner value.

Source

fn from_inner(v: Self::Inner) -> Self

Wrap an inner value into the tropical type.

Source

fn mul_backward_a( a_inner: Self::Inner, b_inner: Self::Inner, dout: Self::Inner, ) -> Self::Inner

Backward contribution for tropical multiplication w.r.t. the first operand.

Source

fn mul_backward_b( a_inner: Self::Inner, b_inner: Self::Inner, dout: Self::Inner, ) -> Self::Inner

Backward contribution for tropical multiplication w.r.t. the second operand.

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§