src/norms.rs

branch
dev
changeset 86
d5b0e496b72f
parent 72
44a4f258a1ff
--- 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<F : Float, E : NormExponent>{
     pub(crate) exponent : E,
+    #[serde(skip)]
     _phantoms : PhantomData<F>
 }
 
@@ -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<A, B, J>(pub A, pub B, pub J);
 
 impl<A, B, J> NormExponent for PairNorm<A, B, J>
@@ -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<F : Float>(pub F);
 impl<F : Float> NormExponent for HuberL1<F> {}
 
@@ -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<F : Float>(pub F);
 impl<F : Float> NormExponent for HuberL21<F> {}
 

mercurial