Drake
Drake C++ Documentation
Loading...
Searching...
No Matches
autodiff.h File Reference

Detailed Description

Utilities for arithmetic on AutoDiffScalar.

#include <array>
#include <cmath>
#include <optional>
#include <tuple>
#include <utility>
#include <Eigen/Dense>
#include <unsupported/Eigen/AutoDiff>
#include "drake/common/autodiff.h"
#include "drake/common/drake_assert.h"
#include "drake/common/eigen_types.h"
#include "drake/common/unused.h"
Include dependency graph for autodiff.h:
This graph shows which files directly or indirectly include this file:

Namespaces

namespace  drake
namespace  drake::math

Typedefs

template<typename Derived, int nq>
using AutoDiffMatrixType
 The appropriate AutoDiffScalar matrix type given the value type and the number of derivatives at compile time.

Functions

template<typename Derived>
void ExtractValue (const Eigen::MatrixBase< Derived > &auto_diff_matrix, MatrixLikewise< typename Derived::Scalar::Scalar, Derived > *value)
 Extracts the value() portion from an AutoDiffScalar matrix into a pre-existing matrix (resizing if necessary).
template<typename Derived>
MatrixLikewise< typename Derived::Scalar::Scalar, Derived > ExtractValue (const Eigen::MatrixBase< Derived > &auto_diff_matrix)
 Returns the value() portion from a matrix of AutoDiffScalar entries.
template<typename Derived>
decltype(auto) DiscardGradient (const Eigen::MatrixBase< Derived > &matrix)
 B = DiscardGradient(A) enables casting from a matrix of AutoDiffScalars to AutoDiffScalar::Scalar type, explicitly throwing away any gradient information.
template<typename Derived, typename DerivedAutoDiff>
void InitializeAutoDiff (const Eigen::MatrixBase< Derived > &value, std::optional< int > num_derivatives, std::optional< int > deriv_num_start, Eigen::MatrixBase< DerivedAutoDiff > *auto_diff_matrix)
 Initializes a single AutoDiff matrix given the corresponding value matrix.
template<typename Derived, typename DerivedAutoDiff>
void InitializeAutoDiff (const Eigen::MatrixBase< Derived > &value, Eigen::MatrixBase< DerivedAutoDiff > *auto_diff_matrix)
 Alternate signature provides default values for the number of derivatives (dynamic, determined at run time) and the starting index (0).
template<int nq = Eigen::Dynamic, typename Derived>
AutoDiffMatrixType< Derived, nq > InitializeAutoDiff (const Eigen::MatrixBase< Derived > &value, std::optional< int > num_derivatives={}, std::optional< int > deriv_num_start={})
 Initializes a single AutoDiff matrix given the corresponding value matrix.
template<typename... Deriveds>
auto InitializeAutoDiffTuple (const Eigen::MatrixBase< Deriveds > &... args)
 Given a series of Eigen matrices, creates a tuple of corresponding AutoDiff matrices with values equal to the input matrices and properly initialized derivative vectors.