src/bisection_tree/btfn.rs

branch
dev
changeset 29
7fd0984743b5
parent 27
00029c20c0ee
child 47
a0db98c16ab5
child 77
cf8ef9463664
equal deleted inserted replaced
28:331345346e7b 29:7fd0984743b5
2 use numeric_literals::replace_float_literals; 2 use numeric_literals::replace_float_literals;
3 use std::iter::Sum; 3 use std::iter::Sum;
4 use std::marker::PhantomData; 4 use std::marker::PhantomData;
5 use std::sync::Arc; 5 use std::sync::Arc;
6 use crate::types::Float; 6 use crate::types::Float;
7 use crate::mapping::{Apply, Mapping, Differentiate}; 7 use crate::mapping::{Apply, Mapping, Differentiable};
8 //use crate::linops::{Apply, Linear}; 8 //use crate::linops::{Apply, Linear};
9 use crate::sets::Set; 9 use crate::sets::Set;
10 use crate::sets::Cube; 10 use crate::sets::Cube;
11 use crate::loc::Loc; 11 use crate::loc::Loc;
12 use super::support::*; 12 use super::support::*;
418 self.bt.iter_at(&x) 418 self.bt.iter_at(&x)
419 .map(|&d| self.generator.support_for(d).apply(x)).sum() 419 .map(|&d| self.generator.support_for(d).apply(x)).sum()
420 } 420 }
421 } 421 }
422 422
423 impl<'a, F : Float, G, BT, V, const N : usize> Differentiate<&'a Loc<F, N>> 423 impl<'a, F : Float, G, BT, V, const N : usize> Differentiable<&'a Loc<F, N>>
424 for BTFN<F, G, BT, N> 424 for BTFN<F, G, BT, N>
425 where BT : BTImpl<F, N>, 425 where BT : BTImpl<F, N>,
426 G : SupportGenerator<F, N, Id=BT::Data>, 426 G : SupportGenerator<F, N, Id=BT::Data>,
427 G::SupportType : LocalAnalysis<F, BT::Agg, N> + Differentiate<&'a Loc<F, N>, Output = V>, 427 G::SupportType : LocalAnalysis<F, BT::Agg, N> + Differentiable<&'a Loc<F, N>, Output = V>,
428 V : Sum { 428 V : Sum {
429 429
430 type Output = V; 430 type Output = V;
431 431
432 fn differential(&self, x : &'a Loc<F, N>) -> Self::Output { 432 fn differential(&self, x : &'a Loc<F, N>) -> Self::Output {
434 .map(|&d| self.generator.support_for(d).differential(x)) 434 .map(|&d| self.generator.support_for(d).differential(x))
435 .sum() 435 .sum()
436 } 436 }
437 } 437 }
438 438
439 impl<F : Float, G, BT, V, const N : usize> Differentiate<Loc<F, N>> 439 impl<F : Float, G, BT, V, const N : usize> Differentiable<Loc<F, N>>
440 for BTFN<F, G, BT, N> 440 for BTFN<F, G, BT, N>
441 where BT : BTImpl<F, N>, 441 where BT : BTImpl<F, N>,
442 G : SupportGenerator<F, N, Id=BT::Data>, 442 G : SupportGenerator<F, N, Id=BT::Data>,
443 G::SupportType : LocalAnalysis<F, BT::Agg, N> + Differentiate<Loc<F, N>, Output = V>, 443 G::SupportType : LocalAnalysis<F, BT::Agg, N> + Differentiable<Loc<F, N>, Output = V>,
444 V : Sum { 444 V : Sum {
445 445
446 type Output = V; 446 type Output = V;
447 447
448 fn differential(&self, x : Loc<F, N>) -> Self::Output { 448 fn differential(&self, x : Loc<F, N>) -> Self::Output {

mercurial