Drake
Drake C++ Documentation
autodiff_gradient.h File Reference

Detailed Description

Utilities that relate simultaneously to both autodiff matrices and gradient matrices.

#include <algorithm>
#include <optional>
#include <Eigen/Dense>
#include <fmt/format.h>
#include "drake/common/drake_assert.h"
#include "drake/common/unused.h"
#include "drake/math/autodiff.h"
#include "drake/math/gradient.h"
Include dependency graph for autodiff_gradient.h:
This graph shows which files directly or indirectly include this file:

Namespaces

 drake
 
 drake::math
 

Functions

template<typename Derived >
Eigen::Matrix< typename Derived::Scalar::Scalar, Derived::SizeAtCompileTime, Eigen::Dynamic > ExtractGradient (const Eigen::MatrixBase< Derived > &auto_diff_matrix, std::optional< int > num_derivatives={})
 Extracts the derivatives() portion from a matrix of AutoDiffScalar entries. More...
 
template<typename DerivedValue , typename DerivedGradient , typename DerivedAutoDiff >
void InitializeAutoDiff (const Eigen::MatrixBase< DerivedValue > &value, const Eigen::MatrixBase< DerivedGradient > &gradient, Eigen::MatrixBase< DerivedAutoDiff > *auto_diff_matrix)
 Initializes an AutoDiff matrix given a matrix of values and a gradient matrix. More...
 
template<typename DerivedValue , typename DerivedGradient >
AutoDiffMatrixType< DerivedValue, DerivedGradient::ColsAtCompileTime > InitializeAutoDiff (const Eigen::MatrixBase< DerivedValue > &value, const Eigen::MatrixBase< DerivedGradient > &gradient)
 Returns an AutoDiff matrix given a matrix of values and a gradient matrix. More...
 
template<typename Derived >
decltype(auto) DiscardZeroGradient (const Eigen::MatrixBase< Derived > &auto_diff_matrix, double precision=Eigen::NumTraits< double >::dummy_precision())
 B = DiscardZeroGradient(A, precision) enables casting from a matrix of AutoDiffScalars to AutoDiffScalar::Scalar type, but first checking that the gradient matrix is empty or zero. More...
 
template<typename Derived >
std::enable_if<!std::is_same_v< typename Derived::Scalar, double >, int >::type GetDerivativeSize (const Eigen::MatrixBase< Derived > &A)
 Given a matrix of AutoDiffScalars, returns the size of the derivatives. More...
 
bool AreAutoDiffVecXdEqual (const Eigen::Ref< const VectorX< AutoDiffXd >> &a, const Eigen::Ref< const VectorX< AutoDiffXd >> &b)
 Determines if a and b are equal. More...