diff -r efa60bc4f743 -r b087e3eab191 src/kernels/hat.rs --- a/src/kernels/hat.rs Thu Aug 29 00:00:00 2024 -0500 +++ b/src/kernels/hat.rs Tue Dec 31 09:25:45 2024 -0500 @@ -14,8 +14,9 @@ GlobalAnalysis, Bounded, }; -use alg_tools::mapping::Apply; -use alg_tools::maputil::{array_init}; +use alg_tools::mapping::{Mapping, Instance}; +use alg_tools::maputil::array_init; +use crate::types::Lipschitz; /// Representation of the hat function $f(x)=1-\\|x\\|\_1/ε$ of `width` $ε$ on $ℝ^N$. #[derive(Copy,Clone,Serialize,Debug,Eq,PartialEq)] @@ -25,26 +26,17 @@ } #[replace_float_literals(C::Type::cast_from(literal))] -impl<'a, C : Constant, const N : usize> Apply<&'a Loc> for Hat { - type Output = C::Type; +impl<'a, C : Constant, const N : usize> Mapping> for Hat { + type Codomain = C::Type; + #[inline] - fn apply(&self, x : &'a Loc) -> Self::Output { + fn apply>>(&self, x : I) -> Self::Codomain { let ε = self.width.value(); - 0.0.max(1.0-x.norm(L1)/ε) + 0.0.max(1.0-x.cow().norm(L1)/ε) } } #[replace_float_literals(C::Type::cast_from(literal))] -impl Apply> for Hat { - type Output = C::Type; - #[inline] - fn apply(&self, x : Loc) -> Self::Output { - self.apply(&x) - } -} - - -#[replace_float_literals(C::Type::cast_from(literal))] impl<'a, C : Constant, const N : usize> Support for Hat { #[inline] fn support_hint(&self) -> Cube { @@ -94,6 +86,26 @@ } } +#[replace_float_literals(C::Type::cast_from(literal))] +impl<'a, C : Constant, const N : usize> Lipschitz for Hat { + type FloatType = C::Type; + + fn lipschitz_factor(&self, _l1 : L1) -> Option { + Some(1.0/self.width.value()) + } +} + +#[replace_float_literals(C::Type::cast_from(literal))] +impl<'a, C : Constant, const N : usize> Lipschitz for Hat { + type FloatType = C::Type; + + fn lipschitz_factor(&self, _l2 : L2) -> Option { + self.lipschitz_factor(L1).map(|l1| + >>::from_norm(&L2, l1, L1) + ) + } +} + impl<'a, C : Constant, const N : usize> LocalAnalysis, N> for Hat {