Ocean
Loading...
Searching...
No Matches
AutomaticDifferentiation.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_MATH_AUTOMATIC_DIFFERENTIATION_H
9#define META_OCEAN_MATH_AUTOMATIC_DIFFERENTIATION_H
10
11#include "ocean/math/Math.h"
12#include "ocean/math/Numeric.h"
13
14namespace Ocean
15{
16
17// Forward declaration.
18template <typename T, typename TNumeric> class AutomaticDifferentiationT;
19
20/**
21 * Definition of a scalar differentiation object using the data type of Scalar as parameter.
22 * @see AutomaticDifferentiationT
23 * @ingroup math
24 */
26
27/**
28 * Definition of a scalar differentiation object using double as data type.
29 * @see AutomaticDifferentiationT
30 * @ingroup math
31 */
33
34/**
35 * Definition of a scalar differentiation object using float as data type.
36 * @see AutomaticDifferentiationT
37 * @ingroup math
38 */
40
41/**
42 * This class implements an automatic differentiation functionality.
43 * The automatic differentiation is realized by a pair of two values using the forward mode: the actual value of a function and the corresponding derivative at this location.<br>
44 * Therefore, each object holds the value of x and x' for a given parameter x.<br>
45 * Automatic differentiation is a nice tool for fast prototyping of e.g., non-linear optimization functions.<br>
46 * The accuracy of the resulting derivative is almost ideal and significantly better compared to numerical differentiation.<br>
47 * However, in general the performance of the automatic differentiation (using the forward method) will be at least two times slower than calculating the derivative directory.<br>
48 * The following code snippet shows a simple example how the AutomaticDifferentiation class can be used.
49 * @code
50 * // the following line determines the derivative f'(x) of f(x) = x^2 for x = 5.5
51 * const AutomaticDifferentiation automaticDerivative0 = AutomaticDifferentiation(5.5) * AutomaticDifferentiation(5.5);
52 * const Scalar derivative0 = automaticDerivative0.derivative();
53 *
54 * // the following line determines the derivative of f'(x) of f(x) = x * sin(x) + 7 for x = 3
55 * const AutomaticDifferentiation automaticDerivative1 = AutomaticDifferentiation(3) * AutomaticDifferentiation::sin(AutomaticDifferentiation(3)) + 7;
56 * const Scalar derivative1 = automaticDerivative1.derivative();
57 * @endcode
58 *
59 * In the case a Jacobian matrix needs to be determined the constructor with additional boolean parameter may be used for calculations:
60 * @code
61 * // we determine the 1x2 Jacobian matrix for f(x, y) = x^2 + 3y + 5
62 * // the Jacobian will have the following layout:
63 * // | df/dx df/dy |
64 *
65 * Scalar jacobian[2];
66 *
67 * Scalar x = 3; // any value for x
68 * Scalar y = 7; // any value for y
69 *
70 * for (unsigned int n = 0u; n < 2u; ++n)
71 * {
72 * const AutomaticDifferentiation dx = AutomaticDifferentiation(x, n == 0u) * AutomaticDifferentiation(x, n == 0u);
73 * const AutomaticDifferentiation dy = AutomaticDifferentiation(y, n == 1u) * 3;
74 *
75 * const AutomaticDifferentiation d = dx + dy + 5;
76 * jacobian[n] = d(); // or d.derivative();
77 * }
78 * @endcode
79 * @tparam T The data type of the scalar
80 * @tparam TNumeric The numeric class providing access to standard mathematical functions like sin, cos, sqrt, etc.
81 * @ingroup math
82 */
83template <typename T, typename TNumeric = NumericT<T>>
85{
86 template <typename T1, typename TNumeric1, typename T2> friend AutomaticDifferentiationT<T1, TNumeric1> operator+(const T2& left, const AutomaticDifferentiationT<T1, TNumeric1>& right);
87 template <typename T1, typename TNumeric1, typename T2> friend AutomaticDifferentiationT<T1, TNumeric1> operator-(const T2& left, const AutomaticDifferentiationT<T1, TNumeric1>& right);
88 template <typename T1, typename TNumeric1, typename T2> friend AutomaticDifferentiationT<T1, TNumeric1> operator*(const T2& left, const AutomaticDifferentiationT<T1, TNumeric1>& right);
89 template <typename T1, typename TNumeric1, typename T2> friend AutomaticDifferentiationT<T1, TNumeric1> operator/(const T2& left, const AutomaticDifferentiationT<T1, TNumeric1>& right);
90
91 public:
92
93 /**
94 * Creates a new differentiation object without initializing the parameters.
95 */
97
98 /**
99 * Creates a new differentiation object for a given scalar value (not a constant).
100 * The derivative for the provided scalar value will be set to 1.
101 * @param value The scalar value defining the object
102 */
103 explicit inline AutomaticDifferentiationT(const T& value);
104
105 /**
106 * Creates a new differentiation object by a given scalar and it's known derivative of the function at the specified location 'value'.
107 * @param value The scalar value defining the object
108 * @param derivative The derivative of the function at location 'value', e.g., 1 for a scalar parameter, 0 for a constant
109 */
110 inline AutomaticDifferentiationT(const T& value, const T& derivative);
111
112 /**
113 * Creates a new differentiation object by a given scalar or constant value, while a boolean state specifies whether the parameter is a scalar or a constant.
114 * @param value The scalar or constant value defining the object
115 * @param isVariable True, if the provided value is a scalar (with derivative 1); False, if the provided value is a constant (with derivative 0)
116 */
117 inline AutomaticDifferentiationT(const T& value, const bool isVariable);
118
119 /**
120 * Returns the actual derivative of this object.
121 * @return The object's derivative
122 */
123 inline const T& derivative() const;
124
125 /**
126 * Returns the value of this object.
127 * @return The object's value
128 */
129 inline const T& value() const;
130
131 /**
132 * Returns the actual derivative value of this object.
133 * @return The object's derivative value
134 */
135 inline const T& operator()() const;
136
137 /**
138 * Adds a scalar value to this differentiation object.
139 * @param right The scalar value
140 * @return The differentiation object with added scalar
141 */
142 inline AutomaticDifferentiationT<T, TNumeric> operator+(const T& right) const;
143
144 /**
145 * Adds a scalar value to this differentiation object.
146 * @param right The scalar value
147 * @return The reference to this object
148 */
150
151 /**
152 * Adds two differentiation objects and determines the sum derivative.
153 * @param right The right differentiation object
154 * @return The sum derivative
155 */
157
158 /**
159 * Adds two differentiation objects and determines the sum derivative.
160 * @param right The right differentiation object
161 * @return The reference to this object
162 */
164
165 /**
166 * Subtracts a scalar value from this differentiation object.
167 * @param right The scalar value
168 * @return The differentiation object with subtracted scalar
169 */
170 inline AutomaticDifferentiationT<T, TNumeric> operator-(const T& right) const;
171
172 /**
173 * Subtracts a scalar value from this differentiation object.
174 * @param right The scalar value
175 * @return The reference to this object
176 */
178
179 /**
180 * Subtracts two differentiation objects and determines the resulting derivative.
181 * @param right The right differentiation object
182 * @return The resulting derivative
183 */
185
186 /**
187 * Unary negation operator returns the negative of this differentiation object.
188 * @return The negative differentiation object
189 */
191
192 /**
193 * Subtracts two differentiation objects and determines the resulting derivative.
194 * @param right The right differentiation object
195 * @return The reference to this object
196 */
198
199 /**
200 * Multiplies two differentiation objects and determines the product derivative.
201 * @param right The right differentiation object
202 * @return The product derivative
203 */
205
206 /**
207 * Multiplies two differentiation objects and determines the product derivative.
208 * @param right The right differentiation object
209 * @return The reference to this object
210 */
212
213 /**
214 * Multiplies this differentiation objects with a scalar.
215 * @param right The right scalar value
216 * @return The resulting differentiation object
217 */
218 inline AutomaticDifferentiationT<T, TNumeric> operator*(const T& right) const;
219
220 /**
221 * Multiplies this differentiation objects with a scalar.
222 * @param right The right scalar value
223 * @return The reference to this object
224 */
226
227 /**
228 * Divides two differentiation objects and determines the quotient derivative.
229 * @param right The right differentiation object, while the object's value must not be zero
230 * @return The quotient derivative
231 */
233
234 /**
235 * Divides two differentiation objects and determines the quotient derivative.
236 * @param right The right differentiation object, while the object's value must not be zero
237 * @return The reference to this object
238 */
240
241 /**
242 * Divides this differentiation object by a scalar value.
243 * @param right The right scalar value, must not be zero
244 * @return The resulting differentiation object
245 */
246 inline AutomaticDifferentiationT<T, TNumeric> operator/(const T& right) const;
247
248 /**
249 * Divides this differentiation object by a scalar value.
250 * @param right The right scalar value, must not be zero
251 * @return The reference to this object
252 */
254
255 /**
256 * Determines the derivative of the sinus function.
257 * @param value The value for which the derivative will be determined, in radians
258 * @return The resulting derivative value
259 */
261
262 /**
263 * Determines the derivative of the cosine function.
264 * @param value The value for which the derivative will be determined, in radians
265 * @return The resulting derivative value
266 */
268
269 /**
270 * Determines the derivative of the tangent function.
271 * @param value The value for which the derivative will be determined, in radian
272 * @return The resulting derivative value
273 */
275
276 /**
277 * Determines the derivative of the square root function.
278 * @param value The value for which the derivative will be determined, with value range [0, infinity)
279 * @return The resulting derivative value
280 */
282
283 /**
284 * Determines the derivative of the square function.
285 * @param value The value for which the derivative will be determined
286 * @return The resulting derivative value
287 */
289
290 /**
291 * Determines the derivative of the exponential function.
292 * @param value The value for which the derivative will be determined
293 * @return The resulting derivative value
294 */
296
297 /**
298 * Determines the derivative of the natural logarithm.
299 * @param value The value for which the derivative will be determined, with value range (0, infinity)
300 * @return The resulting derivative value
301 */
303
304 /**
305 * Determines the derivative of the logarithm to the base 2.
306 * @param value The value for which the derivative will be determined, with value range (0, infinity)
307 * @return The resulting derivative value
308 */
310
311 /**
312 * Determines the derivative of the logarithm to the base 10.
313 * @param value The value for which the derivative will be determined, with value range (0, infinity)
314 * @return The resulting derivative value
315 */
317
318 /**
319 * Determines the derivative of the power function calculating x to the power of y.
320 * @param x The value for which the derivative will be determined, with value range [0, infinity)
321 * @param y The exponent, with range (-infinity, infinity)
322 * @return The resulting derivative value
323 */
325
326 /**
327 * Determines the derivative of the abs function.
328 * @param value The value for which the derivative will be determined
329 * @return The resulting derivative value
330 */
332
333 /**
334 * Determines the derivative of the min function.
335 * @param value The value for which the derivative will be determined
336 * @param second The second scalar value that will be used for minimum comparison
337 * @return The resulting derivative value
338 */
340
341 /**
342 * Determines the derivative of the max function.
343 * @param value The value for which the derivative will be determined
344 * @param second The second scalar value that will be used for maximum comparison
345 * @return The resulting derivative value
346 */
348
349 protected:
350
351 /// The scalar value of this object.
352 T value_ = T(0);
353
354 /// The actual derivative of this object.
355 T derivative_ = T(0);
356};
357
358template <typename T, typename TNumeric>
360 value_(value),
361 derivative_(value == T(0) ? T(0) : T(1))
362{
363 // x' = 1, if x != 0
364 // x' = 1, if x == 0
365}
366
367template <typename T, typename TNumeric>
368inline AutomaticDifferentiationT<T, TNumeric>::AutomaticDifferentiationT(const T& value, const T& derivative) :
369 value_(value),
370 derivative_(derivative)
371{
372 // nothing to do here
373}
374
375template <typename T, typename TNumeric>
376inline AutomaticDifferentiationT<T, TNumeric>::AutomaticDifferentiationT(const T& value, const bool isVariable) :
377 value_(value),
378 derivative_(isVariable ? T(1) : T(0))
379{
380 // nothing to do here
381}
382
383template <typename T, typename TNumeric>
385{
386 return derivative_;
387}
388
389template <typename T, typename TNumeric>
391{
392 return value_;
393}
394
395template <typename T, typename TNumeric>
397{
398 return derivative_;
399}
400
401template <typename T, typename TNumeric>
403{
404 // f(x) = x + c
405 // f'(x) = x'
406
407 return AutomaticDifferentiationT<T, TNumeric>(value_ + right, derivative_);
408}
409
410template <typename T, typename TNumeric>
412{
413 value_ += right;
414 return *this;
415}
416
417template <typename T1, typename TNumeric1, typename T2>
419{
420 // f(x) = c + x
421 // f'(x) = x'
422
423 return AutomaticDifferentiationT<T1, TNumeric1>(T1(left) + right.value_, right.derivative_);
424}
425
426template <typename T, typename TNumeric>
432
433template <typename T, typename TNumeric>
435{
436 value_ += right.value_;
437 derivative_ += right.derivative_;
438
439 return *this;
440}
441
442template <typename T, typename TNumeric>
448
449template <typename T, typename TNumeric>
451{
452 // f(x) = -x
453 // f'(x) = -x'
454
455 return AutomaticDifferentiationT<T, TNumeric>(-value_, -derivative_);
456}
457
458template <typename T, typename TNumeric>
460{
461 value_ -= right.value_;
462 derivative_ -= right.derivative_;
463
464 return *this;
465}
466
467template <typename T, typename TNumeric>
469{
470 // f(x) = x - c
471 // f'(x) = x'
472
473 return AutomaticDifferentiationT<T, TNumeric>(value_ - right, derivative_);
474}
475
476template <typename T, typename TNumeric>
478{
479 value_ -= right;
480 return *this;
481}
482
483template <typename T1, typename TNumeric1, typename T2>
485{
486 // f(x) = c - x
487 // f'(x) = -x'
488
489 return AutomaticDifferentiationT<T1, TNumeric1>(T1(left) - right.value_, -right.derivative_);
490}
491
492template <typename T, typename TNumeric>
494{
495 // u' * v' = u' * v + u * v'
496
497 return AutomaticDifferentiationT<T, TNumeric>(value_ * right.value_, derivative_ * right.value_ + value_ * right.derivative_);
498}
499
500template <typename T, typename TNumeric>
506
507template <typename T, typename TNumeric>
509{
510 // f(x) = x * c
511 // f'(x) = x' * c
512
513 return AutomaticDifferentiationT<T, TNumeric>(value_ * right, derivative_ * right);
514}
515
516template <typename T, typename TNumeric>
518{
519 value_ *= right;
520 return *this;
521}
522
523template <typename T1, typename TNumeric1, typename T2>
525{
526 // f(x) = c * x
527 // f'(x) = c * x'
528
529 return AutomaticDifferentiationT<T1, TNumeric1>(T1(left) * right.value_, T1(left) * right.derivative_);
530}
531
532template <typename T, typename TNumeric>
534{
535 // (u / v)' = (u' * v - u * v') / v^2
536
537 ocean_assert((std::is_same<T, float>::value) || TNumeric::isNotEqualEps(right.value_));
538
539 return AutomaticDifferentiationT<T, TNumeric>(value_ / right.value_, (derivative_ * right.value_ - value_ * right.derivative_) / (right.value_ * right.value_));
540}
541
542template <typename T, typename TNumeric>
548
549template <typename T, typename TNumeric>
551{
552 // f(x) = x / c
553 // f'(x) = x' / c
554
555 ocean_assert((std::is_same<T, float>::value) || TNumeric::isNotEqualEps(right));
556
557 return AutomaticDifferentiationT<T, TNumeric>(value_ / right, derivative_ / right);
558}
559
560template <typename T, typename TNumeric>
562{
563 ocean_assert((std::is_same<T, float>::value) || TNumeric::isNotEqualEps(right));
564
565 value_ /= right;
566 derivative_ /= right;
567
568 return *this;
569}
570
571template <typename T1, typename TNumeric1, typename T2>
573{
574 // f(x) = c / x = c * x^-1
575 // f'(x) = -c / x^2
576
577 ocean_assert((std::is_same<T1, float>::value) || (std::is_same<T2, float>::value) || NumericT<T1>::isNotEqualEps(right.value_));
578
579 return AutomaticDifferentiationT<T1, TNumeric1>(T1(left) / right.value_, -T1(left) / (right.value_ * right.value_) * right.derivative_);
580}
581
582template <typename T, typename TNumeric>
584{
585 // f(x) = sin(x)
586 // f'(x) = cos(x) * x'
587
588 return AutomaticDifferentiationT<T, TNumeric>(TNumeric::sin(value.value_), TNumeric::cos(value.value_) * value.derivative_);
589}
590
591template <typename T, typename TNumeric>
593{
594 // f(x) = cos(x)
595 // f'(x) = -sin(x) * x'
596
597 return AutomaticDifferentiationT<T, TNumeric>(TNumeric::cos(value.value_), -TNumeric::sin(value.value_) * value.derivative_);
598}
599
600template <typename T, typename TNumeric>
602{
603 // f(x) = tan(x)
604 // f'(x) = 1 / (cos(x) * cos(x)) * x'
605
606 return AutomaticDifferentiationT<T, TNumeric>(TNumeric::tan(value.value_), value.derivative_ / TNumeric::sqr(TNumeric::cos(value.value_)));
607}
608
609template <typename T, typename TNumeric>
611{
612 // f(x) = sqrt(x)
613 // f'(x) = 1 / (2 * sqrt(x)) * x'
614
615 ocean_assert(value.value_ >= T(0));
616
617 const T sqrtValue = TNumeric::sqrt(value.value_);
618
619 return AutomaticDifferentiationT<T, TNumeric>(sqrtValue, T(0.5) * value.derivative_ / sqrtValue);
620}
621
622template <typename T, typename TNumeric>
624{
625 // f(x) = x^2
626 // f'(x) = 2x * x'
627
628 return AutomaticDifferentiationT<T, TNumeric>(value.value_ * value.value_, T(2) * value.value_ * value.derivative_);
629}
630
631template <typename T, typename TNumeric>
633{
634 // f(x) = exp(x) = e^x
635 // f'(x) = e^x * x'
636
637 const T expValue = TNumeric::exp(value.value_);
638
639 return AutomaticDifferentiationT<T, TNumeric>(expValue, expValue * value.derivative_);
640}
641
642template <typename T, typename TNumeric>
644{
645 // f(x) = log(x)
646 // f'(x) = x' / x
647
648 ocean_assert((std::is_same<T, float>::value) || TNumeric::isNotEqualEps(value.value_));
649
650 return AutomaticDifferentiationT<T, TNumeric>(TNumeric::log(value.value_), value.derivative_ / value.value_);
651}
652
653template <typename T, typename TNumeric>
655{
656 // f(x) = log_2(x)
657 // f'(x) = x' / (x * log(2))
658
659 ocean_assert((std::is_same<T, float>::value) || TNumeric::isNotEqualEps(value.value_));
660
661 return AutomaticDifferentiationT<T, TNumeric>(TNumeric::log2(value.value_), value.derivative_ / (value.value_ * T(0.69314718055994530941723212145818)));
662}
663
664template <typename T, typename TNumeric>
666{
667 // f(x) = log_10(x)
668 // f'(x) = x' / (x * log(10))
669
670 ocean_assert((std::is_same<T, float>::value) || TNumeric::isNotEqualEps(value.value_));
671
672 return AutomaticDifferentiationT<T, TNumeric>(TNumeric::log10(value.value_), value.derivative_ / (value.value_ * T(2.3025850929940456840179914546844)));
673}
674
675template <typename T, typename TNumeric>
677{
678 // f(x, y) = x^y
679 // f'(x) = y * x^(y - 1) * x'
680
681 ocean_assert(x.value_ >= T(0));
682
683 return AutomaticDifferentiationT<T, TNumeric>(TNumeric::pow(x.value_, y), y * TNumeric::pow(x.value_, y - T(1)) * x.derivative_);
684}
685
686template <typename T, typename TNumeric>
688{
689 // f(x) = |x|
690 // f'(x) = sign(x) * x'
691
692 return AutomaticDifferentiationT<T, TNumeric>(TNumeric::abs(value.value_), value.value_ >= T(0) ? value.derivative_ : -value.derivative_);
693}
694
695template <typename T, typename TNumeric>
697{
698 // f(x) = min(x, c)
699 // | x', x < c
700 // f'(x) = | 0, x >= c
701
702 if (value.value_ < second)
703 {
705 }
706 else
707 {
708 return AutomaticDifferentiationT<T, TNumeric>(second, T(0));
709 }
710}
711
712template <typename T, typename TNumeric>
714{
715 // f(x) = max(x, c)
716 // | x', x > c
717 // f'(x) = | 0, x <= c
718
719 if (value.value_ > second)
720 {
722 }
723 else
724 {
725 return AutomaticDifferentiationT<T, TNumeric>(second, T(0));
726 }
727}
728
729}
730
731#endif // META_OCEAN_MATH_AUTOMATIC_DIFFERENTIATION_H
This class implements an automatic differentiation functionality.
Definition AutomaticDifferentiation.h:85
static AutomaticDifferentiationT< T, TNumeric > log10(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the logarithm to the base 10.
Definition AutomaticDifferentiation.h:665
T derivative_
The actual derivative of this object.
Definition AutomaticDifferentiation.h:355
static AutomaticDifferentiationT< T, TNumeric > sqr(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the square function.
Definition AutomaticDifferentiation.h:623
static AutomaticDifferentiationT< T, TNumeric > abs(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the abs function.
Definition AutomaticDifferentiation.h:687
static AutomaticDifferentiationT< T, TNumeric > tan(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the tangent function.
Definition AutomaticDifferentiation.h:601
static AutomaticDifferentiationT< T, TNumeric > max(const AutomaticDifferentiationT< T, TNumeric > &value, const T &second)
Determines the derivative of the max function.
Definition AutomaticDifferentiation.h:713
const T & derivative() const
Returns the actual derivative of this object.
Definition AutomaticDifferentiation.h:384
static AutomaticDifferentiationT< T, TNumeric > log(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the natural logarithm.
Definition AutomaticDifferentiation.h:643
static AutomaticDifferentiationT< T, TNumeric > pow(const AutomaticDifferentiationT< T, TNumeric > &x, const T &y)
Determines the derivative of the power function calculating x to the power of y.
Definition AutomaticDifferentiation.h:676
friend AutomaticDifferentiationT< T1, TNumeric1 > operator-(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:484
const T & value() const
Returns the value of this object.
Definition AutomaticDifferentiation.h:390
AutomaticDifferentiationT< T, TNumeric > & operator+=(const T &right)
Adds a scalar value to this differentiation object.
Definition AutomaticDifferentiation.h:411
static AutomaticDifferentiationT< T, TNumeric > cos(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the cosine function.
Definition AutomaticDifferentiation.h:592
static AutomaticDifferentiationT< T, TNumeric > sqrt(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the square root function.
Definition AutomaticDifferentiation.h:610
static AutomaticDifferentiationT< T, TNumeric > log2(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the logarithm to the base 2.
Definition AutomaticDifferentiation.h:654
friend AutomaticDifferentiationT< T1, TNumeric1 > operator+(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:418
T value_
The scalar value of this object.
Definition AutomaticDifferentiation.h:352
static AutomaticDifferentiationT< T, TNumeric > min(const AutomaticDifferentiationT< T, TNumeric > &value, const T &second)
Determines the derivative of the min function.
Definition AutomaticDifferentiation.h:696
AutomaticDifferentiationT< T, TNumeric > & operator-=(const T &right)
Subtracts a scalar value from this differentiation object.
Definition AutomaticDifferentiation.h:477
static AutomaticDifferentiationT< T, TNumeric > sin(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the sinus function.
Definition AutomaticDifferentiation.h:583
const T & operator()() const
Returns the actual derivative value of this object.
Definition AutomaticDifferentiation.h:396
static AutomaticDifferentiationT< T, TNumeric > exp(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the exponential function.
Definition AutomaticDifferentiation.h:632
friend AutomaticDifferentiationT< T1, TNumeric1 > operator/(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:572
AutomaticDifferentiationT()=default
Creates a new differentiation object without initializing the parameters.
AutomaticDifferentiationT< T, TNumeric > & operator/=(const AutomaticDifferentiationT< T, TNumeric > &right)
Divides two differentiation objects and determines the quotient derivative.
Definition AutomaticDifferentiation.h:543
AutomaticDifferentiationT< T, TNumeric > & operator*=(const AutomaticDifferentiationT< T, TNumeric > &right)
Multiplies two differentiation objects and determines the product derivative.
Definition AutomaticDifferentiation.h:501
friend AutomaticDifferentiationT< T1, TNumeric1 > operator*(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:524
This class provides basic numeric functionalities.
Definition Numeric.h:57
AutomaticDifferentiationT< Scalar, Numeric > AutomaticDifferentiation
Definition of a scalar differentiation object using the data type of Scalar as parameter.
Definition AutomaticDifferentiation.h:25
AutomaticDifferentiationT< float, NumericF > AutomaticDifferentiationF
Definition of a scalar differentiation object using float as data type.
Definition AutomaticDifferentiation.h:39
AutomaticDifferentiationT< double, NumericD > AutomaticDifferentiationD
Definition of a scalar differentiation object using double as data type.
Definition AutomaticDifferentiation.h:32
The namespace covering the entire Ocean framework.
Definition Accessor.h:15
AutomaticDifferentiationT< T1, TNumeric1 > operator*(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:524
AutomaticDifferentiationT< T1, TNumeric1 > operator+(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:418
AutomaticDifferentiationT< T1, TNumeric1 > operator/(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:572
AutomaticDifferentiationT< T1, TNumeric1 > operator-(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:484