Namespace Scine::Utils::AutomaticDifferentiationΒΆ

namespace AutomaticDifferentiation

Typedefs

using Value1DType = typename Value1DOrder<o>::ValueType

Templated type for a value in 1 dimension.

using Value3DType = typename Value3DOrder<o>::ValueType

Templated type for a value in 3 dimension.

using DerivativeType = typename Derivative3DImpl<o>::ValueType

Templated type for a derivative.

using DerivativeContainerType = typename DerivativeContainer3DImpl<o>::ValueType

Templated type for a derivative container.

Functions

derivOrder getDerivativeOrderEnum(unsigned order)

Get the enum corresponding to the derivative order.

int getDerivativeOrder(derivOrder order)

Get the integer corresponding to the derivative order.

template<derivOrder o>
Value1DType<o> getFromFull(double v, double firstDer, double secondDer)

Create a value with derivatives in 1 dimension and neglect the unnecessary derivatives.

template<derivOrder o>
Value1DType<o> constant1D(double c)

Transform a double to a ValueWithDerivative in one dimension, with derivatives equal to zero.

template<derivOrder o>
Value1DType<o> variableWithUnitDerivative(double v)

Transform v to a ValueWithDerivative in one dimension, with first derivative 1 and second derivative 0.

template<derivOrder o>
Value3DType<o> constant3D(double c)

Transform a double to a ValueWithDerivative in three dimensions, with derivatives equal to zero.

template<derivOrder o>
Value3DType<o> toX(double x)

Get X as a value with derivatives in three dimensions.

The only non-zero derivative is the first derivative in x-direction.

template<derivOrder o>
Value3DType<o> toY(double y)

Get Y as a value with derivatives in three dimensions.

The only non-zero derivative is the first derivative in y-direction.

template<derivOrder o>
Value3DType<o> toZ(double z)

Get Z as a value with derivatives in three dimensions.

The only non-zero derivative is the first derivative in z-direction.

template<derivOrder o>
Value3DType<o> toRSquared(double x, double y, double z)

Get R-squared as a value with derivatives in three dimensions.

template<derivOrder o>
Value3DType<o> get3Dfrom1D(Value1DType<o> v, const Eigen::Vector3d &R)

Get a value with derivatives in 3 dimensions from the value with derivatives in one dimension, given a vector R.

template<derivOrder o>
Value3DType<o> getValueWithOppositeDerivative(const Value3DType<o> &v)

Get the value with inverted derivatives (useful for pairs of derivatives for two atoms).

The sign of the first derivatives changes.

template<derivOrder o>
double getValue1DAsDouble(const Value1DType<o> &v)

Extract the value with derivatives in 1 dimension as a double.

template<derivOrder o>
double getValue3DAsDouble(const Value3DType<o> &v)

Extract the value with derivatives in 3 dimension as a double.

template<>
double constant1D<derivOrder::zero>(double c)
template<>
double variableWithUnitDerivative<derivOrder::zero>(double v)
template<>
double getFromFull<derivOrder::zero>(double v, double, double)
template<>
double constant3D<derivOrder::zero>(double c)
template<>
double toX<derivOrder::zero>(double x)
template<>
double toY<derivOrder::zero>(double y)
template<>
double toZ<derivOrder::zero>(double z)
template<>
double toRSquared<derivOrder::zero>(double x, double y, double z)
template<>
double get3Dfrom1D<derivOrder::zero>(double v, const Eigen::Vector3d&)
template<>
double getValueWithOppositeDerivative<derivOrder::zero>(const double &v)
template<>
double getValue1DAsDouble<derivOrder::zero>(const double &v)
template<>
double getValue3DAsDouble<derivOrder::zero>(const double &v)
template<>
First1D constant1D<derivOrder::one>(double c)
template<>
First1D variableWithUnitDerivative<derivOrder::one>(double v)
template<>
First1D getFromFull<derivOrder::one>(double v, double firstDer, double)
template<>
First3D constant3D<derivOrder::one>(double c)
template<>
First3D toX<derivOrder::one>(double x)
template<>
First3D toY<derivOrder::one>(double y)
template<>
First3D toZ<derivOrder::one>(double z)
template<>
First3D toRSquared<derivOrder::one>(double x, double y, double z)
template<>
First3D get3Dfrom1D<derivOrder::one>(First1D v, const Eigen::Vector3d &R)
template<>
First3D getValueWithOppositeDerivative<derivOrder::one>(const First3D &v)
template<>
double getValue1DAsDouble<derivOrder::one>(const First1D &v)
template<>
double getValue3DAsDouble<derivOrder::one>(const First3D &v)
template<>
Second1D constant1D<derivOrder::two>(double c)
template<>
Second1D variableWithUnitDerivative<derivOrder::two>(double v)
template<>
Second1D getFromFull<derivOrder::two>(double v, double firstDer, double secondDer)
template<>
Second3D constant3D<derivOrder::two>(double c)
template<>
Second3D toX<derivOrder::two>(double x)
template<>
Second3D toY<derivOrder::two>(double y)
template<>
Second3D toZ<derivOrder::two>(double z)
template<>
Second3D toRSquared<derivOrder::two>(double x, double y, double z)
template<>
Second3D get3Dfrom1D<derivOrder::two>(Second1D v, const Eigen::Vector3d &R)
template<>
Second3D getValueWithOppositeDerivative<derivOrder::two>(const Second3D &v)
template<>
double getValue1DAsDouble<derivOrder::two>(const Second1D &v)
template<>
double getValue3DAsDouble<derivOrder::two>(const Second3D &v)
template<typename DerivativeT, typename Crtp>
Crtp operator+(double v, const FirstBase<DerivativeT, Crtp> &rhs)
template<typename DerivativeT, typename Crtp>
Crtp operator-(double v, const FirstBase<DerivativeT, Crtp> &rhs)
template<typename DerivativeT, typename Crtp>
Crtp operator*(double f, const FirstBase<DerivativeT, Crtp> &rhs)
template<typename DerivativeT, typename Crtp>
Crtp operator/(double f, const FirstBase<DerivativeT, Crtp> &rhs)
template<typename DerivativeT, typename Crtp>
Crtp square(const FirstBase<DerivativeT, Crtp> &value)
template<typename DerivativeT, typename Crtp>
Crtp sqrt(const FirstBase<DerivativeT, Crtp> &value)
template<typename DerivativeT, typename Crtp>
Crtp exp(const FirstBase<DerivativeT, Crtp> &value)
template<derivativeType o>
DerivativeType<o> getOppositeDerivative(const DerivativeType<o> &v)

