src/kernels/mollifier.rs

branch
dev
changeset 35
b087e3eab191
parent 0
eb3c7813b67a
child 38
0f59c0d02e13
--- a/src/kernels/mollifier.rs	Thu Aug 29 00:00:00 2024 -0500
+++ b/src/kernels/mollifier.rs	Tue Dec 31 09:25:45 2024 -0500
@@ -2,7 +2,7 @@
 //! Implementation of the standard mollifier
 
 use rgsl::hypergeometric::hyperg_U;
-use float_extras::f64::{tgamma as gamma};
+use float_extras::f64::tgamma as gamma;
 use numeric_literals::replace_float_literals;
 use serde::Serialize;
 use alg_tools::types::*;
@@ -17,7 +17,7 @@
     LocalAnalysis,
     GlobalAnalysis
 };
-use alg_tools::mapping::Apply;
+use alg_tools::mapping::{Mapping, Instance};
 use alg_tools::maputil::array_init;
 
 /// Reresentation of the (unnormalised) standard mollifier.
@@ -36,13 +36,14 @@
 }
 
 #[replace_float_literals(C::Type::cast_from(literal))]
-impl<'a, C : Constant, const N : usize> Apply<&'a Loc<C::Type, N>> for Mollifier<C, N> {
-    type Output = C::Type;
+impl<C : Constant, const N : usize> Mapping<Loc<C::Type, N>> for Mollifier<C, N> {
+    type Codomain = C::Type;
+
     #[inline]
-    fn apply(&self, x : &'a Loc<C::Type, N>) -> Self::Output {
+    fn apply<I : Instance<Loc<C::Type, N>>>(&self, x : I) -> Self::Codomain {
         let ε = self.width.value();
         let ε2 = ε*ε;
-        let n2 = x.norm2_squared();
+        let n2 = x.eval(|x| x.norm2_squared());
         if n2 < ε2 {
             (n2 / (n2 - ε2)).exp()
         } else {
@@ -51,13 +52,6 @@
     }
 }
 
-impl<C : Constant, const N : usize> Apply<Loc<C::Type, N>> for Mollifier<C, N> {
-    type Output = C::Type;
-    #[inline]
-    fn apply(&self, x : Loc<C::Type, N>) -> Self::Output {
-        self.apply(&x)
-    }
-}
 
 impl<'a, C : Constant, const N : usize> Support<C::Type, N> for Mollifier<C, N> {
     #[inline]

mercurial