--- a/src/types.rs Fri Apr 28 13:15:19 2023 +0300 +++ b/src/types.rs Tue Dec 31 09:34:24 2024 -0500 @@ -43,6 +43,22 @@ pub postprocessing : Option<DiscreteMeasure<Loc<F, N>, F>>, } +impl<F : Float, const N : usize> IterInfo<F, N> { + /// Initialise statistics with zeros. `ε` and `value` are unspecified. + pub fn new() -> Self { + IterInfo { + value : F::NAN, + n_spikes : 0, + this_iters : 0, + merged : 0, + pruned : 0, + inner_iters : 0, + ε : F::NAN, + postprocessing : None, + } + } +} + impl<F, const N : usize> LogRepr for IterInfo<F, N> where F : LogRepr + Float { fn logrepr(&self) -> ColoredString { format!("{}\t| N = {}, ε = {:.8}, inner_iters_mean = {}, merged+pruned_mean = {}+{}", @@ -95,3 +111,16 @@ } } } + +/// Type for indicating norm-2-squared data fidelity or transport cost. +#[derive(Clone, Copy, Serialize, Deserialize)] +pub struct L2Squared; + +/// Trait for indicating that `Self` is Lipschitz with respect to the (semi)norm `D`. +pub trait Lipschitz<D> { + /// The type of floats + type FloatType : Float; + + /// Returns the Lipschitz factor of `self` with respect to the (semi)norm `D`. + fn lipschitz_factor(&self, seminorm : D) -> Option<Self::FloatType>; +}