A scalar type that performs automatic differentiation, similar to Eigen::AutoDiffScalar<Eigen::VectorXd>.
Unlike Eigen::AutoDiffScalar, Drake's AutoDiff is not templated; it only supports dynamically-sized derivatives using floating-point doubles.
However, by using a careful representation trick (maintaining a separate scale factor) it runs faster than Eigen::AutoDiffScalar<Eigen::VectorXd>.
#include <drake/common/ad/auto_diff.h>
Public Types | |
| using | DerType = Eigen::VectorXd |
| Compatibility alias to mimic Eigen::AutoDiffScalar. | |
| using | Scalar = double |
| Compatibility alias to mimic Eigen::AutoDiffScalar. | |
Public Member Functions | |
| AutoDiff ()=default | |
| Constructs zero. | |
| AutoDiff (double value) | |
| Constructs a value with empty derivatives. | |
| AutoDiff (double value, Eigen::Index size, Eigen::Index offset) | |
| Constructs a value with a single partial derivative of 1.0 at the given offset in a vector of size otherwise-zero derivatives. | |
| AutoDiff (double value, const Eigen::Ref< const Eigen::VectorXd > &derivatives) | |
| Constructs a value with the given derivatives. | |
| AutoDiff & | operator= (double value) |
| Assigns a value and clears the derivatives. | |
| ~AutoDiff ()=default | |
| double | value () const |
| Returns the value part of this AutoDiff (readonly). | |
| double & | value () |
| (Advanced) Returns the value part of this AutoDiff (mutable). | |
| DerivativesConstXpr | derivatives () const |
| Returns a view of the derivatives part of this AutoDiff (readonly). | |
| DerivativesMutableXpr | derivatives () |
| (Advanced) Returns a mutable view of the derivatives part of this AutoDiff. | |
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable | |
| AutoDiff (const AutoDiff &)=default | |
| AutoDiff & | operator= (const AutoDiff &)=default |
| AutoDiff (AutoDiff &&)=default | |
| AutoDiff & | operator= (AutoDiff &&)=default |
Internal use only | |
| const internal::Partials & | partials () const |
| (Internal use only) Users should call derivatives() instead. | |
| internal::Partials & | partials () |
| (Internal use only) Users should call derivatives() instead. | |
| using DerType = Eigen::VectorXd |
Compatibility alias to mimic Eigen::AutoDiffScalar.
|
default |
|
default |
|
default |
Constructs zero.
| AutoDiff | ( | double | value | ) |
Constructs a value with empty derivatives.
| AutoDiff | ( | double | value, |
| Eigen::Index | size, | ||
| Eigen::Index | offset ) |
Constructs a value with a single partial derivative of 1.0 at the given offset in a vector of size otherwise-zero derivatives.
| AutoDiff | ( | double | value, |
| const Eigen::Ref< const Eigen::VectorXd > & | derivatives ) |
Constructs a value with the given derivatives.
|
default |
| DerivativesMutableXpr derivatives | ( | ) |
(Advanced) Returns a mutable view of the derivatives part of this AutoDiff.
Instead of mutating the derivatives after construction, it's generally preferable to set them directly in the constructor if possible.
| DerivativesConstXpr derivatives | ( | ) | const |
Returns a view of the derivatives part of this AutoDiff (readonly).
| internal::Partials & partials | ( | ) |
(Internal use only) Users should call derivatives() instead.
| const internal::Partials & partials | ( | ) | const |
(Internal use only) Users should call derivatives() instead.
| double & value | ( | ) |
(Advanced) Returns the value part of this AutoDiff (mutable).
Operations on this value will NOT alter the derivatives.
| double value | ( | ) | const |
Returns the value part of this AutoDiff (readonly).