Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Types | Private Member Functions | List of all members
gtsam::ExpressionFactor< T > Class Template Reference

#include <Expression.h>

Inheritance diagram for gtsam::ExpressionFactor< T >:
Inheritance graph
[legend]

Public Types

typedef std::shared_ptr< ExpressionFactor< T > > shared_ptr
 

Public Member Functions

gtsam::NonlinearFactor::shared_ptr clone () const override
 
bool equals (const NonlinearFactor &f, double tol) const override
 equals relies on Testable traits being defined for T More...
 
 ExpressionFactor (const SharedNoiseModel &noiseModel, const T &measurement, const Expression< T > &expression)
 
std::shared_ptr< GaussianFactorlinearize (const Values &x) const override
 
const Tmeasured () const
 
void print (const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
 print relies on Testable traits being defined for T More...
 
Vector unwhitenedError (const Values &x, OptionalMatrixVecType H=nullptr) const override
 
virtual Vector unwhitenedError (const Values &x, OptionalMatrixVecType H=nullptr) const=0
 
Vector unwhitenedError (const Values &x, std::vector< Matrix > &H) const
 
 ~ExpressionFactor () override
 Destructor. More...
 

Protected Types

typedef ExpressionFactor< TThis
 

Protected Member Functions

virtual Expression< Texpression () const
 
 ExpressionFactor ()
 
 ExpressionFactor (const SharedNoiseModel &noiseModel, const T &measurement)
 Default constructor, for serialization. More...
 
void initialize (const Expression< T > &expression)
 Initialize with constructor arguments. More...
 

Protected Attributes

FastVector< intdims_
 dimensions of the Jacobian matrices More...
 
Expression< Texpression_
 the expression that is AD enabled More...
 
T measured_
 the measurement to be compared with the expression More...
 

Static Protected Attributes

static const int Dim = traits<T>::dimension
 

Private Types

enum  { NeedsToAlign = (sizeof(T) % 16) == 0 }
 

Private Member Functions

 GTSAM_CONCEPT_ASSERT (IsTestable< T >)
 

Detailed Description

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

Factor that supports arbitrary expressions via AD.

Arbitrary instances of this template can be directly inserted into a factor graph for optimization. However, to enable the correct (de)serialization of such instances, the user should declare derived classes from this template, implementing expresion(), serialize(), clone(), print(), and defining the corresponding struct traits<NewFactor> : public Testable<NewFactor> {}.

Template Parameters
TType for measurements.

Definition at line 36 of file Expression.h.

Member Typedef Documentation

◆ shared_ptr

template<typename T >
typedef std::shared_ptr<ExpressionFactor<T> > gtsam::ExpressionFactor< T >::shared_ptr

Definition at line 63 of file ExpressionFactor.h.

◆ This

template<typename T >
typedef ExpressionFactor<T> gtsam::ExpressionFactor< T >::This
protected

Definition at line 51 of file ExpressionFactor.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename T >
anonymous enum
private
Enumerator
NeedsToAlign 

Definition at line 227 of file ExpressionFactor.h.

Constructor & Destructor Documentation

◆ ExpressionFactor() [1/3]

template<typename T >
gtsam::ExpressionFactor< T >::ExpressionFactor ( const SharedNoiseModel noiseModel,
const T measurement,
const Expression< T > &  expression 
)
inline

Constructor: creates a factor from a measurement and measurement function

Parameters
noiseModelthe noise model associated with a measurement
measurementactual value of the measurement, of type T
expressionpredicts the measurement from Values The keys associated with the factor, returned by keys(), are sorted.

Definition at line 72 of file ExpressionFactor.h.

◆ ~ExpressionFactor()

template<typename T >
gtsam::ExpressionFactor< T >::~ExpressionFactor ( )
inlineoverride

Destructor.

Definition at line 79 of file ExpressionFactor.h.

◆ ExpressionFactor() [2/3]

template<typename T >
gtsam::ExpressionFactor< T >::ExpressionFactor ( )
inlineprotected

Definition at line 162 of file ExpressionFactor.h.

◆ ExpressionFactor() [3/3]

template<typename T >
gtsam::ExpressionFactor< T >::ExpressionFactor ( const SharedNoiseModel noiseModel,
const T measurement 
)
inlineprotected

Default constructor, for serialization.

Constructor for serializable derived classes

Definition at line 166 of file ExpressionFactor.h.

Member Function Documentation

◆ clone()

template<typename T >
gtsam::NonlinearFactor::shared_ptr gtsam::ExpressionFactor< T >::clone ( ) const
inlineoverride
Returns
a deep copy of this factor

Definition at line 156 of file ExpressionFactor.h.

◆ equals()

template<typename T >
bool gtsam::ExpressionFactor< T >::equals ( const NonlinearFactor f,
double  tol 
) const
inlineoverride

equals relies on Testable traits being defined for T

Definition at line 92 of file ExpressionFactor.h.

◆ expression()

template<typename T >
virtual Expression<T> gtsam::ExpressionFactor< T >::expression ( ) const
inlineprotectedvirtual

◆ GTSAM_CONCEPT_ASSERT()

template<typename T >
gtsam::ExpressionFactor< T >::GTSAM_CONCEPT_ASSERT ( IsTestable< T )
private

◆ initialize()

template<typename T >
void gtsam::ExpressionFactor< T >::initialize ( const Expression< T > &  expression)
inlineprotected

Initialize with constructor arguments.

Definition at line 172 of file ExpressionFactor.h.

◆ linearize()

template<typename T >
std::shared_ptr<GaussianFactor> gtsam::ExpressionFactor< T >::linearize ( const Values x) const
inlineoverride

Definition at line 117 of file ExpressionFactor.h.

◆ measured()

template<typename T >
const T& gtsam::ExpressionFactor< T >::measured ( ) const
inline

return the measurement

Definition at line 82 of file ExpressionFactor.h.

◆ print()

template<typename T >
void gtsam::ExpressionFactor< T >::print ( const std::string &  s = "",
const KeyFormatter keyFormatter = DefaultKeyFormatter 
) const
inlineoverride

print relies on Testable traits being defined for T

Definition at line 85 of file ExpressionFactor.h.

◆ unwhitenedError() [1/3]

template<typename T >
Vector gtsam::ExpressionFactor< T >::unwhitenedError ( const Values x,
OptionalMatrixVecType  H = nullptr 
) const
inlineoverride

Error function without the NoiseModel, $ z-h(x) -> Local(h(x),z) $. We override this method to provide both the function evaluation and its derivative(s) in H.

Definition at line 104 of file ExpressionFactor.h.

◆ unwhitenedError() [2/3]

template<typename T >
virtual Vector gtsam::NoiseModelFactor::unwhitenedError

Error function without the NoiseModel, $ z-h(x) $. Override this method to finish implementing an N-way factor. If the optional arguments is specified, it should compute both the function evaluation and its derivative(s) in H.

◆ unwhitenedError() [3/3]

template<typename T >
Vector gtsam::NoiseModelFactor::unwhitenedError
inline

support taking in the actual vector instead of the pointer as well to get access to this version of the function from derived classes one will need to use the "using" keyword and specify that like this: public: using NoiseModelFactor::unwhitenedError;

Definition at line 263 of file NonlinearFactor.h.

Member Data Documentation

◆ Dim

template<typename T >
const int gtsam::ExpressionFactor< T >::Dim = traits<T>::dimension
staticprotected

Definition at line 52 of file ExpressionFactor.h.

◆ dims_

template<typename T >
FastVector<int> gtsam::ExpressionFactor< T >::dims_
protected

dimensions of the Jacobian matrices

Definition at line 56 of file ExpressionFactor.h.

◆ expression_

template<typename T >
Expression<T> gtsam::ExpressionFactor< T >::expression_
protected

the expression that is AD enabled

Definition at line 55 of file ExpressionFactor.h.

◆ measured_

template<typename T >
T gtsam::ExpressionFactor< T >::measured_
protected

the measurement to be compared with the expression

Definition at line 54 of file ExpressionFactor.h.


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


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:15:23