src/nalgebra_support.rs

branch
dev
changeset 64
4f6ca107ccb1
parent 63
f7b87d84864d
child 70
672aec2e1acd
child 80
f802ddbabcfc
--- a/src/nalgebra_support.rs	Sun Dec 22 14:54:46 2024 -0500
+++ b/src/nalgebra_support.rs	Sun Dec 22 15:30:34 2024 -0500
@@ -198,8 +198,8 @@
     }
 
     #[inline]
-    fn dist2_squared(&self, other : &Self) -> E {
-        metric_distance_squared(self, other)
+    fn dist2_squared<I : Instance<Self>>(&self, other : I) -> E {
+        metric_distance_squared(self, other.ref_instance())
     }
 }
 
@@ -263,12 +263,12 @@
 impl<E,M,S> Dist<E, L1>
 for Vector<E,M,S>
 where M : Dim,
-      S : Storage<E,M>,
+      S : Storage<E,M> + Clone,
       E : Float + Scalar + Zero + One + RealField,
       DefaultAllocator : Allocator<M> {
     #[inline]
-    fn dist(&self, other : &Self, _ : L1) -> E {
-        LpNorm(1).metric_distance(self, other)
+    fn dist<I : Instance<Self>>(&self, other : I, _ : L1) -> E {
+        LpNorm(1).metric_distance(self, other.ref_instance())
     }
 }
 
@@ -288,12 +288,12 @@
 impl<E,M,S> Dist<E, L2>
 for Vector<E,M,S>
 where M : Dim,
-      S : Storage<E,M>,
+      S : Storage<E,M> + Clone,
       E : Float + Scalar + Zero + One + RealField,
       DefaultAllocator : Allocator<M> {
     #[inline]
-    fn dist(&self, other : &Self, _ : L2) -> E {
-        LpNorm(2).metric_distance(self, other)
+    fn dist<I : Instance<Self>>(&self, other : I, _ : L2) -> E {
+        LpNorm(2).metric_distance(self, other.ref_instance())
     }
 }
 
@@ -313,12 +313,12 @@
 impl<E,M,S> Dist<E, Linfinity>
 for Vector<E,M,S>
 where M : Dim,
-      S : Storage<E,M>,
+      S : Storage<E,M> + Clone,
       E : Float + Scalar + Zero + One + RealField,
       DefaultAllocator : Allocator<M> {
     #[inline]
-    fn dist(&self, other : &Self, _ : Linfinity) -> E {
-        UniformNorm.metric_distance(self, other)
+    fn dist<I : Instance<Self>>(&self, other : I, _ : Linfinity) -> E {
+        UniformNorm.metric_distance(self, other.ref_instance())
     }
 }
 

mercurial