Drake
Drake C++ Documentation
Loading...
Searching...
No Matches
drake::ad Namespace Reference

Classes

class  AutoDiff
 A scalar type that performs automatic differentiation, similar to Eigen::AutoDiffScalar<Eigen::VectorXd>. More...

Functions

Increment and decrement
AutoDiffoperator++ (AutoDiff &x)
 Standard prefix increment operator (i.e., ++x).
AutoDiff operator++ (AutoDiff &x, int)
 Standard postfix increment operator (i.e., x++).
AutoDiffoperator-- (AutoDiff &x)
 Standard prefix decrement operator (i.e., --x).
AutoDiff operator-- (AutoDiff &x, int)
 Standard postfix decrement operator (i.e., x--).
Arithmetic operators
AutoDiffoperator+= (AutoDiff &a, const AutoDiff &b)
 Standard compound addition and assignment operator.
AutoDiffoperator+= (AutoDiff &a, double b)
 Standard compound addition and assignment operator.
AutoDiffoperator-= (AutoDiff &a, const AutoDiff &b)
 Standard compound subtraction and assignment operator.
AutoDiffoperator-= (AutoDiff &a, double b)
 Standard compound subtraction and assignment operator.
AutoDiffoperator*= (AutoDiff &a, const AutoDiff &b)
 Standard compound multiplication and assignment operator.
AutoDiffoperator*= (AutoDiff &a, double b)
 Standard compound multiplication and assignment operator.
AutoDiffoperator/= (AutoDiff &a, const AutoDiff &b)
 Standard compound division and assignment operator.
AutoDiffoperator/= (AutoDiff &a, double b)
 Standard compound division and assignment operator.
AutoDiff operator+ (AutoDiff a, const AutoDiff &b)
 Standard addition operator.
AutoDiff operator+ (AutoDiff a, double b)
 Standard addition operator.
AutoDiff operator+ (double a, AutoDiff b)
 Standard addition operator.
AutoDiff operator+ (AutoDiff x)
 Standard unary plus operator.
AutoDiff operator- (AutoDiff a, const AutoDiff &b)
 Standard subtraction operator.
AutoDiff operator- (AutoDiff a, double b)
 Standard subtraction operator.
AutoDiff operator- (double a, AutoDiff b)
 Standard subtraction operator.
AutoDiff operator- (AutoDiff x)
 Standard unary minus operator.
AutoDiff operator* (AutoDiff a, const AutoDiff &b)
 Standard multiplication operator.
AutoDiff operator* (AutoDiff a, double b)
 Standard multiplication operator.
AutoDiff operator* (double a, AutoDiff b)
 Standard multiplication operator.
AutoDiff operator/ (AutoDiff a, const AutoDiff &b)
 Standard division operator.
AutoDiff operator/ (AutoDiff a, double b)
 Standard division operator.
AutoDiff operator/ (double a, const AutoDiff &b)
 Standard division operator.
Comparison operators
bool operator< (const AutoDiff &a, const AutoDiff &b)
 Standard comparison operator.
bool operator<= (const AutoDiff &a, const AutoDiff &b)
 Standard comparison operator.
bool operator> (const AutoDiff &a, const AutoDiff &b)
 Standard comparison operator.
bool operator>= (const AutoDiff &a, const AutoDiff &b)
 Standard comparison operator.
bool operator== (const AutoDiff &a, const AutoDiff &b)
 Standard comparison operator.
bool operator!= (const AutoDiff &a, const AutoDiff &b)
 Standard comparison operator.
bool operator< (const AutoDiff &a, double b)
 Standard comparison operator.
bool operator<= (const AutoDiff &a, double b)
 Standard comparison operator.
bool operator> (const AutoDiff &a, double b)
 Standard comparison operator.
bool operator>= (const AutoDiff &a, double b)
 Standard comparison operator.
bool operator== (const AutoDiff &a, double b)
 Standard comparison operator.
bool operator!= (const AutoDiff &a, double b)
 Standard comparison operator.
bool operator< (double a, const AutoDiff &b)
 Standard comparison operator.
bool operator<= (double a, const AutoDiff &b)
 Standard comparison operator.
