#[repr(transparent)]pub struct Standard<T: Scalar>(pub T);Expand description
Standard arithmetic semiring with addition and multiplication.
This represents the usual (+, ×) operations used in linear algebra.
§Example
use omeinsum::algebra::{Standard, Semiring};
let a = Standard(2.0f32);
let b = Standard(3.0f32);
assert_eq!(a.add(b).to_scalar(), 5.0); // 2 + 3 = 5
assert_eq!(a.mul(b).to_scalar(), 6.0); // 2 × 3 = 6Tuple Fields§
§0: TTrait Implementations§
Source§impl<T: Scalar + Zero + One + PartialEq + Add<Output = T> + Mul<Output = T>> Algebra for Standard<T>
impl<T: Scalar + Zero + One + PartialEq + Add<Output = T> + Mul<Output = T>> Algebra for Standard<T>
Source§fn add_with_argmax(
self,
_self_idx: Self::Index,
rhs: Self,
_rhs_idx: Self::Index,
) -> (Self, Self::Index)
fn add_with_argmax( self, _self_idx: Self::Index, rhs: Self, _rhs_idx: Self::Index, ) -> (Self, Self::Index)
Addition with argmax tracking. Read more
Source§fn add_backward(
self,
_rhs: Self,
grad_out: Self::Scalar,
_winner_idx: Option<Self::Index>,
) -> (Self::Scalar, Self::Scalar)
fn add_backward( self, _rhs: Self, grad_out: Self::Scalar, _winner_idx: Option<Self::Index>, ) -> (Self::Scalar, Self::Scalar)
Backward pass for addition. Read more
Source§fn mul_backward(
self,
rhs: Self,
grad_out: Self::Scalar,
) -> (Self::Scalar, Self::Scalar)
fn mul_backward( self, rhs: Self, grad_out: Self::Scalar, ) -> (Self::Scalar, Self::Scalar)
Backward pass for multiplication. Read more
Source§fn needs_argmax() -> bool
fn needs_argmax() -> bool
Whether this algebra requires argmax tracking for backprop.
Source§impl<T: Scalar + Zero + One + PartialEq + Add<Output = T> + Mul<Output = T>> Semiring for Standard<T>
impl<T: Scalar + Zero + One + PartialEq + Add<Output = T> + Mul<Output = T>> Semiring for Standard<T>
Source§fn from_scalar(s: T) -> Self
fn from_scalar(s: T) -> Self
Create from scalar value
impl<T: Copy + Scalar> Copy for Standard<T>
impl<T: Scalar> StructuralPartialEq for Standard<T>
Auto Trait Implementations§
impl<T> Freeze for Standard<T>where
T: Freeze,
impl<T> RefUnwindSafe for Standard<T>where
T: RefUnwindSafe,
impl<T> Send for Standard<T>
impl<T> Sync for Standard<T>
impl<T> Unpin for Standard<T>where
T: Unpin,
impl<T> UnwindSafe for Standard<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,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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