src/mapping.rs

branch
dev
changeset 80
f802ddbabcfc
parent 68
c5f70e767511
--- a/src/mapping.rs	Tue Dec 31 08:48:50 2024 -0500
+++ b/src/mapping.rs	Mon Dec 23 23:27:45 2024 -0500
@@ -9,11 +9,20 @@
 pub use crate::instance::{Instance, Decomposition, BasicDecomposition, Space};
 use crate::norms::{Norm, NormExponent};
 
+pub trait ArithmeticOptIn {}
+
+pub struct ArithmeticTrue;
+pub struct ArithmeticFalse;
+
+impl ArithmeticOptIn for ArithmeticTrue {}
+impl ArithmeticOptIn for ArithmeticFalse {}
+
 /// A mapping from `Domain` to `Codomain`.
 ///
 /// This is automatically implemented when the relevant [`Apply`] are implemented.
 pub trait Mapping<Domain : Space> {
     type Codomain : Space;
+    type ArithmeticOptIn : ArithmeticOptIn;
 
     /// Compute the value of `self` at `x`.
     fn apply<I : Instance<Domain>>(&self, x : I) -> Self::Codomain;
@@ -154,6 +163,7 @@
     M::Codomain : std::iter::Sum + Clone
 {
     type Codomain = M::Codomain;
+    type ArithmeticOptIn = ArithmeticTrue;
 
     fn apply<I : Instance<Domain>>(&self, x : I) -> Self::Codomain {
         let xr = x.ref_instance();
@@ -193,6 +203,7 @@
     G : Clone + DifferentiableMapping<X>
 {
     type Codomain = G::DerivativeDomain;
+    type ArithmeticOptIn = ArithmeticTrue;
 
     #[inline]
     fn apply<I : Instance<X>>(&self, x : I) -> Self::Codomain {
@@ -212,6 +223,7 @@
     G: Mapping<X, Codomain=Loc<F, 1>>
 {
     type Codomain = F;
+    type ArithmeticOptIn = ArithmeticTrue;
 
     #[inline]
     fn apply<I : Instance<X>>(&self, x : I) -> Self::Codomain {
@@ -244,6 +256,7 @@
     G : Mapping<X, Codomain=Loc<F, N>> + Clone,
 {
     type Codomain = F;
+    type ArithmeticOptIn = ArithmeticTrue;
 
     #[inline]
     fn apply<I : Instance<X>>(&self, x : I) -> Self::Codomain {
@@ -290,6 +303,7 @@
     S : Mapping<T::Codomain>
 {
     type Codomain = S::Codomain;
+    type ArithmeticOptIn = ArithmeticTrue;
 
     #[inline]
     fn apply<I : Instance<X>>(&self, x : I) -> Self::Codomain {

mercurial