Some Differentiable simplifications and clarifications dev

Sat, 09 Nov 2024 20:36:23 -0500

author
Tuomo Valkonen <tuomov@iki.fi>
date
Sat, 09 Nov 2024 20:36:23 -0500
branch
dev
changeset 47
a0db98c16ab5
parent 46
bd924d62d952
child 48
3f3e00e81755

Some Differentiable simplifications and clarifications

src/bisection_tree/btfn.rs file | annotate | diff | comparison | revisions
src/bisection_tree/either.rs file | annotate | diff | comparison | revisions
src/bisection_tree/support.rs file | annotate | diff | comparison | revisions
src/mapping.rs file | annotate | diff | comparison | revisions
--- a/src/bisection_tree/btfn.rs	Wed Nov 06 15:34:17 2024 -0500
+++ b/src/bisection_tree/btfn.rs	Sat Nov 09 20:36:23 2024 -0500
@@ -424,12 +424,12 @@
 for BTFN<F, G, BT, N>
 where BT : BTImpl<F, N>,
       G : SupportGenerator<F, N, Id=BT::Data>,
-      G::SupportType : LocalAnalysis<F, BT::Agg, N> + Differentiable<&'a Loc<F, N>, Output = V>,
+      G::SupportType : LocalAnalysis<F, BT::Agg, N> + Differentiable<&'a Loc<F, N>, Derivative = V>,
       V : Sum {
 
-    type Output = V;
+    type Derivative = V;
 
-    fn differential(&self, x : &'a Loc<F, N>) -> Self::Output {
+    fn differential(&self, x : &'a Loc<F, N>) -> Self::Derivative {
         self.bt.iter_at(x)
             .map(|&d| self.generator.support_for(d).differential(x))
             .sum()
@@ -440,12 +440,12 @@
 for BTFN<F, G, BT, N>
 where BT : BTImpl<F, N>,
       G : SupportGenerator<F, N, Id=BT::Data>,
-      G::SupportType : LocalAnalysis<F, BT::Agg, N> + Differentiable<Loc<F, N>, Output = V>,
+      G::SupportType : LocalAnalysis<F, BT::Agg, N> + Differentiable<Loc<F, N>, Derivative = V>,
       V : Sum {
 
-    type Output = V;
+    type Derivative = V;
 
-    fn differential(&self, x : Loc<F, N>) -> Self::Output {
+    fn differential(&self, x : Loc<F, N>) -> Self::Derivative {
         self.bt.iter_at(&x)
             .map(|&d| self.generator.support_for(d).differential(x))
             .sum()
--- a/src/bisection_tree/either.rs	Wed Nov 06 15:34:17 2024 -0500
+++ b/src/bisection_tree/either.rs	Sat Nov 09 20:36:23 2024 -0500
@@ -191,9 +191,9 @@
 }
 
 impl<F, S1, S2, X> Differentiable<X> for EitherSupport<S1, S2>
-where S1 : Differentiable<X, Output=F>,
-      S2 : Differentiable<X, Output=F> {
-    type Output = F;
+where S1 : Differentiable<X, Derivative=F>,
+      S2 : Differentiable<X, Derivative=F> {
+    type Derivative = F;
     #[inline]
     fn differential(&self, x : X) -> F {
         match self {
--- a/src/bisection_tree/support.rs	Wed Nov 06 15:34:17 2024 -0500
+++ b/src/bisection_tree/support.rs	Sat Nov 09 20:36:23 2024 -0500
@@ -146,19 +146,19 @@
 }
 
 impl<'a, T, V, F : Float, const N : usize> Differentiable<&'a Loc<F, N>> for Shift<T,F,N>
-where T : Differentiable<Loc<F, N>, Output=V> {
-    type Output = V;
+where T : Differentiable<Loc<F, N>, Derivative=V> {
+    type Derivative = V;
     #[inline]
-    fn differential(&self, x : &'a Loc<F, N>) -> Self::Output {
+    fn differential(&self, x : &'a Loc<F, N>) -> Self::Derivative {
         self.base_fn.differential(x - &self.shift)
     }
 }
 
 impl<'a, T, V, F : Float, const N : usize> Differentiable<Loc<F, N>> for Shift<T,F,N>
-where T : Differentiable<Loc<F, N>, Output=V> {
-    type Output = V;
+where T : Differentiable<Loc<F, N>, Derivative=V> {
+    type Derivative = V;
     #[inline]
-    fn differential(&self, x : Loc<F, N>) -> Self::Output {
+    fn differential(&self, x : Loc<F, N>) -> Self::Derivative {
         self.base_fn.differential(x - &self.shift)
     }
 }
@@ -251,23 +251,23 @@
 }
 
 impl<'a, T, V, F : Float, C, const N : usize> Differentiable<&'a Loc<F, N>> for Weighted<T, C>
-where T : for<'b> Differentiable<&'b Loc<F, N>, Output=V>,
+where T : for<'b> Differentiable<&'b Loc<F, N>, Derivative=V>,
       V : std::ops::Mul<F, Output=V>,
       C : Constant<Type=F> {
-    type Output = V;
+    type Derivative = V;
     #[inline]
-    fn differential(&self, x : &'a Loc<F, N>) -> Self::Output {
+    fn differential(&self, x : &'a Loc<F, N>) -> Self::Derivative {
         self.base_fn.differential(x) * self.weight.value()
     }
 }
 
 impl<'a, T, V, F : Float, C, const N : usize> Differentiable<Loc<F, N>> for Weighted<T, C>
-where T : Differentiable<Loc<F, N>, Output=V>,
+where T : Differentiable<Loc<F, N>, Derivative=V>,
       V : std::ops::Mul<F, Output=V>,
       C : Constant<Type=F> {
-    type Output = V;
+    type Derivative = V;
     #[inline]
-    fn differential(&self, x : Loc<F, N>) -> Self::Output {
+    fn differential(&self, x : Loc<F, N>) -> Self::Derivative {
         self.base_fn.differential(x) * self.weight.value()
     }
 }
--- a/src/mapping.rs	Wed Nov 06 15:34:17 2024 -0500
+++ b/src/mapping.rs	Sat Nov 09 20:36:23 2024 -0500
@@ -68,10 +68,10 @@
 
 /// Trait for calculation the differential of `Self` as a mathematical function on `X`.
 pub trait Differentiable<X> : Sized {
-    type Output;
+    type Derivative;
 
     /// Compute the differential of `self` at `x`.
-    fn differential(&self, x : X) -> Self::Output;
+    fn differential(&self, x : X) -> Self::Derivative;
 }
 
 /// A differentiable mapping from `Domain` to [`Mapping::Codomain`], with differentials
@@ -80,8 +80,8 @@
 /// This is automatically implemented when the relevant [`Differentiate`] are implemented.
 pub trait DifferentiableMapping<Domain>
 : Mapping<Domain>
-  + Differentiable<Domain, Output=Self::Differential>
-  + for<'a> Differentiable<&'a Domain, Output=Self::Differential> {
+  + Differentiable<Domain, Derivative=Self::Differential>
+  + for<'a> Differentiable<&'a Domain, Derivative=Self::Differential> {
     type Differential;
 
     /// Form the differential mapping of `self`.
@@ -98,8 +98,8 @@
 
 impl<Domain, Differential, T> DifferentiableMapping<Domain> for T
 where T : Mapping<Domain>
-          + Differentiable<Domain, Output=Differential>
-          + for<'a> Differentiable<&'a Domain, Output=Differential> {
+          + Differentiable<Domain, Derivative=Differential>
+          + for<'a> Differentiable<&'a Domain, Derivative=Differential> {
     type Differential = Differential;
 }
 
@@ -149,9 +149,9 @@
       M :: Differential : std::iter::Sum,
       Domain : Copy {
 
-    type Output = M::Differential;
+    type Derivative = M::Differential;
 
-    fn differential(&self, x : Domain) -> Self::Output {
+    fn differential(&self, x : Domain) -> Self::Derivative {
         self.components.iter().map(|c| c.differential(x)).sum()
     }
 }
@@ -273,9 +273,9 @@
 }
 
 impl<'g, X, G : Differentiable<X>> Differentiable<X> for Ref<'g, G> {
-    type Output = G::Output;
+    type Derivative = G::Derivative;
     #[inline]
-    fn differential(&self, x : X) -> Self::Output {
+    fn differential(&self, x : X) -> Self::Derivative {
         self.0.differential(x)
     }
 }

mercurial