diff -r 2f1798c65fd6 -r c4e394a9c84c src/mapping.rs --- a/src/mapping.rs Mon Sep 01 00:04:22 2025 -0500 +++ b/src/mapping.rs Mon Sep 01 13:51:03 2025 -0500 @@ -4,7 +4,7 @@ use crate::error::DynResult; use crate::instance::MyCow; -pub use crate::instance::{BasicDecomposition, Decomposition, Instance, Space}; +pub use crate::instance::{BasicDecomposition, ClosedSpace, Decomposition, Instance, Space}; use crate::loc::Loc; use crate::norms::{Norm, NormExponent}; use crate::operator_arithmetic::{Constant, Weighted}; @@ -14,7 +14,7 @@ /// A mapping from `Domain` to `Self::Codomain`. pub trait Mapping { - type Codomain: Space; + type Codomain: ClosedSpace; /// Compute the value of `self` at `x`. fn apply>(&self, x: I) -> Self::Codomain; @@ -25,11 +25,7 @@ where Self: Sized, { - Composition { - outer: self, - inner: other, - intermediate_norm_exponent: (), - } + Composition { outer: self, inner: other, intermediate_norm_exponent: () } } #[inline] @@ -43,11 +39,7 @@ Domain: Norm, F: Num, { - Composition { - outer: self, - inner: other, - intermediate_norm_exponent: norm, - } + Composition { outer: self, inner: other, intermediate_norm_exponent: norm } } /// Multiply `self` by the scalar `a`. @@ -58,10 +50,7 @@ C: Constant, Self::Codomain: ClosedMul, { - Weighted { - weight: a, - base_fn: self, - } + Weighted { weight: a, base_fn: self } } } @@ -86,7 +75,7 @@ /// /// This is automatically implemented when [`DifferentiableImpl`] is. pub trait DifferentiableMapping: Mapping { - type DerivativeDomain: Space; + type DerivativeDomain: ClosedSpace; type Differential<'b>: Mapping where Self: 'b; @@ -115,7 +104,7 @@ /// Helper trait for implementing [`DifferentiableMapping`] pub trait DifferentiableImpl: Sized { - type Derivative: Space; + type Derivative: ClosedSpace; /// Compute the differential of `self` at `x`, consuming the input. fn differential_impl>(&self, x: I) -> Self::Derivative; @@ -138,17 +127,11 @@ } fn diff(self) -> Differential<'static, Domain, Self> { - Differential { - g: MyCow::Owned(self), - _space: PhantomData, - } + Differential { g: MyCow::Owned(self), _space: PhantomData } } fn diff_ref(&self) -> Differential<'_, Domain, Self> { - Differential { - g: MyCow::Borrowed(self), - _space: PhantomData, - } + Differential { g: MyCow::Borrowed(self), _space: PhantomData } } } @@ -201,10 +184,7 @@ pub trait FlattenCodomain: Mapping> + Sized { /// Flatten the codomain from [`Loc`]`` to `F`. fn flatten_codomain(self) -> FlattenedCodomain { - FlattenedCodomain { - g: self, - _phantoms: PhantomData, - } + FlattenedCodomain { g: self, _phantoms: PhantomData } } } @@ -241,21 +221,13 @@ /// Flatten the codomain from [`Loc`]`` to `F`. fn slice_codomain(self, slice: usize) -> SlicedCodomain<'static, X, F, Self, N> { assert!(slice < N); - SlicedCodomain { - g: MyCow::Owned(self), - slice, - _phantoms: PhantomData, - } + SlicedCodomain { g: MyCow::Owned(self), slice, _phantoms: PhantomData } } /// Flatten the codomain from [`Loc`]`` to `F`. fn slice_codomain_ref(&self, slice: usize) -> SlicedCodomain<'_, X, F, Self, N> { assert!(slice < N); - SlicedCodomain { - g: MyCow::Borrowed(self), - slice, - _phantoms: PhantomData, - } + SlicedCodomain { g: MyCow::Borrowed(self), slice, _phantoms: PhantomData } } } @@ -294,7 +266,7 @@ E: Copy, //Composition: Space, S::Derivative: Mul, - Y: Space, + Y: ClosedSpace, { //type Derivative = Composition; type Derivative = Y;