8#ifndef META_OCEAN_MATH_AUTOMATIC_DIFFERENTIATION_H
9#define META_OCEAN_MATH_AUTOMATIC_DIFFERENTIATION_H
83template <
typename T,
typename TNumeric = NumericT<T>>
358template <
typename T,
typename TNumeric>
366template <
typename T,
typename TNumeric>
374template <
typename T,
typename TNumeric>
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>
527template <
typename T1,
typename TNumeric1,
typename T2>
536template <
typename T,
typename TNumeric>
541 ocean_assert((std::is_same<T, float>::value) || TNumeric::isNotEqualEps(right.
value_));
546template <
typename T,
typename TNumeric>
549 *
this = *
this / right;
553template <
typename T,
typename TNumeric>
559 ocean_assert((std::is_same<T, float>::value) || TNumeric::isNotEqualEps(right));
564template <
typename T,
typename TNumeric>
567 ocean_assert((std::is_same<T, float>::value) || TNumeric::isNotEqualEps(right));
575template <
typename T1,
typename TNumeric1,
typename T2>
586template <
typename T,
typename TNumeric>
595template <
typename T,
typename TNumeric>
604template <
typename T,
typename TNumeric>
613template <
typename T,
typename TNumeric>
619 ocean_assert(
value.value_ >= T(0));
621 const T sqrtValue = TNumeric::sqrt(
value.value_);
626template <
typename T,
typename TNumeric>
635template <
typename T,
typename TNumeric>
641 const T expValue = TNumeric::exp(
value.value_);
646template <
typename T,
typename TNumeric>
652 ocean_assert((std::is_same<T, float>::value) || TNumeric::isNotEqualEps(
value.value_));
657template <
typename T,
typename TNumeric>
663 ocean_assert((std::is_same<T, float>::value) || TNumeric::isNotEqualEps(
value.value_));
668template <
typename T,
typename TNumeric>
674 ocean_assert((std::is_same<T, float>::value) || TNumeric::isNotEqualEps(
value.value_));
679template <
typename T,
typename TNumeric>
685 ocean_assert(x.
value_ >= T(0));
690template <
typename T,
typename TNumeric>
699template <
typename T,
typename TNumeric>
706 if (
value.value_ < second)
716template <
typename T,
typename TNumeric>
723 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:669
Scalar derivative_
Definition AutomaticDifferentiation.h:355
static AutomaticDifferentiationT< T, TNumeric > sqr(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the square function.
Definition AutomaticDifferentiation.h:627
static AutomaticDifferentiationT< T, TNumeric > abs(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the abs function.
Definition AutomaticDifferentiation.h:691
static AutomaticDifferentiationT< T, TNumeric > tan(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the tangent function.
Definition AutomaticDifferentiation.h:605
AutomaticDifferentiationT< T, TNumeric > operator+(const T &right) const
Adds a scalar value to this differentiation object.
Definition AutomaticDifferentiation.h:401
static AutomaticDifferentiationT< T, TNumeric > max(const AutomaticDifferentiationT< T, TNumeric > &value, const T &second)
Determines the derivative of the max function.
Definition AutomaticDifferentiation.h:717
const Scalar & derivative() const
static AutomaticDifferentiationT< T, TNumeric > log(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the natural logarithm.
Definition AutomaticDifferentiation.h:647
AutomaticDifferentiationT(const T &value)
Creates a new differentiation object for a given scalar value (not a constant).
Definition AutomaticDifferentiation.h:359
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:680
const Scalar & value() const
AutomaticDifferentiationT< T, TNumeric > operator*(const AutomaticDifferentiationT< T, TNumeric > &right) const
Multiplies two differentiation objects and determines the product derivative.
Definition AutomaticDifferentiation.h:492
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:596
static AutomaticDifferentiationT< T, TNumeric > sqrt(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the square root function.
Definition AutomaticDifferentiation.h:614
static AutomaticDifferentiationT< T, TNumeric > log2(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the logarithm to the base 2.
Definition AutomaticDifferentiation.h:658
friend AutomaticDifferentiationT< T1, TNumeric1 > operator+(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:417
Scalar value_
Definition AutomaticDifferentiation.h:352
AutomaticDifferentiationT< T, TNumeric > operator-() const
Unary negation operator returns the negative of this differentiation object.
Definition AutomaticDifferentiation.h:449
AutomaticDifferentiationT< T, TNumeric > operator-(const AutomaticDifferentiationT< T, TNumeric > &right) const
Subtracts two differentiation objects and determines the resulting derivative.
Definition AutomaticDifferentiation.h:442
static AutomaticDifferentiationT< T, TNumeric > min(const AutomaticDifferentiationT< T, TNumeric > &value, const T &second)
Determines the derivative of the min function.
Definition AutomaticDifferentiation.h:700
AutomaticDifferentiationT< T, TNumeric > & operator-=(const AutomaticDifferentiationT< T, TNumeric > &right)
Subtracts two differentiation objects and determines the resulting derivative.
Definition AutomaticDifferentiation.h:458
AutomaticDifferentiationT< T, TNumeric > operator/(const AutomaticDifferentiationT< T, TNumeric > &right) const
Divides two differentiation objects and determines the quotient derivative.
Definition AutomaticDifferentiation.h:537
AutomaticDifferentiationT< T, TNumeric > operator/(const T &right) const
Divides this differentiation object by a scalar value.
Definition AutomaticDifferentiation.h:554
AutomaticDifferentiationT< T, TNumeric > & operator*=(const T &right)
Multiplies this differentiation objects with a scalar.
Definition AutomaticDifferentiation.h:516
AutomaticDifferentiationT< T, TNumeric > & operator-=(const T &right)
Subtracts a scalar value from this differentiation object.
Definition AutomaticDifferentiation.h:476
AutomaticDifferentiationT< T, TNumeric > operator-(const T &right) const
Subtracts a scalar value from this differentiation object.
Definition AutomaticDifferentiation.h:467
static AutomaticDifferentiationT< T, TNumeric > sin(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the sinus function.
Definition AutomaticDifferentiation.h:587
AutomaticDifferentiationT< T, TNumeric > & operator+=(const AutomaticDifferentiationT< T, TNumeric > &right)
Adds two differentiation objects and determines the sum derivative.
Definition AutomaticDifferentiation.h:433
const T & operator()() const
Returns the actual derivative value of this object.
Definition AutomaticDifferentiation.h:395
AutomaticDifferentiationT(const T &value, const T &derivative)
Creates a new differentiation object by a given scalar and it's known derivative of the function at t...
Definition AutomaticDifferentiation.h:367
AutomaticDifferentiationT< T, TNumeric > operator*(const T &right) const
Multiplies this differentiation objects with a scalar.
Definition AutomaticDifferentiation.h:507
static AutomaticDifferentiationT< T, TNumeric > exp(const AutomaticDifferentiationT< T, TNumeric > &value)
Determines the derivative of the exponential function.
Definition AutomaticDifferentiation.h:636
friend AutomaticDifferentiationT< T1, TNumeric1 > operator/(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:576
AutomaticDifferentiationT(const T &value, const bool isVariable)
Creates a new differentiation object by a given scalar or constant value, while a boolean state speci...
Definition AutomaticDifferentiation.h:375
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:547
AutomaticDifferentiationT< T, TNumeric > operator+(const AutomaticDifferentiationT< T, TNumeric > &right) const
Adds two differentiation objects and determines the sum derivative.
Definition AutomaticDifferentiation.h:426
AutomaticDifferentiationT< T, TNumeric > & operator*=(const AutomaticDifferentiationT< T, TNumeric > &right)
Multiplies two differentiation objects and determines the product derivative.
Definition AutomaticDifferentiation.h:500
AutomaticDifferentiationT< T, TNumeric > & operator/=(const T &right)
Divides this differentiation object by a scalar value.
Definition AutomaticDifferentiation.h:565
friend AutomaticDifferentiationT< T1, TNumeric1 > operator*(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:528
static constexpr bool isNotEqualEps(const T value)
Returns whether a value is not smaller than or equal to a small epsilon.
Definition Numeric.h:2246
AutomaticDifferentiationT< Scalar, Numeric > AutomaticDifferentiation
Definition of a scalar differentiation object using the data type of Scalar as parameter.
Definition AutomaticDifferentiation.h:25
AutomaticDifferentiationT< double, NumericD > AutomaticDifferentiationD
Definition of a scalar differentiation object using double as data type.
Definition AutomaticDifferentiation.h:32
AutomaticDifferentiationT< float, NumericF > AutomaticDifferentiationF
Definition of a scalar differentiation object using float as data type.
Definition AutomaticDifferentiation.h:39
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:528
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:576
AutomaticDifferentiationT< T1, TNumeric1 > operator-(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:483