diff -r 2f1798c65fd6 -r c4e394a9c84c src/nalgebra_support.rs --- a/src/nalgebra_support.rs Mon Sep 01 00:04:22 2025 -0500 +++ b/src/nalgebra_support.rs Mon Sep 01 13:51:03 2025 -0500 @@ -9,7 +9,7 @@ */ use crate::euclidean::*; -use crate::instance::Instance; +use crate::instance::{Instance, Ownable}; use crate::linops::*; use crate::mapping::{BasicDecomposition, Space}; use crate::norms::*; @@ -24,14 +24,36 @@ use num_traits::identities::{One, Zero}; use std::ops::Mul; +impl Ownable for Matrix +where + S: Storage, + M: Dim, + N: Dim, + E: Scalar + Zero + One, + DefaultAllocator: Allocator, +{ + type OwnedVariant = OMatrix; + + #[inline] + fn into_owned(self) -> Self::OwnedVariant { + Matrix::into_owned(self) + } + + /// Returns an owned instance of a reference. + fn clone_owned(&self) -> Self::OwnedVariant { + Matrix::clone_owned(self) + } +} + impl Space for Matrix where - SM: Storage + Clone, + SM: Storage, N: Dim, M: Dim, - E: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign, + E: Scalar + Zero + One, DefaultAllocator: Allocator, { + type OwnedSpace = OMatrix; type Decomp = BasicDecomposition; } @@ -103,10 +125,9 @@ } } -impl AXPY> for Matrix +impl VectorSpace for Matrix where - SM: StorageMut + Clone, - SV1: Storage + Clone, + S: Storage, M: Dim, N: Dim, E: Scalar + Zero + One + Float, @@ -116,6 +137,22 @@ type Owned = OMatrix; #[inline] + fn similar_origin(&self) -> Self::Owned { + let (n, m) = self.shape_generic(); + OMatrix::zeros_generic(n, m) + } +} + +impl AXPY> for Matrix +where + SM: StorageMut, + SV1: Storage, + M: Dim, + N: Dim, + E: Scalar + Zero + One + Float, + DefaultAllocator: Allocator, +{ + #[inline] fn axpy>>(&mut self, α: E, x: I, β: E) { x.eval(|x̃| { assert_eq!(self.ncols(), x̃.ncols()); @@ -136,12 +173,6 @@ fn set_zero(&mut self) { self.iter_mut().for_each(|e| *e = E::ZERO); } - - #[inline] - fn similar_origin(&self) -> Self::Owned { - let (n, m) = self.shape_generic(); - OMatrix::zeros_generic(n, m) - } } /* Implemented automatically as Euclidean. @@ -160,6 +191,21 @@ impl Projection for Vector where + SM: Storage + Clone, + M: Dim, + E: Scalar + Zero + One + Float + RealField, + DefaultAllocator: Allocator, +{ + #[inline] + fn proj_ball(self, ρ: E, exp: Linfinity) -> ::OwnedSpace { + let mut owned = self.into_owned(); + owned.proj_ball_mut(ρ, exp); + owned + } +} + +impl ProjectionMut for Vector +where SM: StorageMut + Clone, M: Dim, E: Scalar + Zero + One + Float + RealField,