src/discrete_gradient.rs

branch
dev
changeset 86
d5b0e496b72f
parent 74
2c76df38d02b
--- a/src/discrete_gradient.rs	Mon Dec 30 15:46:28 2024 -0500
+++ b/src/discrete_gradient.rs	Mon Jan 06 20:29:25 2025 -0500
@@ -2,6 +2,7 @@
 Simple disrete gradient operators
  */
 use numeric_literals::replace_float_literals;
+use serde::{Serialize, Deserialize};
 use nalgebra::{
     DVector, Matrix, U1, Storage, StorageMut, Dyn
 };
@@ -10,23 +11,32 @@
 use crate::linops::{Mapping, Linear, BoundedLinear, Adjointable, GEMV};
 use crate::norms::{Norm, L2};
 
-#[derive(Copy, Clone, Debug)]
+#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
 /// Forward differences with Neumann boundary conditions
 pub struct ForwardNeumann;
 
-#[derive(Copy, Clone, Debug)]
+#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
 /// Forward differences with Dirichlet boundary conditions
 pub struct ForwardDirichlet;
 
-#[derive(Copy, Clone, Debug)]
+#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
 /// Backward differences with Dirichlet boundary conditions
 pub struct BackwardDirichlet;
 
-#[derive(Copy, Clone, Debug)]
+#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
 /// Backward differences with Neumann boundary conditions
 pub struct BackwardNeumann;
 
 /// Finite differences gradient
+#[derive(Clone, Debug, Serialize, Deserialize)]
+#[serde(bound(
+    serialize = "[usize; N] : Serialize,
+                 B : Serialize,
+                 F : Serialize,",
+    deserialize = "[usize; N] : for<'a> Deserialize<'a>,
+                   B : for<'a> Deserialize<'a>,
+                   F : for<'a> Deserialize<'a>,"
+))]
 pub struct Grad<
     F : Float + nalgebra::RealField,
     B : Discretisation<F>,

mercurial