diff -r 99ad55974e62 -r d5b0e496b72f src/norms.rs --- a/src/norms.rs Mon Dec 30 15:46:28 2024 -0500 +++ b/src/norms.rs Mon Jan 06 20:29:25 2025 -0500 @@ -2,7 +2,7 @@ Norms, projections, etc. */ -use serde::Serialize; +use serde::{Serialize, Deserialize}; use std::marker::PhantomData; use crate::types::*; use crate::euclidean::*; @@ -12,10 +12,11 @@ // Abstract norms // -#[derive(Copy,Clone,Debug)] +#[derive(Copy,Clone,Debug, Serialize, Deserialize)] /// Helper structure to convert a [`NormExponent`] into a [`Mapping`] pub struct NormMapping{ pub(crate) exponent : E, + #[serde(skip)] _phantoms : PhantomData } @@ -30,29 +31,29 @@ } /// Exponent type for the 1-[`Norm`]. -#[derive(Copy,Debug,Clone,Serialize,Eq,PartialEq)] +#[derive(Copy,Debug,Clone,Serialize,Deserialize,Eq,PartialEq)] pub struct L1; impl NormExponent for L1 {} /// Exponent type for the 2-[`Norm`]. -#[derive(Copy,Debug,Clone,Serialize,Eq,PartialEq)] +#[derive(Copy,Debug,Clone,Serialize,Deserialize,Eq,PartialEq)] pub struct L2; impl NormExponent for L2 {} /// Exponent type for the ∞-[`Norm`]. -#[derive(Copy,Debug,Clone,Serialize,Eq,PartialEq)] +#[derive(Copy,Debug,Clone,Serialize,Deserialize,Eq,PartialEq)] pub struct Linfinity; impl NormExponent for Linfinity {} /// Exponent type for 2,1-[`Norm`]. /// (1-norm over a domain Ω, 2-norm of a vector at each point of the domain.) -#[derive(Copy,Debug,Clone,Serialize,Eq,PartialEq)] +#[derive(Copy,Debug,Clone,Serialize,Deserialize,Eq,PartialEq)] pub struct L21; impl NormExponent for L21 {} /// Norms for pairs (a, b). ‖(a,b)‖ = ‖(‖a‖_A, ‖b‖_B)‖_J /// For use with [`crate::direct_product::Pair`] -#[derive(Copy,Debug,Clone,Serialize,Eq,PartialEq)] +#[derive(Copy,Debug,Clone,Serialize,Deserialize,Eq,PartialEq)] pub struct PairNorm(pub A, pub B, pub J); impl NormExponent for PairNorm @@ -63,7 +64,7 @@ /// /// The parameter γ of this type is the smoothing factor. Zero means no smoothing, and higher /// values more smoothing. Behaviour with γ < 0 is undefined. -#[derive(Copy,Debug,Clone,Serialize,Eq,PartialEq)] +#[derive(Copy,Debug,Clone,Serialize,Deserialize,Eq,PartialEq)] pub struct HuberL1(pub F); impl NormExponent for HuberL1 {} @@ -71,7 +72,7 @@ /// /// The parameter γ of this type is the smoothing factor. Zero means no smoothing, and higher /// values more smoothing. Behaviour with γ < 0 is undefined. -#[derive(Copy,Debug,Clone,Serialize,Eq,PartialEq)] +#[derive(Copy,Debug,Clone,Serialize,Deserialize,Eq,PartialEq)] pub struct HuberL21(pub F); impl NormExponent for HuberL21 {}