gtsam
Loading...
Searching...
No Matches
gtsam::GaussianFactor Class Referenceabstract

Detailed Description

An abstract virtual base class for JacobianFactor and HessianFactor.

A GaussianFactor has a quadratic error function. GaussianFactor is non-mutable (all methods const!). The factor value is exp(-0.5*||Ax-b||^2)

Inheritance diagram for gtsam::GaussianFactor:

Advanced Interface

virtual bool isJacobian () const
 Fast check for JacobianFactor-based types.
template<typename CONTAINER>
static DenseIndex Slot (const CONTAINER &keys, Key key)

Public Member Functions

Standard Constructors
 GaussianFactor ()
 Default constructor creates empty factor.
template<typename CONTAINER>
 GaussianFactor (const CONTAINER &keys)
 Construct from container of keys.
Testable
void print (const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override=0
 print with optional string
virtual bool equals (const GaussianFactor &lf, double tol=1e-9) const =0
 assert equality up to a tolerance
Standard Interface
virtual double error (const VectorValues &c) const
virtual double deltaError (const VectorValues &c, double *oldError=nullptr, double *newError=nullptr) const
 Compute the change in error from zero to c.
double error (const HybridValues &c) const override
 All factor types need to implement an error function.
virtual DenseIndex getDim (const_iterator variable) const =0
 Return the dimension of the variable pointed to by the given key iterator.
virtual Matrix augmentedJacobian () const =0
 Return a dense \( [ \;A\;b\; ] \in \mathbb{R}^{m \times n+1} \) Jacobian matrix, augmented with b with the noise models baked into A and b.
virtual std::pair< Matrix, Vector > jacobian () const =0
 Return the dense Jacobian \( A \) and right-hand-side \( b \), with the noise models baked into A and b.
virtual Matrix augmentedInformation () const =0
 Return the augmented information matrix represented by this GaussianFactor.
virtual Matrix information () const =0
 Return the non-augmented information matrix represented by this GaussianFactor.
VectorValues hessianDiagonal () const
 Return the diagonal of the Hessian for this factor.
virtual void hessianDiagonalAdd (VectorValues &d) const =0
 Add the current diagonal to a VectorValues instance.
virtual void hessianDiagonal (double *d) const =0
 Raw memory access version of hessianDiagonal.
virtual std::map< Key, Matrix > hessianBlockDiagonal () const =0
 Return the block diagonal of the Hessian for this factor.
virtual GaussianFactor::shared_ptr clone () const =0
 Clone a factor (make a deep copy).
virtual GaussianFactor::shared_ptr negate () const =0
 Construct the corresponding anti-factor to negate information stored stored in this factor.
virtual void updateHessian (const KeyVector &keys, SymmetricBlockMatrix *info) const =0
 Update an information matrix by adding the information corresponding to this factor (used internally during elimination).
virtual void updateHessian (const KeyVector &keys, SymmetricBlockMatrix *info, DenseIndex beginCol, DenseIndex endCol) const =0
 Update an information matrix by adding the information corresponding to this factor (used internally during elimination), restricted to a range of block columns, useful for parallelization.
Operator interface
virtual void multiplyHessianAdd (double alpha, const VectorValues &x, VectorValues &y) const =0
 y += alpha * A'*A*x
virtual VectorValues gradientAtZero () const =0
 A'*b for Jacobian, eta for Hessian.
virtual void gradientAtZero (double *d) const =0
 Raw memory access version of gradientAtZero.
virtual Vector gradient (Key key, const VectorValues &x) const =0
 Gradient wrt a key at any values.
Public Member Functions inherited from gtsam::Factor
virtual ~Factor ()=default
 Default destructor.
bool empty () const
 Whether the factor is empty (involves zero variables).
Key front () const
 First key.
Key back () const
 Last key.
const_iterator find (Key key) const
 find
const KeyVector & keys () const
 Access the factor's involved variable keys.
const_iterator begin () const
 Iterator at beginning of involved variable keys.
const_iterator end () const
 Iterator at end of involved variable keys.
size_t size () const
virtual void printKeys (const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const
 print only keys
bool equals (const This &other, double tol=1e-9) const
 check equality
KeyVector & keys ()
iterator begin ()
 Iterator at beginning of involved variable keys.
iterator end ()
 Iterator at end of involved variable keys.

Public Types

typedef GaussianFactor This
 This class.
typedef std::shared_ptr< This > shared_ptr
 shared_ptr to this class
typedef Factor Base
 Our base class.
Public Types inherited from gtsam::Factor
typedef KeyVector::iterator iterator
 Iterator over keys.
typedef KeyVector::const_iterator const_iterator
 Const iterator over keys.

Additional Inherited Members

 Factor ()
 Default constructor for I/O.
template<typename CONTAINER>
 Factor (const CONTAINER &keys)
 Construct factor from container of keys.
template<typename ITERATOR>
 Factor (ITERATOR first, ITERATOR last)
 Construct factor from iterator keys.
template<typename CONTAINER>
static Factor FromKeys (const CONTAINER &keys)
 Construct factor from container of keys.
template<typename ITERATOR>
static Factor FromIterators (ITERATOR first, ITERATOR last)
 Construct factor from iterator keys.
Protected Attributes inherited from gtsam::Factor
KeyVector keys_
 The keys involved in this factor.

Constructor & Destructor Documentation

◆ GaussianFactor()

template<typename CONTAINER>
gtsam::GaussianFactor::GaussianFactor ( const CONTAINER & keys)
inline

Construct from container of keys.

This constructor is used internally from derived factor constructors, either from a container of keys or from a boost::assign::list_of.

Member Function Documentation

◆ augmentedInformation()

virtual Matrix gtsam::GaussianFactor::augmentedInformation ( ) const
pure virtual

Return the augmented information matrix represented by this GaussianFactor.

The augmented information matrix contains the information matrix with an additional column holding the information vector, and an additional row holding the transpose of the information vector. The lower-right entry contains the constant error term (when \( \delta x = 0 \)). The augmented information matrix is described in more detail in HessianFactor, which in fact stores an augmented information matrix.

Implemented in gtsam::BatchJacobianFactorBase, gtsam::HessianFactor, gtsam::JacobianFactor, and gtsam::RegularImplicitSchurFactor< CAMERA >.

◆ augmentedJacobian()

virtual Matrix gtsam::GaussianFactor::augmentedJacobian ( ) const
pure virtual

Return a dense \( [ \;A\;b\; ] \in \mathbb{R}^{m \times n+1} \) Jacobian matrix, augmented with b with the noise models baked into A and b.

The negative log-likelihood is \( \frac{1}{2} \Vert Ax-b \Vert^2 \). See also GaussianFactorGraph::jacobian and GaussianFactorGraph::sparseJacobian.

Implemented in gtsam::BatchJacobianFactorBase, gtsam::HessianFactor, gtsam::JacobianFactor, and gtsam::RegularImplicitSchurFactor< CAMERA >.

◆ clone()

◆ deltaError()

double GaussianFactor::deltaError ( const VectorValues & c,
double * oldError = nullptr,
double * newError = nullptr ) const
virtual

Compute the change in error from zero to c.

Optionally return the old and new errors for reuse by callers.

Reimplemented in gtsam::BatchJacobianFactor< ErrorDim, BlockDims >, gtsam::BatchJacobianFactor< ErrorDim, BlockDims... >, gtsam::BatchJacobianFactorBase, gtsam::FixedJacobianFactor< M, Ns >, gtsam::HessianFactor, and gtsam::JacobianFactor.

◆ equals()

virtual bool gtsam::GaussianFactor::equals ( const GaussianFactor & lf,
double tol = 1e-9 ) const
pure virtual

◆ error() [1/2]

double GaussianFactor::error ( const HybridValues & hybridValues) const
overridevirtual

All factor types need to implement an error function.

In factor graphs, this is the negative log-likelihood.

Reimplemented from gtsam::Factor.

Reimplemented in gtsam::HessianFactor, and gtsam::JacobianFactor.

◆ error() [2/2]

double GaussianFactor::error ( const VectorValues & c) const
virtual

◆ getDim()

virtual DenseIndex gtsam::GaussianFactor::getDim ( const_iterator variable) const
pure virtual

◆ gradient()

virtual Vector gtsam::GaussianFactor::gradient ( Key key,
const VectorValues & x ) const
pure virtual

◆ gradientAtZero() [1/2]

virtual VectorValues gtsam::GaussianFactor::gradientAtZero ( ) const
pure virtual

◆ gradientAtZero() [2/2]

virtual void gtsam::GaussianFactor::gradientAtZero ( double * d) const
pure virtual

◆ hessianBlockDiagonal()

virtual std::map< Key, Matrix > gtsam::GaussianFactor::hessianBlockDiagonal ( ) const
pure virtual

Return the block diagonal of the Hessian for this factor.

Implemented in gtsam::BatchJacobianFactorBase, gtsam::HessianFactor, gtsam::JacobianFactor, and gtsam::RegularImplicitSchurFactor< CAMERA >.

◆ hessianDiagonal()

virtual void gtsam::GaussianFactor::hessianDiagonal ( double * d) const
pure virtual

◆ hessianDiagonalAdd()

◆ information()

virtual Matrix gtsam::GaussianFactor::information ( ) const
pure virtual

Return the non-augmented information matrix represented by this GaussianFactor.

Implemented in gtsam::BatchJacobianFactorBase, gtsam::HessianFactor, gtsam::JacobianFactor, and gtsam::RegularImplicitSchurFactor< CAMERA >.

◆ isJacobian()

virtual bool gtsam::GaussianFactor::isJacobian ( ) const
inlinevirtual

Fast check for JacobianFactor-based types.

Reimplemented in gtsam::JacobianFactor.

◆ jacobian()

virtual std::pair< Matrix, Vector > gtsam::GaussianFactor::jacobian ( ) const
pure virtual

Return the dense Jacobian \( A \) and right-hand-side \( b \), with the noise models baked into A and b.

The negative log-likelihood is \( \frac{1}{2} \Vert Ax-b \Vert^2 \). See also GaussianFactorGraph::augmentedJacobian and GaussianFactorGraph::sparseJacobian.

Implemented in gtsam::BatchJacobianFactorBase, gtsam::HessianFactor, gtsam::JacobianFactor, and gtsam::RegularImplicitSchurFactor< CAMERA >.

◆ multiplyHessianAdd()

virtual void gtsam::GaussianFactor::multiplyHessianAdd ( double alpha,
const VectorValues & x,
VectorValues & y ) const
pure virtual

◆ negate()

virtual GaussianFactor::shared_ptr gtsam::GaussianFactor::negate ( ) const
pure virtual

Construct the corresponding anti-factor to negate information stored stored in this factor.

Returns
a HessianFactor with negated Hessian matrices

Implemented in gtsam::BatchJacobianFactorBase, gtsam::HessianFactor, gtsam::JacobianFactor, and gtsam::RegularImplicitSchurFactor< CAMERA >.

◆ print()

void gtsam::GaussianFactor::print ( const std::string & s = "",
const KeyFormatter & formatter = DefaultKeyFormatter ) const
overridepure virtual

◆ updateHessian() [1/2]

virtual void gtsam::GaussianFactor::updateHessian ( const KeyVector & keys,
SymmetricBlockMatrix * info ) const
pure virtual

Update an information matrix by adding the information corresponding to this factor (used internally during elimination).

Parameters
scatterA mapping from variable index to slot index in this HessianFactor
infoThe information matrix to be updated

Implemented in gtsam::BatchJacobianFactor< ErrorDim, BlockDims >, gtsam::BatchJacobianFactor< ErrorDim, BlockDims... >, gtsam::BatchJacobianFactorBase, gtsam::FixedJacobianFactor< M, Ns >, gtsam::HessianFactor, gtsam::JacobianFactor, and gtsam::RegularImplicitSchurFactor< CAMERA >.

◆ updateHessian() [2/2]

virtual void gtsam::GaussianFactor::updateHessian ( const KeyVector & keys,
SymmetricBlockMatrix * info,
DenseIndex beginCol,
DenseIndex endCol ) const
pure virtual

Update an information matrix by adding the information corresponding to this factor (used internally during elimination), restricted to a range of block columns, useful for parallelization.

Parameters
keysThe ordered vector of keys for the information matrix to be updated
infoThe information matrix to be updated
beginColFirst block column index (inclusive) in the range to update
endColLast block column index (exclusive) in the range to update

Implemented in gtsam::BatchJacobianFactor< ErrorDim, BlockDims >, gtsam::BatchJacobianFactor< ErrorDim, BlockDims... >, gtsam::BatchJacobianFactorBase, gtsam::FixedJacobianFactor< M, Ns >, gtsam::HessianFactor, gtsam::JacobianFactor, and gtsam::RegularImplicitSchurFactor< CAMERA >.


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