src/euclidean.rs

branch
dev
changeset 132
89371dc4d637
parent 124
6aa955ad8122
child 146
3f9a03f95457
--- a/src/euclidean.rs	Mon May 12 16:28:50 2025 -0500
+++ b/src/euclidean.rs	Mon May 12 19:30:41 2025 -0500
@@ -3,34 +3,27 @@
 */
 
 use crate::instance::Instance;
+use crate::linops::AXPY;
 use crate::norms::{HasDual, Reflexive};
 use crate::types::*;
-use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
+use std::ops::{Add, AddAssign, Sub, SubAssign};
 
 /// Space (type) with Euclidean and vector space structure
 ///
 /// The type should implement vector space operations (addition, subtraction, scalar
 /// multiplication and scalar division) along with their assignment versions, as well
 /// as an inner product.
+// TODO: remove F parameter, use AXPY::Field
 pub trait Euclidean<F: Float = f64>:
     HasDual<F, DualSpace = Self>
+    + AXPY<Field = F>
     + Reflexive<F>
-    + Mul<F, Output = <Self as Euclidean<F>>::Output>
-    + MulAssign<F>
-    + Div<F, Output = <Self as Euclidean<F>>::Output>
-    + DivAssign<F>
-    + Add<Self, Output = <Self as Euclidean<F>>::Output>
-    + Sub<Self, Output = <Self as Euclidean<F>>::Output>
-    + for<'b> Add<&'b Self, Output = <Self as Euclidean<F>>::Output>
-    + for<'b> Sub<&'b Self, Output = <Self as Euclidean<F>>::Output>
-    + AddAssign<Self>
+    // TODO: move the following to AXPY
+    + for<'b> Add<&'b Self, Output = <Self as AXPY>::Owned>
+    + for<'b> Sub<&'b Self, Output = <Self as AXPY>::Owned>
     + for<'b> AddAssign<&'b Self>
-    + SubAssign<Self>
     + for<'b> SubAssign<&'b Self>
-    + Neg<Output = <Self as Euclidean<F>>::Output>
 {
-    type Output: Euclidean<F>;
-
     // Inner product
     fn dot<I: Instance<Self>>(&self, other: I) -> F;
 
@@ -82,5 +75,5 @@
 /// Trait for [`Euclidean`] spaces with dimensions known at compile time.
 pub trait StaticEuclidean<F: Float = f64>: Euclidean<F> {
     /// Returns the origin
-    fn origin() -> <Self as Euclidean<F>>::Output;
+    fn origin() -> <Self as AXPY>::Owned;
 }

mercurial