diff -r df9628092285 -r 8979a6638424 src/dist.rs --- a/src/dist.rs Mon Oct 21 08:44:23 2024 -0500 +++ b/src/dist.rs Mon Oct 21 10:02:57 2024 -0500 @@ -4,15 +4,13 @@ use crate::fb::{Grad, Desc}; /// Structure for distance-to functions -pub struct DistTo { - base : M -} +pub struct DistTo(pub M); impl Apply for DistTo { type Output = f64; fn apply(&self, x : M) -> Self::Output { - self.base.dist_to(&x) + self.0.dist_to(&x) } } @@ -20,20 +18,18 @@ type Output = f64; fn apply(&self, x : &'a M) -> Self::Output { - self.base.dist_to(x) + self.0.dist_to(x) } } /// Structure for distance-to functions -pub struct DistToSquaredDiv2 { - base : M -} +pub struct DistToSquaredDiv2(pub M); impl Apply for DistToSquaredDiv2 { type Output = f64; fn apply(&self, x : M) -> Self::Output { - let d = self.base.dist_to(&x); + let d = self.0.dist_to(&x); d*d / 2.0 } } @@ -42,7 +38,7 @@ type Output = f64; fn apply(&self, x : &'a M) -> Self::Output { - let d = self.base.dist_to(x); + let d = self.0.dist_to(x); d*d / 2.0 } } @@ -55,6 +51,6 @@ impl Grad for DistToSquaredDiv2 { fn grad(&self, x : &M) -> M::Tangent { - x.log(&self.base) + x.log(&self.0) } }