Get opposed derivatives.

i.e. sign of first derivative changes.

template<derivativeType o>
DerivativeType<o> getDerivativeFromValueWithDerivatives(const Value3DType<UnderlyingOrder<o>> &v)

Extract the derivatives from a value type with derivatives.

template<derivativeType o>
void addDerivativeToContainer(DerivativeContainerType<o> &container, int a, int b, const DerivativeType<o> &v)

Add derivatives to a derivative container.

Parameters
  • v: Derivative for the pair of indexes a-b. Considering the direction a->b.

template<>
DerivativeType<derivativeType::first> getOppositeDerivative<derivativeType::first>(const DerivativeType<derivativeType::first> &v)
template<>
DerivativeType<derivativeType::second_atomic> getOppositeDerivative<derivativeType::second_atomic>(const DerivativeType<derivativeType::second_atomic> &v)
template<>
DerivativeType<derivativeType::second_full> getOppositeDerivative<derivativeType::second_full>(const DerivativeType<derivativeType::second_full> &v)
template<>
DerivativeType<derivativeType::first> getDerivativeFromValueWithDerivatives<derivativeType::first>(const Value3DType<derivOrder::one> &v)
template<>
DerivativeType<derivativeType::second_atomic> getDerivativeFromValueWithDerivatives<derivativeType::second_atomic>(const Value3DType<derivOrder::two> &v)
template<>
DerivativeType<derivativeType::second_full> getDerivativeFromValueWithDerivatives<derivativeType::second_full>(const Value3DType<derivOrder::two> &v)
template<>
void addDerivativeToContainer<derivativeType::first>(DerivativeContainerType<derivativeType::first> &container, int a, int b, const DerivativeType<derivativeType::first> &v)
template<>
void addDerivativeToContainer<derivativeType::second_atomic>(DerivativeContainerType<derivativeType::second_atomic> &container, int a, int b, const DerivativeType<derivativeType::second_atomic> &v)
template<>
void addDerivativeToContainer<derivativeType::second_full>(DerivativeContainerType<derivativeType::second_full> &container, int a, int b, const DerivativeType<derivativeType::second_full> &v)
Second1D operator*(double f, const Second1D &der)
Second1D operator+(double f, const Second1D &h)
Second1D operator+(const Second1D &h, double f)
Second1D operator-(double f, const Second1D &h)
Second1D operator-(const Second1D &h, double f)
Second1D operator/(double v, const Second1D &der)
Second1D sqrt(const Second1D &der)
Second1D exp(const Second1D &der)
Second1D cos(const Second1D &der)
Second3D operator*(double f, const Second3D &der)
Second3D sqrt(const Second3D &der)
Second3D exp(const Second3D &der)
Second3D arccos(const Second3D &der)

Variables

constexpr derivOrder UnderlyingOrder = UnderlyingOrderImpl<O>::o

Template variable for the derivative order corresponding to a derivative type.

template<derivOrder O>
struct Value3DOrder
#include <AutomaticDifferentiationTypesHelper.h>

Values in 3 dimensions.

template<derivOrder O>
struct Value1DOrder
#include <AutomaticDifferentiationTypesHelper.h>

Values in 1 dimension.

class First1D : public Scine::Utils::AutomaticDifferentiation::FirstBase<double, First1D>
#include <First1D.h>

Class representing values in one dimension and allowing for the automatic calculation of first derivatives.

class First3D : public Scine::Utils::AutomaticDifferentiation::FirstBase<Eigen::Vector3d, First3D>
#include <First3D.h>

Class representing values in one dimensions and allowing for the automatic calculation of first derivatives.

template<typename DerivativeT, typename Crtp>
class FirstBase
#include <FirstBase.h>

Base class representing values with some derivative type and allowing for the automatic calculation of first derivatives.

This class makes use of CRTP so that the functions will directly have the correct return type for the derived classes.

class FirstND : public Scine::Utils::AutomaticDifferentiation::FirstBase<Eigen::MatrixXd, FirstND>
#include <FirstND.h>

Class representing values in N dimensions and allowing for the automatic calculation of first derivatives in those N dimensions.

class Second1D
#include <Second1D.h>

Class representing values in one dimensions and allowing for the automatic calculation of first and second derivatives.

class Second3D
#include <Second3D.h>

Class representing values in three dimensions and allowing for the automatic calculation of first and second derivatives.