bool operator> (double a, const AutoDiff &b)
 Standard comparison operator.
bool operator>= (double a, const AutoDiff &b)
 Standard comparison operator.
bool operator== (double a, const AutoDiff &b)
 Standard comparison operator.
bool operator!= (double a, const AutoDiff &b)
 Standard comparison operator.
Minimum/maximum operations
const AutoDiffmax (const AutoDiff &a, const AutoDiff &b)
 ADL overload to mimic std::max from <algorithm>.
AutoDiff max (AutoDiff a, double b)
 ADL overload to mimic std::max from <algorithm>.
AutoDiff max (double a, AutoDiff b)
 ADL overload to mimic std::max from <algorithm>.
const AutoDiffmin (const AutoDiff &a, const AutoDiff &b)
 ADL overload to mimic std::min from <algorithm>.
AutoDiff min (AutoDiff a, double b)
 ADL overload to mimic std::min from <algorithm>.
AutoDiff min (double a, AutoDiff b)
 ADL overload to mimic std::min from <algorithm>.
Math functions: Basic operations
AutoDiff abs (AutoDiff x)
 ADL overload to mimic std::abs from <cmath>.
AutoDiff abs2 (AutoDiff x)
 ADL overload to mimic Eigen::numext::abs2.
Math functions: Exponential and Power functions
AutoDiff exp (AutoDiff x)
 ADL overload to mimic std::exp from <cmath>.
AutoDiff log (AutoDiff x)
 ADL overload to mimic std::log from <cmath>.
AutoDiff pow (AutoDiff base, const AutoDiff &exp)
 ADL overload to mimic std::pow from <cmath>.
AutoDiff pow (double base, const AutoDiff &exp)
 ADL overload to mimic std::pow from <cmath>.
AutoDiff pow (AutoDiff base, double exp)
 ADL overload to mimic std::pow from <cmath>.
AutoDiff sqrt (AutoDiff x)
 ADL overload to mimic std::sqrt from <cmath>.
Math functions: Trigonometric functions
AutoDiff sin (AutoDiff x)
 ADL overload to mimic std::sin from <cmath>.
AutoDiff cos (AutoDiff x)
 ADL overload to mimic std::cos from <cmath>.
AutoDiff tan (AutoDiff x)
 ADL overload to mimic std::tan from <cmath>.
AutoDiff asin (AutoDiff x)
 ADL overload to mimic std::asin from <cmath>.
AutoDiff acos (AutoDiff x)
 ADL overload to mimic std::acos from <cmath>.
AutoDiff atan (AutoDiff x)
 ADL overload to mimic std::atan from <cmath>.
AutoDiff atan2 (AutoDiff a, const AutoDiff &b)
 ADL overload to mimic std::atan2 from <cmath>.
AutoDiff atan2 (AutoDiff a, double b)
 ADL overload to mimic std::atan2 from <cmath>.
AutoDiff atan2 (double a, AutoDiff b)
 ADL overload to mimic std::atan2 from <cmath>.
Math functions: Hyperbolic functions
AutoDiff sinh (AutoDiff x)
 ADL overload to mimic std::sinh from <cmath>.
AutoDiff cosh (AutoDiff x)
 ADL overload to mimic std::cosh from <cmath>.
AutoDiff tanh (AutoDiff x)
 ADL overload to mimic std::tanh from <cmath>.
Math functions: Nearest integer floating point operations
double ceil (const AutoDiff &x)
 ADL overload to mimic std::ceil from <cmath>.
double floor (const AutoDiff &x)
 ADL overload to mimic std::floor from <cmath>.
double round (const AutoDiff &x)
 ADL overload to mimic std::round from <cmath>.
double nexttoward (const AutoDiff &from, long double to)
 ADL overload to mimic std::nexttoward from <cmath>.
AutoDiff copysign (const AutoDiff &mag, const AutoDiff &sgn)
 ADL overload to mimic std::copysign from <cmath>.
bool isfinite (const AutoDiff &x)
 ADL overload to mimic std::isfinite from <cmath>.
bool isinf (const AutoDiff &x)
 ADL overload to mimic std::isinf from <cmath>.
