diff -r cc68841e758f -r 00029c20c0ee src/bisection_tree/btfn.rs --- a/src/bisection_tree/btfn.rs Fri Apr 28 08:27:17 2023 +0300 +++ b/src/bisection_tree/btfn.rs Fri Apr 28 08:32:15 2023 +0300 @@ -4,7 +4,7 @@ use std::marker::PhantomData; use std::sync::Arc; use crate::types::Float; -use crate::mapping::{Apply, Mapping}; +use crate::mapping::{Apply, Mapping, Differentiate}; //use crate::linops::{Apply, Linear}; use crate::sets::Set; use crate::sets::Cube; @@ -386,10 +386,8 @@ make_btfn_unaryop!(Neg, neg); - - // -// Mapping +// Apply, Mapping, Differentiate // impl<'a, F : Float, G, BT, V, const N : usize> Apply<&'a Loc> @@ -422,6 +420,42 @@ } } +impl<'a, F : Float, G, BT, V, const N : usize> Differentiate<&'a Loc> +for BTFN +where BT : BTImpl, + G : SupportGenerator, + G::SupportType : LocalAnalysis + Differentiate<&'a Loc, Output = V>, + V : Sum { + + type Output = V; + + fn differential(&self, x : &'a Loc) -> Self::Output { + self.bt.iter_at(x) + .map(|&d| self.generator.support_for(d).differential(x)) + .sum() + } +} + +impl Differentiate> +for BTFN +where BT : BTImpl, + G : SupportGenerator, + G::SupportType : LocalAnalysis + Differentiate, Output = V>, + V : Sum { + + type Output = V; + + fn differential(&self, x : Loc) -> Self::Output { + self.bt.iter_at(&x) + .map(|&d| self.generator.support_for(d).differential(x)) + .sum() + } +} + +// +// GlobalAnalysis +// + impl GlobalAnalysis for BTFN where BT : BTImpl,