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.
At the moment, the features of this class are similar to Eigen::AutoDiffScalar, but in the future Drake will further customize this class to optimize its runtime performance and better integrate it with our optimization tools.
#include <drake/common/ad/auto_diff.h>
Public Types | |
using | DerType = Eigen::VectorXd |
Compatibility alias to mimic Eigen::AutoDiffScalar. More... | |
using | Scalar = double |
Compatibility alias to mimic Eigen::AutoDiffScalar. More... | |
Public Member Functions | |
AutoDiff ()=default | |
Constructs zero. More... | |
AutoDiff (double value) | |
Constructs a value with empty derivatives. More... | |
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. More... | |
AutoDiff (double value, const Eigen::Ref< const Eigen::VectorXd > &derivatives) | |
Constructs a value with the given derivatives. More... | |
AutoDiff & | operator= (double value) |
Assigns a value and clears the derivatives. More... | |
~AutoDiff ()=default | |
double | value () const |
Returns the value part of this AutoDiff (readonly). More... | |
double & | value () |
(Advanced) Returns the value part of this AutoDiff (mutable). More... | |
const Eigen::VectorXd & | derivatives () const |
Returns a view of the derivatives part of this AutoDiff (readonly). More... | |
Eigen::VectorXd & | derivatives () |
(Advanced) Returns a mutable view of the derivatives part of this AutoDiff. More... | |
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. More... | |
internal::Partials & | partials () |
(Internal use only) Users should call derivatives() instead. More... | |
using DerType = Eigen::VectorXd |
Compatibility alias to mimic Eigen::AutoDiffScalar.
|
default |
Constructs zero.
Constructs a value with a single partial derivative of 1.0 at the given offset
in a vector of size
otherwise-zero derivatives.
Constructs a value with the given derivatives.
|
default |
const Eigen::VectorXd& derivatives | ( | ) | const |
Returns a view of the derivatives part of this AutoDiff (readonly).
Do not presume any specific C++ type for the the return value. It will act like an Eigen column-vector expression (e.g., Eigen::Block<const VectorXd>), but we reserve the right to change the return type for efficiency down the road.
Eigen::VectorXd& 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.
Do not presume any specific C++ type for the the return value. It will act like a mutable Eigen column-vector expression (e.g., Eigen::Block<VectorXd>) that also allows for assignment and resizing, but we reserve the right to change the return type for efficiency down the road.
const internal::Partials& partials | ( | ) | const |
(Internal use only) Users should call derivatives() instead.
internal::Partials& partials | ( | ) |
(Internal use only) Users should call derivatives() instead.
double value | ( | ) | const |
Returns the value part of this AutoDiff (readonly).
double& value | ( | ) |
(Advanced) Returns the value part of this AutoDiff (mutable).
Operations on this value will NOT alter the derivatives.