bool isnan (const AutoDiff &x)
 ADL overload to mimic std::isnan from <cmath>.

Function Documentation

◆ abs()

AutoDiff abs ( AutoDiff x)

ADL overload to mimic std::abs from <cmath>.

◆ abs2()

AutoDiff abs2 ( AutoDiff x)

ADL overload to mimic Eigen::numext::abs2.

◆ acos()

AutoDiff acos ( AutoDiff x)

ADL overload to mimic std::acos from <cmath>.

◆ asin()

AutoDiff asin ( AutoDiff x)

ADL overload to mimic std::asin from <cmath>.

◆ atan()

AutoDiff atan ( AutoDiff x)

ADL overload to mimic std::atan from <cmath>.

◆ atan2() [1/3]

AutoDiff atan2 ( AutoDiff a,
const AutoDiff & b )

ADL overload to mimic std::atan2 from <cmath>.

◆ atan2() [2/3]

AutoDiff atan2 ( AutoDiff a,
double b )

ADL overload to mimic std::atan2 from <cmath>.

◆ atan2() [3/3]

AutoDiff atan2 ( double a,
AutoDiff b )

ADL overload to mimic std::atan2 from <cmath>.

◆ ceil()

double ceil ( const AutoDiff & x)

ADL overload to mimic std::ceil from <cmath>.

The result's derivatives are always zero.

◆ copysign()

AutoDiff copysign ( const AutoDiff & mag,
const AutoDiff & sgn )

ADL overload to mimic std::copysign from <cmath>.

◆ cos()

AutoDiff cos ( AutoDiff x)

ADL overload to mimic std::cos from <cmath>.

◆ cosh()

AutoDiff cosh ( AutoDiff x)

ADL overload to mimic std::cosh from <cmath>.

◆ exp()

AutoDiff exp ( AutoDiff x)

ADL overload to mimic std::exp from <cmath>.

◆ floor()

double floor ( const AutoDiff & x)

ADL overload to mimic std::floor from <cmath>.

The result's derivatives are always zero.

◆ isfinite()

bool isfinite ( const AutoDiff & x)

ADL overload to mimic std::isfinite from <cmath>.

Because the return type is bool, the derivatives are not preserved.

◆ isinf()

bool isinf ( const AutoDiff & x)

ADL overload to mimic std::isinf from <cmath>.

Because the return type is bool, the derivatives are not preserved.

◆ isnan()

bool isnan ( const AutoDiff & x)

ADL overload to mimic std::isnan from <cmath>.

Because the return type is bool, the derivatives are not preserved.

◆ log()

AutoDiff log ( AutoDiff x)

ADL overload to mimic std::log from <cmath>.

◆ max() [1/3]

AutoDiff max ( AutoDiff a,
double b )

ADL overload to mimic std::max from <algorithm>.

When a and b are equal, retains the derivatives of a.

◆ max() [2/3]

const AutoDiff & max ( const AutoDiff & a,
const AutoDiff & b )

ADL overload to mimic std::max from <algorithm>.

Note that like std::max, this function returns a reference to whichever argument was chosen; it does not make a copy. When a and b are equal, retains the derivatives of a (by returning a) unless a has empty derivatives, in which case b is returned.

◆ max() [3/3]

AutoDiff max ( double a,
AutoDiff b )

ADL overload to mimic std::max from <algorithm>.

When a and b are equal, retains the derivatives of b.

◆ min() [1/3]

AutoDiff min ( AutoDiff a,
double b )

ADL overload to mimic std::min from <algorithm>.

When a and b are equal, retains the derivatives of a.

◆ min() [2/3]

const AutoDiff & min ( const AutoDiff & a,
const AutoDiff & b )

ADL overload to mimic std::min from <algorithm>.

Note that like std::min, this function returns a reference to whichever argument was chosen; it does not make a copy. When a and b are equal, retains the derivatives of a (by returning a) unless a has empty derivatives, in which case b is returned.

◆ min() [3/3]

AutoDiff min ( double a,
AutoDiff b )

ADL overload to mimic std::min from <algorithm>.

When a and b are equal, retains the derivatives of b.

