# HG changeset patch # User Tuomo Valkonen # Date 1747096241 18000 # Node ID 89371dc4d637920b80a5f051609105ee282e704f # Parent 0a689881b0f1d353078fbcc04cd170e9b644c8b6 Make Euclidean depend on AXPY diff -r 0a689881b0f1 -r 89371dc4d637 src/convex.rs --- a/src/convex.rs Mon May 12 16:28:50 2025 -0500 +++ b/src/convex.rs Mon May 12 19:30:41 2025 -0500 @@ -401,7 +401,7 @@ impl Prox for Norm222 where F: Float, - X: Euclidean, + X: Euclidean, { type Prox<'a> = Scaled @@ -416,7 +416,7 @@ impl DifferentiableImpl for Norm222 where F: Float, - X: Euclidean, + X: Euclidean, { type Derivative = X; @@ -428,7 +428,7 @@ impl LipschitzDifferentiableImpl for Norm222 where F: Float, - X: Euclidean, + X: Euclidean, { type FloatType = F; diff -r 0a689881b0f1 -r 89371dc4d637 src/direct_product.rs --- a/src/direct_product.rs Mon May 12 16:28:50 2025 -0500 +++ b/src/direct_product.rs Mon May 12 19:30:41 2025 -0500 @@ -270,22 +270,20 @@ B: Euclidean, //Pair: Euclidean, Self: Sized - + Mul> + + Mul::Owned> + MulAssign - + Div> + + Div::Owned> + DivAssign - + Add> - + Sub> - + for<'b> Add<&'b Self, Output = Pair> - + for<'b> Sub<&'b Self, Output = Pair> + + Add::Owned> + + Sub::Owned> + + for<'b> Add<&'b Self, Output = ::Owned> + + for<'b> Sub<&'b Self, Output = ::Owned> + AddAssign + for<'b> AddAssign<&'b Self> + SubAssign + for<'b> SubAssign<&'b Self> - + Neg>, + + Neg::Owned>, { - type Output = Pair; - fn dot>(&self, other: I) -> F { let Pair(u, v) = other.decompose(); self.0.dot(u) + self.1.dot(v) diff -r 0a689881b0f1 -r 89371dc4d637 src/euclidean.rs --- 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: HasDual + + AXPY + Reflexive - + Mul>::Output> - + MulAssign - + Div>::Output> - + DivAssign - + Add>::Output> - + Sub>::Output> - + for<'b> Add<&'b Self, Output = >::Output> - + for<'b> Sub<&'b Self, Output = >::Output> - + AddAssign + // TODO: move the following to AXPY + + for<'b> Add<&'b Self, Output = ::Owned> + + for<'b> Sub<&'b Self, Output = ::Owned> + for<'b> AddAssign<&'b Self> - + SubAssign + for<'b> SubAssign<&'b Self> - + Neg>::Output> { - type Output: Euclidean; - // Inner product fn dot>(&self, other: I) -> F; @@ -82,5 +75,5 @@ /// Trait for [`Euclidean`] spaces with dimensions known at compile time. pub trait StaticEuclidean: Euclidean { /// Returns the origin - fn origin() -> >::Output; + fn origin() -> ::Owned; } diff -r 0a689881b0f1 -r 89371dc4d637 src/loc.rs --- a/src/loc.rs Mon May 12 16:28:50 2025 -0500 +++ b/src/loc.rs Mon May 12 19:30:41 2025 -0500 @@ -433,8 +433,6 @@ domination!(L2, L1); impl Euclidean for Loc { - type Output = Self; - /// This implementation is not stabilised as it's meant to be used for very small vectors. /// Use [`nalgebra`] for larger vectors. #[inline] diff -r 0a689881b0f1 -r 89371dc4d637 src/nalgebra_support.rs --- a/src/nalgebra_support.rs Mon May 12 16:28:50 2025 -0500 +++ b/src/nalgebra_support.rs Mon May 12 19:30:41 2025 -0500 @@ -222,8 +222,6 @@ E: Float + Scalar + Zero + One + RealField, DefaultAllocator: Allocator, { - type Output = OVector; - #[inline] fn dot>(&self, other: I) -> E { Vector::::dot(self, other.ref_instance())