8#ifndef META_OCEAN_MATH_AUTOMATIC_DIFFERENTIATION_H
9#define META_OCEAN_MATH_AUTOMATIC_DIFFERENTIATION_H
18template <
typename T,
typename TNumeric>
class AutomaticDifferentiationT;
83template <
typename T,
typename TNumeric = NumericT<T>>
129 inline const T&
value()
const;
358template <
typename T,
typename TNumeric>
366template <
typename T,
typename TNumeric>
369 derivative_(derivative)
374template <
typename T,
typename TNumeric>
377 derivative_(isVariable ? T(1) : T(0))
382template <
typename T,
typename TNumeric>
388template <
typename T,
typename TNumeric>
394template <
typename T,
typename TNumeric>
400template <
typename T,
typename TNumeric>
409template <
typename T,
typename TNumeric>
416template <
typename T1,
typename TNumeric1,
typename T2>
425template <
typename T,
typename TNumeric>
432template <
typename T,
typename TNumeric>
441template <
typename T,
typename TNumeric>
448template <
typename T,
typename TNumeric>
457template <
typename T,
typename TNumeric>
466template <
typename T,
typename TNumeric>
475template <
typename T,
typename TNumeric>
482template <
typename T1,
typename TNumeric1,
typename T2>
491template <
typename T,
typename TNumeric>
499template <
typename T,
typename TNumeric>
502 *
this = *
this * right;
506template <
typename T,
typename TNumeric>
515template <
typename T,
typename TNumeric>
522template <
typename T1,
typename TNumeric1,
typename T2>
531template <
typename T,
typename TNumeric>
536 ocean_assert((std::is_same<T, float>::value) || TNumeric::isNotEqualEps(right.
value_));
541template <
typename T,
typename TNumeric>
544 *
this = *
this / right;
548template <
typename T,
typename TNumeric>
554 ocean_assert((std::is_same<T, float>::value) || TNumeric::isNotEqualEps(right));
559template <
typename T,
typename TNumeric>
562 ocean_assert((std::is_same<T, float>::value) || TNumeric::isNotEqualEps(right));
565 derivative_ /= right;
570template <
typename T1,
typename TNumeric1,
typename T2>
581template <
typename T,
typename TNumeric>
590template <
typename T,
typename TNumeric>
599template <
typename T,
typename TNumeric>
608template <
typename T,
typename TNumeric>
614 ocean_assert(value.
value_ >= T(0));
616 const T sqrtValue = TNumeric::sqrt(value.
value_);
621template <
typename T,
typename TNumeric>
630template <
typename T,
typename TNumeric>
636 const T expValue = TNumeric::exp(value.
value_);
641template <
typename T,
typename TNumeric>
647 ocean_assert((std::is_same<T, float>::value) || TNumeric::isNotEqualEps(value.
value_));
652template <
typename T,
typename TNumeric>
658 ocean_assert((std::is_same<T, float>::value) || TNumeric::isNotEqualEps(value.
value_));
663template <
typename T,
typename TNumeric>
669 ocean_assert((std::is_same<T, float>::value) || TNumeric::isNotEqualEps(value.
value_));
674template <
typename T,
typename TNumeric>
680 ocean_assert(x.
value_ >= T(0));
685template <
typename T,
typename TNumeric>
694template <
typename T,
typename TNumeric>
701 if (value.
value_ < second)
711template <
typename T,
typename TNumeric>
718 if (value.
value_ > second)
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:664
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:622
static AutomaticDifferentiationT< T, TNumeric > abs(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the abs function.
Definition AutomaticDifferentiation.h:686
static AutomaticDifferentiationT< T, TNumeric > tan(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the tangent function.
Definition AutomaticDifferentiation.h:600
static AutomaticDifferentiationT< T, TNumeric > max(const AutomaticDifferentiationT< T, TNumeric > &value, const T &second)
Determines the derivative of the max function.
Definition AutomaticDifferentiation.h:712
const T & derivative() const
Returns the actual derivative of this object.
Definition AutomaticDifferentiation.h:383
static AutomaticDifferentiationT< T, TNumeric > log(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the natural logarithm.
Definition AutomaticDifferentiation.h:642
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:675
friend AutomaticDifferentiationT< T1, TNumeric1 > operator-(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:483
const T & value() const
Returns the value of this object.
Definition AutomaticDifferentiation.h:389
AutomaticDifferentiationT< T, TNumeric > & operator+=(const T &right)
Adds a scalar value to this differentiation object.
Definition AutomaticDifferentiation.h:410
static AutomaticDifferentiationT< T, TNumeric > cos(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the cosine function.
Definition AutomaticDifferentiation.h:591
static AutomaticDifferentiationT< T, TNumeric > sqrt(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the square root function.
Definition AutomaticDifferentiation.h:609
static AutomaticDifferentiationT< T, TNumeric > log2(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the logarithm to the base 2.
Definition AutomaticDifferentiation.h:653
friend AutomaticDifferentiationT< T1, TNumeric1 > operator+(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:417
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:695
AutomaticDifferentiationT< T, TNumeric > & operator-=(const T &right)
Subtracts a scalar value from this differentiation object.
Definition AutomaticDifferentiation.h:476
static AutomaticDifferentiationT< T, TNumeric > sin(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the sinus function.
Definition AutomaticDifferentiation.h:582
const T & operator()() const
Returns the actual derivative value of this object.
Definition AutomaticDifferentiation.h:395
static AutomaticDifferentiationT< T, TNumeric > exp(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the exponential function.
Definition AutomaticDifferentiation.h:631
friend AutomaticDifferentiationT< T1, TNumeric1 > operator/(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:571
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:542
AutomaticDifferentiationT< T, TNumeric > & operator*=(const AutomaticDifferentiationT< T, TNumeric > &right)
Multiplies two differentiation objects and determines the product derivative.
Definition AutomaticDifferentiation.h:500
friend AutomaticDifferentiationT< T1, TNumeric1 > operator*(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:523
This class provides basic numeric functionalities.
Definition Numeric.h:57
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:523
AutomaticDifferentiationT< T1, TNumeric1 > operator+(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:417
AutomaticDifferentiationT< T1, TNumeric1 > operator/(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:571
AutomaticDifferentiationT< T1, TNumeric1 > operator-(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:483