◆ nexttoward()

double nexttoward ( const AutoDiff & from,
long double to )

ADL overload to mimic std::nexttoward from <cmath>.

The result's derivatives are always zero.

◆ operator!=() [1/3]

bool operator!= ( const AutoDiff & a,
const AutoDiff & b )

Standard comparison operator.

Discards the derivatives.

◆ operator!=() [2/3]

bool operator!= ( const AutoDiff & a,
double b )

Standard comparison operator.

Discards the derivatives.

◆ operator!=() [3/3]

bool operator!= ( double a,
const AutoDiff & b )

Standard comparison operator.

Discards the derivatives.

◆ operator*() [1/3]

AutoDiff operator* ( AutoDiff a,
const AutoDiff & b )

Standard multiplication operator.

◆ operator*() [2/3]

AutoDiff operator* ( AutoDiff a,
double b )

Standard multiplication operator.

◆ operator*() [3/3]

AutoDiff operator* ( double a,
AutoDiff b )

Standard multiplication operator.

◆ operator*=() [1/2]

AutoDiff & operator*= ( AutoDiff & a,
const AutoDiff & b )

Standard compound multiplication and assignment operator.

◆ operator*=() [2/2]

AutoDiff & operator*= ( AutoDiff & a,
double b )

Standard compound multiplication and assignment operator.

◆ operator+() [1/4]

AutoDiff operator+ ( AutoDiff a,
const AutoDiff & b )

Standard addition operator.

◆ operator+() [2/4]

AutoDiff operator+ ( AutoDiff a,
double b )

Standard addition operator.

◆ operator+() [3/4]

AutoDiff operator+ ( AutoDiff x)

Standard unary plus operator.

◆ operator+() [4/4]

AutoDiff operator+ ( double a,
AutoDiff b )

Standard addition operator.

◆ operator++() [1/2]

AutoDiff & operator++ ( AutoDiff & x)

Standard prefix increment operator (i.e., ++x).

◆ operator++() [2/2]

AutoDiff operator++ ( AutoDiff & x,
int  )

Standard postfix increment operator (i.e., x++).

◆ operator+=() [1/2]

AutoDiff & operator+= ( AutoDiff & a,
const AutoDiff & b )

Standard compound addition and assignment operator.

◆ operator+=() [2/2]

AutoDiff & operator+= ( AutoDiff & a,
double b )

Standard compound addition and assignment operator.

◆ operator-() [1/4]

AutoDiff operator- ( AutoDiff a,
const AutoDiff & b )

Standard subtraction operator.

◆ operator-() [2/4]

AutoDiff operator- ( AutoDiff a,
double b )

Standard subtraction operator.

◆ operator-() [3/4]

AutoDiff operator- ( AutoDiff x)

Standard unary minus operator.

◆ operator-() [4/4]

AutoDiff operator- ( double a,
AutoDiff b )

Standard subtraction operator.

◆ operator--() [1/2]

AutoDiff & operator-- ( AutoDiff & x)

Standard prefix decrement operator (i.e., --x).

◆ operator--() [2/2]

AutoDiff operator-- ( AutoDiff & x,
int  )

Standard postfix decrement operator (i.e., x--).

◆ operator-=() [1/2]

AutoDiff & operator-= ( AutoDiff & a,
const AutoDiff & b )

Standard compound subtraction and assignment operator.

◆ operator-=() [2/2]

AutoDiff & operator-= ( AutoDiff & a,
double b )

Standard compound subtraction and assignment operator.

◆ operator/() [1/3]

AutoDiff operator/ ( AutoDiff a,
const AutoDiff & b )

Standard division operator.

◆ operator/() [2/3]

AutoDiff operator/ ( AutoDiff a,
double b )

Standard division operator.

◆ operator/() [3/3]

AutoDiff operator/ ( double a,
const AutoDiff & b )

Standard division operator.

◆ operator/=() [1/2]

AutoDiff & operator/= ( AutoDiff & a,
const AutoDiff & b )

Standard compound division and assignment operator.

◆ operator/=() [2/2]

AutoDiff & operator/= ( AutoDiff & a,
double b )

