pub struct ForwardADMulti<A: AD + ForwardADTrait> { /* private fields */ }Expand description
Computes derivatives using Forward-mode Automatic Differentiation (Multi-Tangent).
This method allows for computing multiple columns of the Jacobian in a single pass by propagating a vector of tangents. This can significantly speed up computation by taking advantage of SIMD and reducing function overhead.
Implementations§
Source§impl<A: AD + ForwardADTrait> ForwardADMulti<A>
impl<A: AD + ForwardADTrait> ForwardADMulti<A>
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/example1.rs (line 63)
33fn main() {
34 let inputs = vec![1., 2.];
35
36 // Reverse AD //////////////////////////////////////////////////////////////////////////////////
37 let function_standard = Test { coeff: 2.0 };
38 let function_derivative = function_standard.to_other_ad_type::<adr>();
39 let differentiable_block = FunctionEngine::new(function_standard, function_derivative, ReverseAD::new());
40
41 let (f_res, derivative_res) = differentiable_block.derivative(&inputs);
42 println!("Reverse AD: ");
43 println!(" f_res: {}", f_res[0]);
44 println!(" derivative: {}", derivative_res);
45 println!("//////////////");
46 println!();
47
48 // Forward AD //////////////////////////////////////////////////////////////////////////////////
49 let function_standard = Test { coeff: 2.0 };
50 let function_derivative = function_standard.to_other_ad_type::<adfn<1>>();
51 let differentiable_block = FunctionEngine::new(function_standard, function_derivative, ForwardAD::new());
52
53 let (f_res, derivative_res) = differentiable_block.derivative(&inputs);
54 println!("Forward AD: ");
55 println!(" f_res: {}", f_res[0]);
56 println!(" derivative: {}", derivative_res);
57 println!("//////////////");
58 println!();
59
60 // Forward AD Multi ////////////////////////////////////////////////////////////////////////////
61 let function_standard = Test { coeff: 2.0 };
62 let function_derivative = function_standard.to_other_ad_type::<adfn<2>>();
63 let differentiable_block = FunctionEngine::new(function_standard, function_derivative, ForwardADMulti::new());
64
65 let (f_res, derivative_res) = differentiable_block.derivative(&inputs);
66 println!("Forward AD Multi: ");
67 println!(" f_res: {}", f_res[0]);
68 println!(" derivative: {}", derivative_res);
69 println!("//////////////");
70 println!();
71
72 // Finite Differencing /////////////////////////////////////////////////////////////////////////
73 let function_standard = Test { coeff: 2.0 };
74 let function_derivative = function_standard.clone();
75 let differentiable_block = FunctionEngine::new(function_standard, function_derivative, FiniteDifferencing::new());
76
77 let (f_res, derivative_res) = differentiable_block.derivative(&inputs);
78 println!("Finite Differencing: ");
79 println!(" f_res: {}", f_res[0]);
80 println!(" derivative: {}", derivative_res);
81 println!("//////////////");
82 println!();
83
84}Trait Implementations§
Source§impl<A: Clone + AD + ForwardADTrait> Clone for ForwardADMulti<A>
impl<A: Clone + AD + ForwardADTrait> Clone for ForwardADMulti<A>
Source§fn clone(&self) -> ForwardADMulti<A>
fn clone(&self) -> ForwardADMulti<A>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<A: AD + ForwardADTrait> DerivativeMethodTrait for ForwardADMulti<A>
impl<A: AD + ForwardADTrait> DerivativeMethodTrait for ForwardADMulti<A>
Auto Trait Implementations§
impl<A> Freeze for ForwardADMulti<A>
impl<A> RefUnwindSafe for ForwardADMulti<A>where
A: RefUnwindSafe,
impl<A> Send for ForwardADMulti<A>
impl<A> Sync for ForwardADMulti<A>
impl<A> Unpin for ForwardADMulti<A>where
A: Unpin,
impl<A> UnsafeUnpin for ForwardADMulti<A>
impl<A> UnwindSafe for ForwardADMulti<A>where
A: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.