Sun, 18 May 2025 23:31:48 -0500
Dist argument order changed to reflect other changes
| src/loc.rs | file | annotate | diff | comparison | revisions | |
| src/nalgebra_support.rs | file | annotate | diff | comparison | revisions | |
| src/norms.rs | file | annotate | diff | comparison | revisions |
--- a/src/loc.rs Sun May 18 23:15:50 2025 -0500 +++ b/src/loc.rs Sun May 18 23:31:48 2025 -0500 @@ -608,7 +608,7 @@ } } -impl<F: Float, const N: usize> Dist<F, L2> for Loc<N, F> { +impl<F: Float, const N: usize> Dist<L2, F> for Loc<N, F> { #[inline] fn dist<I: Instance<Self>>(&self, other: I, _: L2) -> F { self.dist2(other) @@ -635,7 +635,7 @@ } } -impl<F: Float, const N: usize> Dist<F, L1> for Loc<N, F> { +impl<F: Float, const N: usize> Dist<L1, F> for Loc<N, F> { #[inline] fn dist<I: Instance<Self>>(&self, other: I, _: L1) -> F { other.eval_ref_decompose(|r| { @@ -663,7 +663,7 @@ } } -impl<F: Float, const N: usize> Dist<F, Linfinity> for Loc<N, F> { +impl<F: Float, const N: usize> Dist<Linfinity, F> for Loc<N, F> { #[inline] fn dist<I: Instance<Self>>(&self, other: I, _: Linfinity) -> F { other.eval_ref_decompose(|r| {
--- a/src/nalgebra_support.rs Sun May 18 23:15:50 2025 -0500 +++ b/src/nalgebra_support.rs Sun May 18 23:31:48 2025 -0500 @@ -300,7 +300,7 @@ } } -impl<E, M, S> Dist<E, L1> for Vector<E, M, S> +impl<E, M, S> Dist<L1, E> for Vector<E, M, S> where M: Dim, S: Storage<E, M> + Clone, @@ -326,7 +326,7 @@ } } -impl<E, M, S> Dist<E, L2> for Vector<E, M, S> +impl<E, M, S> Dist<L2, E> for Vector<E, M, S> where M: Dim, S: Storage<E, M> + Clone, @@ -352,7 +352,7 @@ } } -impl<E, M, S> Dist<E, Linfinity> for Vector<E, M, S> +impl<E, M, S> Dist<Linfinity, E> for Vector<E, M, S> where M: Dim, S: Storage<E, M> + Clone,
--- a/src/norms.rs Sun May 18 23:15:50 2025 -0500 +++ b/src/norms.rs Sun May 18 23:31:48 2025 -0500 @@ -26,10 +26,7 @@ pub trait NormExponent: Copy { /// Return the norm as a mappin fn as_mapping<F: Float>(self) -> NormMapping<F, Self> { - NormMapping { - exponent: self, - _phantoms: PhantomData, - } + NormMapping { exponent: self, _phantoms: PhantomData } } } @@ -111,7 +108,7 @@ } /// Trait for distances with respect to a norm. -pub trait Dist<F: Num, Exponent: NormExponent>: Norm<Exponent, F> + Space { +pub trait Dist<Exponent: NormExponent, F: Num = f64>: Norm<Exponent, F> + Space { /// Calculate the distance fn dist<I: Instance<Self>>(&self, other: I, _p: Exponent) -> F; } @@ -183,7 +180,7 @@ } } -impl<F: Float, E: Euclidean<F> + Normed<F, NormExp = L2>> Dist<F, HuberL1<F>> for E { +impl<F: Float, E: Euclidean<F> + Normed<F, NormExp = L2>> Dist<HuberL1<F>, F> for E { fn dist<I: Instance<Self>>(&self, other: I, huber: HuberL1<F>) -> F { huber.apply(self.dist2_squared(other)) } @@ -195,7 +192,7 @@ // } // } -// impl<F : Float, E : Dist<F, L2>> Dist<F, L21> for Vec<E> { +// impl<F : Float, E : Dist<F, L2>> Dist<L21, F> for Vec<E> { // fn dist<I : Instance<Self>>(&self, other : I, _l21 : L21) -> F { // self.iter().zip(other.iter()).map(|(e, g)| e.dist(g, L2)).sum() // }