gtsam  4.0.0
gtsam
gtsam::Expression< T > Class Template Reference

Detailed Description

template<typename T>
class gtsam::Expression< T >

Expression class that supports automatic differentiation.

+ Inheritance diagram for gtsam::Expression< T >:

Public Member Functions

 Expression (const T &value)
 Construct a constant expression.
 
 Expression (const Key &key)
 Construct a leaf expression, with Key.
 
 Expression (const Symbol &symbol)
 Construct a leaf expression, with Symbol.
 
 Expression (unsigned char c, std::uint64_t j)
 Construct a leaf expression, creating Symbol.
 
template<typename A >
 Expression (typename UnaryFunction< A >::type function, const Expression< A > &expression)
 Construct a unary function expression.
 
template<typename A1 , typename A2 >
 Expression (typename BinaryFunction< A1, A2 >::type function, const Expression< A1 > &expression1, const Expression< A2 > &expression2)
 Construct a binary function expression.
 
template<typename A1 , typename A2 , typename A3 >
 Expression (typename TernaryFunction< A1, A2, A3 >::type function, const Expression< A1 > &expression1, const Expression< A2 > &expression2, const Expression< A3 > &expression3)
 Construct a ternary function expression.
 
template<typename A >
 Expression (const Expression< A > &expression, T(A::*method)(typename MakeOptionalJacobian< T, A >::type) const)
 Construct a nullary method expression.
 
template<typename A1 , typename A2 >
 Expression (const Expression< A1 > &expression1, T(A1::*method)(const A2 &, typename MakeOptionalJacobian< T, A1 >::type, typename MakeOptionalJacobian< T, A2 >::type) const, const Expression< A2 > &expression2)
 Construct a unary method expression.
 
template<typename A1 , typename A2 , typename A3 >
 Expression (const Expression< A1 > &expression1, T(A1::*method)(const A2 &, const A3 &, typename MakeOptionalJacobian< T, A1 >::type, typename MakeOptionalJacobian< T, A2 >::type, typename MakeOptionalJacobian< T, A3 >::type) const, const Expression< A2 > &expression2, const Expression< A3 > &expression3)
 Construct a binary method expression.
 
virtual ~Expression ()
 Destructor.
 
std::set< Keykeys () const
 Return keys that play in this expression.
 
void dims (std::map< Key, int > &map) const
 Return dimensions for each argument, as a map.
 
void print (const std::string &s) const
 Print.
 
value (const Values &values, boost::optional< std::vector< Matrix > & > H=boost::none) const
 Return value and optional derivatives, reverse AD version Notes: this is not terribly efficient, and H should have correct size. More...
 
virtual boost::shared_ptr< Expressionclone () const
 
const boost::shared_ptr< internal::ExpressionNode< T > > & root () const
 Return root.
 
size_t traceSize () const
 Return size needed for memory buffer in traceExecution.
 
Expression< T > & operator+= (const Expression< T > &e)
 Add another expression to this expression.
 

Public Types

typedef Expression< T > type
 Define type so we can apply it as a meta-function.
 

Classes

struct  BinaryFunction
 
struct  TernaryFunction
 
struct  UnaryFunction
 

Protected Types

typedef std::pair< KeyVector, FastVector< int > > KeysAndDims
 Keys and dimensions in same order.
 

Protected Member Functions

 Expression (const boost::shared_ptr< internal::ExpressionNode< T > > &root)
 Construct with a custom root.
 
 Expression ()
 Default constructor, for serialization.
 
KeysAndDims keysAndDims () const
 
valueAndDerivatives (const Values &values, const KeyVector &keys, const FastVector< int > &dims, std::vector< Matrix > &H) const
 private version that takes keys and dimensions, returns derivatives
 
traceExecution (const Values &values, internal::ExecutionTrace< T > &trace, void *traceStorage) const
 trace execution, very unsafe
 
valueAndJacobianMap (const Values &values, internal::JacobianMap &jacobians) const
 brief Return value and derivatives, reverse AD version
 

Protected Attributes

boost::shared_ptr< internal::ExpressionNode< T > > root_
 

Friends

class ExpressionFactor< T >
 
class internal::ExpressionNode< T >
 
class ::ExpressionFactorShallowTest
 

Member Function Documentation

◆ clone()

template<typename T>
virtual boost::shared_ptr<Expression> gtsam::Expression< T >::clone ( ) const
inlinevirtual
Returns
a "deep" copy of this Expression "deep" is in quotes because the ExpressionNode hierarchy is not cloned. The intent is for derived classes to be copied using only a Base pointer.

◆ value()

template<typename T >
T gtsam::Expression< T >::value ( const Values values,
boost::optional< std::vector< Matrix > & >  H = boost::none 
) const

Return value and optional derivatives, reverse AD version Notes: this is not terribly efficient, and H should have correct size.

The order of the Jacobians is same as keys in either keys() or dims()


The documentation for this class was generated from the following files: