Mon, 12 May 2025 16:28:50 -0500
Add more AXPY super traits
| src/direct_product.rs | file | annotate | diff | comparison | revisions | |
| src/linops.rs | file | annotate | diff | comparison | revisions |
--- a/src/direct_product.rs Mon May 12 15:42:48 2025 -0500 +++ b/src/direct_product.rs Mon May 12 16:28:50 2025 -0500 @@ -179,9 +179,7 @@ } impl_scalar!(Mul, mul); -//impl_scalar!(Mul, mul, f64); -impl_scalar!(Sub, sub); -//impl_scalar!(Sub, sub, f64); +impl_scalar!(Div, div); macro_rules! impl_scalar_lhs { ($trait:ident, $fn:ident, $F:ty) => { @@ -211,6 +209,8 @@ impl_scalar_lhs!(Mul, mul, f32); impl_scalar_lhs!(Mul, mul, f64); +impl_scalar_lhs!(Div, div, f32); +impl_scalar_lhs!(Div, div, f64); macro_rules! impl_binary_mut { ($trait:ident, $fn:ident) => { @@ -308,8 +308,8 @@ A: AXPY<U, Field = F>, B: AXPY<V, Field = F>, F: Num, - Self: MulAssign<F>, - Pair<A, B>: MulAssign<F>, + Self: MulAssign<F> + DivAssign<F>, + Pair<A, B>: MulAssign<F> + DivAssign<F>, //A::Owned: MulAssign<F>, //B::Owned: MulAssign<F>, //Pair<A::Owned, B::Owned>: AXPY<Pair<U, V>, Field = F>,
--- a/src/linops.rs Mon May 12 15:42:48 2025 -0500 +++ b/src/linops.rs Mon May 12 16:28:50 2025 -0500 @@ -11,7 +11,7 @@ use numeric_literals::replace_float_literals; use serde::Serialize; use std::marker::PhantomData; -use std::ops::Mul; +use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign}; /// Trait for linear operators on `X`. pub trait Linear<X: Space>: Mapping<X> {} @@ -27,7 +27,21 @@ /// Efficient in-place summation. #[replace_float_literals(Self::Field::cast_from(literal))] -pub trait AXPY<X = Self>: Space + std::ops::MulAssign<Self::Field> +pub trait AXPY<X = Self>: + Space + + MulAssign<Self::Field> + + DivAssign<Self::Field> + + AddAssign<Self> + + AddAssign<Self::Owned> + + SubAssign<Self> + + SubAssign<Self::Owned> + + Mul<Self::Field, Output = Self::Owned> + + Div<Self::Field, Output = Self::Owned> + + Add<Self, Output = Self::Owned> + + Add<Self::Owned, Output = Self::Owned> + + Sub<Self, Output = Self::Owned> + + Sub<Self::Owned, Output = Self::Owned> + + Neg where X: Space, { @@ -504,8 +518,6 @@ #[derive(Clone, Copy, Debug, Serialize, Eq, PartialEq)] pub struct RowOp<S, T>(pub S, pub T); -use std::ops::Add; - impl<A, B, S, T> Mapping<Pair<A, B>> for RowOp<S, T> where A: Space,