Standard compound division and assignment operator.

◆ operator<() [1/3]

bool operator< ( const AutoDiff & a,
const AutoDiff & b )

Standard comparison operator.

Discards the derivatives.

◆ operator<() [2/3]

bool operator< ( const AutoDiff & a,
double b )

Standard comparison operator.

Discards the derivatives.

◆ operator<() [3/3]

bool operator< ( double a,
const AutoDiff & b )

Standard comparison operator.

Discards the derivatives.

◆ operator<=() [1/3]

bool operator<= ( const AutoDiff & a,
const AutoDiff & b )

Standard comparison operator.

Discards the derivatives.

◆ operator<=() [2/3]

bool operator<= ( const AutoDiff & a,
double b )

Standard comparison operator.

Discards the derivatives.

◆ operator<=() [3/3]

bool operator<= ( double a,
const AutoDiff & b )

Standard comparison operator.

Discards the derivatives.

◆ operator==() [1/3]

bool operator== ( const AutoDiff & a,
const AutoDiff & b )

Standard comparison operator.

Discards the derivatives.

◆ operator==() [2/3]

bool operator== ( const AutoDiff & a,
double b )

Standard comparison operator.

Discards the derivatives.

◆ operator==() [3/3]

bool operator== ( double a,
const AutoDiff & b )

Standard comparison operator.

Discards the derivatives.

◆ operator>() [1/3]

bool operator> ( const AutoDiff & a,
const AutoDiff & b )

Standard comparison operator.

Discards the derivatives.

◆ operator>() [2/3]

bool operator> ( const AutoDiff & a,
double b )

Standard comparison operator.

Discards the derivatives.

◆ operator>() [3/3]

bool operator> ( double a,
const AutoDiff & b )

Standard comparison operator.

Discards the derivatives.

◆ operator>=() [1/3]

bool operator>= ( const AutoDiff & a,
const AutoDiff & b )

Standard comparison operator.

Discards the derivatives.

◆ operator>=() [2/3]

bool operator>= ( const AutoDiff & a,
double b )

Standard comparison operator.

Discards the derivatives.

◆ operator>=() [3/3]

bool operator>= ( double a,
const AutoDiff & b )

Standard comparison operator.

Discards the derivatives.

◆ pow() [1/3]

AutoDiff pow ( AutoDiff base,
const AutoDiff & exp )

ADL overload to mimic std::pow from <cmath>.

The resulting partial derivative ∂/∂vᵢ is undefined (i.e., NaN) for all of the following cases:

  • ∂base/∂vᵢ is non-zero and either:
    • base, exp, or pow(base, exp) not finite, or
    • base is 0 and exp < 0
  • ∂exp/∂vᵢ is non-zero and either:
    • base, exp, or pow(base, exp) not finite, or
    • base is < 0

In all other cases, if the base and exp partial derivatives were well-defined then the resulting partial derivatives will also be well-defined.

◆ pow() [2/3]

AutoDiff pow ( AutoDiff base,
double exp )

ADL overload to mimic std::pow from <cmath>.

Refer to pow(AutoDiff,const AutoDiff&) for an explanation of special cases.

◆ pow() [3/3]

AutoDiff pow ( double base,
const AutoDiff & exp )

ADL overload to mimic std::pow from <cmath>.

Refer to pow(AutoDiff,const AutoDiff&) for an explanation of special cases.

◆ round()

double round ( const AutoDiff & x)

ADL overload to mimic std::round from <cmath>.

The result's derivatives are always zero.

◆ sin()

AutoDiff sin ( AutoDiff x)

ADL overload to mimic std::sin from <cmath>.

◆ sinh()

AutoDiff sinh ( AutoDiff x)

ADL overload to mimic std::sinh from <cmath>.

◆ sqrt()

AutoDiff sqrt ( AutoDiff x)

ADL overload to mimic std::sqrt from <cmath>.

◆ tan()

AutoDiff tan ( AutoDiff x)

ADL overload to mimic std::tan from <cmath>.

◆ tanh()

AutoDiff tanh ( AutoDiff x)

ADL overload to mimic std::tanh from <cmath>.