diff -r 102421d462d1 -r 53ab61a41d70 src/nalgebra_support.rs --- a/src/nalgebra_support.rs Wed Sep 03 21:03:47 2025 -0500 +++ b/src/nalgebra_support.rs Wed Sep 03 21:31:13 2025 -0500 @@ -389,7 +389,7 @@ impl Projection for Vector where - SM: StorageMut + Clone, + SM: StorageMut, M: Dim, E: Scalar + Zero + One + Float + RealField, DefaultAllocator: Allocator, @@ -405,7 +405,7 @@ impl ProjectionMut for Vector where - SM: StorageMut + Clone, + SM: StorageMut, M: Dim, E: Scalar + Zero + One + Copy + Float + RealField, DefaultAllocator: Allocator, @@ -464,26 +464,25 @@ }) } -// TODO: should allow different input storages in `Euclidean`. - -impl Euclidean for Vector +impl Euclidean for Matrix where M: Dim, - S: Storage, + N: Dim, + S: Storage, E: Float + Scalar + Zero + One + RealField, - DefaultAllocator: Allocator, - ShapeConstraint: StridesOk, + DefaultAllocator: Allocator, + ShapeConstraint: StridesOk, { - type PrincipalE = OVector; + type PrincipalE = OMatrix; #[inline] fn dot>(&self, other: I) -> E { - other.eval_ref(|ref r| Vector::::dot(self, r)) + other.eval_ref(|ref r| Matrix::::dot(self, r)) } #[inline] fn norm2_squared(&self) -> E { - Vector::::norm_squared(self) + Matrix::::norm_squared(self) } #[inline] @@ -507,13 +506,14 @@ } /// The default norm for `Vector` is [`L2`]. -impl Normed for Vector +impl Normed for Matrix where M: Dim, - S: Storage, + N: Dim, + S: Storage, E: Float + Scalar + Zero + One + RealField, - DefaultAllocator: Allocator, - ShapeConstraint: StridesOk, + DefaultAllocator: Allocator, + ShapeConstraint: StridesOk, { type NormExp = L2; @@ -524,22 +524,24 @@ #[inline] fn is_zero(&self) -> bool { - Vector::::norm_squared(self) == E::ZERO + Matrix::::norm_squared(self) == E::ZERO } } -impl HasDual for Vector +impl HasDual for Matrix where M: Dim, - S: Storage, + N: Dim, + S: Storage, E: Float + Scalar + Zero + One + RealField, - DefaultAllocator: Allocator, - ShapeConstraint: StridesOk, + DefaultAllocator: Allocator, + ShapeConstraint: StridesOk, { - type DualSpace = OVector; + type DualSpace = OMatrix; - fn dual_origin(&self) -> OVector { - OVector::zeros_generic(M::from_usize(self.len()), Const) + fn dual_origin(&self) -> OMatrix { + let (m, n) = self.shape_generic(); + OMatrix::zeros_generic(m, n) } } @@ -560,7 +562,7 @@ impl Dist for Vector where M: Dim, - S: Storage + Clone, + S: Storage, E: Float + Scalar + Zero + One + RealField, DefaultAllocator: Allocator, ShapeConstraint: StridesOk, @@ -571,13 +573,14 @@ } } -impl Norm for Vector +impl Norm for Matrix where M: Dim, - S: Storage, + N: Dim, + S: Storage, E: Float + Scalar + Zero + One + RealField, - DefaultAllocator: Allocator, - ShapeConstraint: StridesOk, + DefaultAllocator: Allocator, + ShapeConstraint: StridesOk, { #[inline] fn norm(&self, _: L2) -> E { @@ -585,13 +588,14 @@ } } -impl Dist for Vector +impl Dist for Matrix where M: Dim, - S: Storage + Clone, + N: Dim, + S: Storage, E: Float + Scalar + Zero + One + RealField, - DefaultAllocator: Allocator, - ShapeConstraint: StridesOk, + DefaultAllocator: Allocator, + ShapeConstraint: StridesOk, { #[inline] fn dist>(&self, other: I, _: L2) -> E { @@ -599,13 +603,14 @@ } } -impl Norm for Vector +impl Norm for Matrix where M: Dim, - S: Storage, + N: Dim, + S: Storage, E: Float + Scalar + Zero + One + RealField, - DefaultAllocator: Allocator, - ShapeConstraint: StridesOk, + DefaultAllocator: Allocator, + ShapeConstraint: StridesOk, { #[inline] fn norm(&self, _: Linfinity) -> E { @@ -613,13 +618,14 @@ } } -impl Dist for Vector +impl Dist for Matrix where M: Dim, - S: Storage + Clone, + N: Dim, + S: Storage, E: Float + Scalar + Zero + One + RealField, - DefaultAllocator: Allocator, - ShapeConstraint: StridesOk, + DefaultAllocator: Allocator, + ShapeConstraint: StridesOk, { #[inline] fn dist>(&self, other: I, _: Linfinity) -> E {