--- a/src/euclidean.rs Mon Sep 01 13:51:03 2025 -0500 +++ b/src/euclidean.rs Mon Sep 01 20:55:34 2025 -0500 @@ -4,9 +4,8 @@ use crate::instance::Instance; use crate::linops::{VectorSpace, AXPY}; -use crate::norms::{HasDual, Reflexive}; +use crate::norms::Reflexive; use crate::types::*; -use std::ops::{Add, AddAssign, Sub, SubAssign}; pub mod wrap; @@ -17,17 +16,13 @@ /// 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 +// TODO: remove F parameter, use VectorSpace::Field pub trait Euclidean<F: Float = f64>: - HasDual<F, DualSpace = Self> - + VectorSpace<Field = F> - + Reflexive<F> - // TODO: move the following to AXPY - + for<'b> Add<&'b Self, Output = <Self as VectorSpace>::Owned> - + for<'b> Sub<&'b Self, Output = <Self as VectorSpace>::Owned> - + for<'b> AddAssign<&'b Self> - + for<'b> SubAssign<&'b Self> + VectorSpace<Field = F, Owned = Self::OwnedEuclidean> + + Reflexive<F, DualSpace = Self::OwnedEuclidean> { + type OwnedEuclidean: ClosedEuclidean<F>; + // Inner product fn dot<I: Instance<Self>>(&self, other: I) -> F; @@ -71,10 +66,14 @@ } } +pub trait ClosedEuclidean<F: Float = f64>: + Instance<Self> + Euclidean<F, OwnedEuclidean = Self> +{ +} +impl<F: Float, X: Instance<X> + Euclidean<F, OwnedEuclidean = Self>> ClosedEuclidean<F> for X {} + // TODO: remove F parameter, use AXPY::Field -pub trait EuclideanMut<F: Float = f64>: - Euclidean<F> + AXPY<Field = F> + for<'b> AddAssign<&'b Self> + for<'b> SubAssign<&'b Self> -{ +pub trait EuclideanMut<F: Float = f64>: Euclidean<F> + AXPY<Field = F> { /// In-place projection to the 2-ball. #[inline] fn proj_ball2_mut(&mut self, ρ: F) { @@ -85,10 +84,7 @@ } } -impl<X, F: Float> EuclideanMut<F> for X where - X: Euclidean<F> + AXPY<Field = F> + for<'b> AddAssign<&'b Self> + for<'b> SubAssign<&'b Self> -{ -} +impl<X, F: Float> EuclideanMut<F> for X where X: Euclidean<F> + AXPY<Field = F> {} /// Trait for [`Euclidean`] spaces with dimensions known at compile time. pub trait StaticEuclidean<F: Float = f64>: Euclidean<F> {