diff -r 848ecc05becf -r 05089fbc0310 src/mapping.rs --- a/src/mapping.rs Tue Dec 31 09:02:55 2024 -0500 +++ b/src/mapping.rs Tue Dec 31 08:30:43 2024 -0500 @@ -4,10 +4,11 @@ use std::marker::PhantomData; use std::borrow::Cow; -use crate::types::Float; +use crate::types::{Num, Float}; use serde::Serialize; use crate::loc::Loc; pub use crate::instance::{Instance, Decomposition, BasicDecomposition, Space}; +use crate::norms::{Norm, NormExponent}; /// A mapping from `Domain` to `Codomain`. /// @@ -17,6 +18,33 @@ /// Compute the value of `self` at `x`. fn apply>(&self, x : I) -> Self::Codomain; + + #[inline] + /// Form the composition `self ∘ other` + fn compose>(self, other : T) + -> Composition + where + Self : Sized + { + Composition{ outer : self, inner : other, intermediate_norm_exponent : () } + } + + + #[inline] + /// Form the composition `self ∘ other`, assigning a norm to the inermediate space + fn compose_with_norm( + self, other : T, norm : E + ) -> Composition + where + Self : Sized, + X : Space, + T : Mapping, + E : NormExponent, + Domain : Norm, + F : Num + { + Composition{ outer : self, inner : other, intermediate_norm_exponent : norm } + } } /// Automatically implemented shorthand for referring to [`Mapping`]s from [`Loc`] to `F`. @@ -236,3 +264,25 @@ impl> + Clone, const N : usize> SliceCodomain for G {} + + +/// The composition S ∘ T. `E` is for storing a `NormExponent` for the intermediate space. +pub struct Composition { + pub outer : S, + pub inner : T, + pub intermediate_norm_exponent : E +} + +impl Mapping for Composition +where + X : Space, + T : Mapping, + S : Mapping +{ + type Codomain = S::Codomain; + + #[inline] + fn apply>(&self, x : I) -> Self::Codomain { + self.outer.apply(self.inner.apply(x)) + } +}