diff -r e7f1cb4bec78 -r 103aa137fcb2 src/mapping.rs --- a/src/mapping.rs Tue Apr 29 00:03:12 2025 -0500 +++ b/src/mapping.rs Tue Apr 29 07:55:18 2025 -0500 @@ -9,6 +9,7 @@ use crate::types::{ClosedMul, Float, Num}; use std::borrow::Cow; use std::marker::PhantomData; +use std::ops::Mul; /// A mapping from `Domain` to `Self::Codomain`. pub trait Mapping { @@ -283,8 +284,39 @@ } } +/// Helper trait for implementing [`DifferentiableMapping`] +impl DifferentiableImpl for Composition +where + X: Space, + T: DifferentiableImpl + Mapping, + S: DifferentiableImpl, + E: Copy, + //Composition: Space, + S::Derivative: Mul, + Y: Space, +{ + //type Derivative = Composition; + type Derivative = Y; + + /// Compute the differential of `self` at `x`, consuming the input. + fn differential_impl>(&self, x: I) -> Self::Derivative { + // Composition { + // outer: self + // .outer + // .differential_impl(self.inner.apply(x.ref_instance())), + // inner: self.inner.differential_impl(x), + // intermediate_norm_exponent: self.intermediate_norm_exponent, + // } + self.outer + .differential_impl(self.inner.apply(x.ref_instance())) + * self.inner.differential_impl(x) + } +} + mod quadratic; pub use quadratic::Quadratic; +mod dataterm; +pub use dataterm::DataTerm; /// Trait for indicating that `Self` is Lipschitz with respect to the (semi)norm `D`. pub trait Lipschitz {