GTSAM  4.0.2
C++ library for smoothing and mapping (SAM)
Public Types | Public Member Functions | Protected Attributes | List of all members
gtsam::RegularHessianFactor< D > Class Template Reference
Inheritance diagram for gtsam::RegularHessianFactor< D >:
Inheritance graph
[legend]
Collaboration diagram for gtsam::RegularHessianFactor< D >:
Collaboration graph
[legend]

Public Types

typedef Eigen::Matrix< double, D, 1 > VectorD
 
typedef Eigen::Matrix< double, D, D > MatrixD
 
typedef GaussianFactor Base
 Typedef to base class.
 
typedef HessianFactor This
 Typedef to this class.
 
typedef std::shared_ptr< Thisshared_ptr
 A shared_ptr to this class.
 
typedef SymmetricBlockMatrix::Block Block
 A block from the Hessian matrix.
 
typedef SymmetricBlockMatrix::constBlock constBlock
 A block from the Hessian matrix (const version)
 
typedef KeyVector::iterator iterator
 Iterator over keys.
 
typedef KeyVector::const_iterator const_iterator
 Const iterator over keys.
 

Public Member Functions

 RegularHessianFactor (const KeyVector &js, const std::vector< Matrix > &Gs, const std::vector< Vector > &gs, double f)
 
 RegularHessianFactor (Key j1, Key j2, const MatrixD &G11, const MatrixD &G12, const VectorD &g1, const MatrixD &G22, const VectorD &g2, double f)
 
 RegularHessianFactor (Key j1, Key j2, Key j3, const MatrixD &G11, const MatrixD &G12, const MatrixD &G13, const VectorD &g1, const MatrixD &G22, const MatrixD &G23, const VectorD &g2, const MatrixD &G33, const VectorD &g3, double f)
 
template<typename KEYS >
 RegularHessianFactor (const KEYS &keys, const SymmetricBlockMatrix &augmentedInformation)
 
 RegularHessianFactor (const RegularJacobianFactor< D > &jf)
 Construct from RegularJacobianFactor.
 
 RegularHessianFactor (const GaussianFactorGraph &factors, const Scatter &scatter)
 Construct from a GaussianFactorGraph.
 
 RegularHessianFactor (const GaussianFactorGraph &factors)
 Construct from a GaussianFactorGraph.
 
void multiplyHessianAdd (double alpha, const VectorValues &x, VectorValues &y) const override
 
void multiplyHessianAdd (double alpha, const double *x, double *yvalues) const
 
void multiplyHessianAdd (double alpha, const double *x, double *yvalues, std::vector< size_t > offsets) const
 Raw memory version, with offsets TODO document reasoning.
 
void hessianDiagonal (double *d) const override
 
void gradientAtZero (double *d) const override
 Add gradient at zero to d TODO: is it really the goal to add ??
 
GaussianFactor::shared_ptr clone () const override
 
void print (const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override
 
bool equals (const GaussianFactor &lf, double tol=1e-9) const override
 
double error (const VectorValues &c) const override
 
DenseIndex getDim (const_iterator variable) const override
 
size_t rows () const
 
GaussianFactor::shared_ptr negate () const override
 
double constantTerm () const
 
double & constantTerm ()
 
SymmetricBlockMatrix::constBlock linearTerm (const_iterator j) const
 
SymmetricBlockMatrix::constBlock linearTerm () const
 
SymmetricBlockMatrix::Block linearTerm ()
 
const SymmetricBlockMatrixinfo () const
 Return underlying information matrix.
 
SymmetricBlockMatrixinfo ()
 
Matrix augmentedInformation () const override
 
Eigen::SelfAdjointView< SymmetricBlockMatrix::constBlock, Eigen::Upper > informationView () const
 Return self-adjoint view onto the information matrix (NOT augmented).
 
Matrix information () const override
 
void hessianDiagonalAdd (VectorValues &d) const override
 Add the current diagonal to a VectorValues instance.
 
std::map< Key, Matrix > hessianBlockDiagonal () const override
 Return the block diagonal of the Hessian for this factor.
 
std::pair< Matrix, Vector > jacobian () const override
 Return (dense) matrix associated with factor.
 
Matrix augmentedJacobian () const override
 
void updateHessian (const KeyVector &keys, SymmetricBlockMatrix *info) const override
 
void updateHessian (HessianFactor *other) const
 
VectorValues gradientAtZero () const override
 eta for Hessian
 
Vector gradient (Key key, const VectorValues &x) const override
 
std::shared_ptr< GaussianConditionaleliminateCholesky (const Ordering &keys)
 
VectorValues solve ()
 Solve the system A'*A delta = A'*b in-place, return delta as VectorValues.
 
Testable
bool equals (const This &other, double tol=1e-9) const
 check equality
 
virtual void printKeys (const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const
 print only keys
 
Standard Interface
double error (const HybridValues &c) const override
 
VectorValues hessianDiagonal () const
 Return the diagonal of the Hessian for this factor.
 
Standard Interface
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 KeyVectorkeys () const
 Access the factor's involved variable keys.
 
const_iterator begin () const
 
const_iterator end () const
 
size_t size () const
 
Advanced Interface
KeyVectorkeys ()
 
iterator begin ()
 
iterator end ()
 

Static Public Member Functions

Advanced Interface
template<typename CONTAINER >
static DenseIndex Slot (const CONTAINER &keys, Key key)
 

Static Protected Member Functions

Standard Constructors
template<typename CONTAINER >
static Factor FromKeys (const CONTAINER &keys)
 
template<typename ITERATOR >
static Factor FromIterators (ITERATOR first, ITERATOR last)
 

Protected Attributes

SymmetricBlockMatrix info_
 The full augmented information matrix, s.t. the quadratic error is 0.5*[x -1]'H[x -1].
 
KeyVector keys_
 The keys involved in this factor.
 

Constructor & Destructor Documentation

◆ RegularHessianFactor() [1/4]

template<size_t D>
gtsam::RegularHessianFactor< D >::RegularHessianFactor ( const KeyVector js,
const std::vector< Matrix > &  Gs,
const std::vector< Vector > &  gs,
double  f 
)
inline

Construct an n-way factor. Gs contains the upper-triangle blocks of the quadratic term (the Hessian matrix) provided in row-order, gs the pieces of the linear vector term, and f the constant term.

◆ RegularHessianFactor() [2/4]

template<size_t D>
gtsam::RegularHessianFactor< D >::RegularHessianFactor ( Key  j1,
Key  j2,
const MatrixD &  G11,
const MatrixD &  G12,
const VectorD &  g1,
const MatrixD &  G22,
const VectorD &  g2,
double  f 
)
inline

Construct a binary factor. Gxx are the upper-triangle blocks of the quadratic term (the Hessian matrix), gx the pieces of the linear vector term, and f the constant term.

◆ RegularHessianFactor() [3/4]

template<size_t D>
gtsam::RegularHessianFactor< D >::RegularHessianFactor ( Key  j1,
Key  j2,
Key  j3,
const MatrixD &  G11,
const MatrixD &  G12,
const MatrixD &  G13,
const VectorD &  g1,
const MatrixD &  G22,
const MatrixD &  G23,
const VectorD &  g2,
const MatrixD &  G33,
const VectorD &  g3,
double  f 
)
inline

Construct a ternary factor. Gxx are the upper-triangle blocks of the quadratic term (the Hessian matrix), gx the pieces of the linear vector term, and f the constant term.

◆ RegularHessianFactor() [4/4]

template<size_t D>
template<typename KEYS >
gtsam::RegularHessianFactor< D >::RegularHessianFactor ( const KEYS &  keys,
const SymmetricBlockMatrix augmentedInformation 
)
inline

Constructor with an arbitrary number of keys and with the augmented information matrix specified as a block matrix.

Member Function Documentation

◆ augmentedInformation()

Matrix gtsam::HessianFactor::augmentedInformation ( ) const
overridevirtualinherited

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.

For HessianFactor, this is the same as info() except that this function returns a complete symmetric matrix whereas info() returns a matrix where only the upper triangle is valid, but should be interpreted as symmetric. This is because info() returns only a reference to the internal representation of the augmented information matrix, which stores only the upper triangle.

Implements gtsam::GaussianFactor.

◆ augmentedJacobian()

Matrix gtsam::HessianFactor::augmentedJacobian ( ) const
overridevirtualinherited

Return (dense) matrix associated with factor The returned system is an augmented matrix: [A b]

Parameters
setweight to use whitening to bake in weights

Implements gtsam::GaussianFactor.

◆ begin() [1/2]

const_iterator gtsam::Factor::begin ( ) const
inlineinherited

Iterator at beginning of involved variable keys

◆ begin() [2/2]

iterator gtsam::Factor::begin ( )
inlineinherited

Iterator at beginning of involved variable keys

◆ clone()

GaussianFactor::shared_ptr gtsam::HessianFactor::clone ( ) const
inlineoverridevirtualinherited

Clone this HessianFactor

Implements gtsam::GaussianFactor.

◆ constantTerm() [1/2]

double gtsam::HessianFactor::constantTerm ( ) const
inlineinherited

Return the constant term \( f \) as described above

Returns
The constant term \( f \)

◆ constantTerm() [2/2]

double& gtsam::HessianFactor::constantTerm ( )
inlineinherited

Return the constant term \( f \) as described above

Returns
The constant term \( f \)

◆ eliminateCholesky()

std::shared_ptr<GaussianConditional> gtsam::HessianFactor::eliminateCholesky ( const Ordering keys)
inherited

In-place elimination that returns a conditional on (ordered) keys specified, and leaves this factor to be on the remaining keys (separator) only. Does dense partial Cholesky.

◆ end() [1/2]

const_iterator gtsam::Factor::end ( ) const
inlineinherited

Iterator at end of involved variable keys

◆ end() [2/2]

iterator gtsam::Factor::end ( )
inlineinherited

Iterator at end of involved variable keys

◆ equals()

bool gtsam::HessianFactor::equals ( const GaussianFactor lf,
double  tol = 1e-9 
) const
overridevirtualinherited

Compare to another factor for testing (implementing Testable)

Implements gtsam::GaussianFactor.

◆ error() [1/2]

double gtsam::GaussianFactor::error ( const HybridValues c) const
overridevirtualinherited

All factor types need to implement an error function. In factor graphs, this is the negative log-likelihood.

Reimplemented from gtsam::Factor.

◆ error() [2/2]

double gtsam::HessianFactor::error ( const VectorValues c) const
overridevirtualinherited

Evaluate the factor error f(x). returns 0.5*[x -1]'H[x -1] (also see constructor documentation)

Reimplemented from gtsam::GaussianFactor.

◆ FromIterators()

template<typename ITERATOR >
static Factor gtsam::Factor::FromIterators ( ITERATOR  first,
ITERATOR  last 
)
inlinestaticprotectedinherited

Construct factor from iterator keys. This is called internally from derived factor static factor methods, as a workaround for not being able to call the protected constructors above.

◆ FromKeys()

template<typename CONTAINER >
static Factor gtsam::Factor::FromKeys ( const CONTAINER &  keys)
inlinestaticprotectedinherited

Construct factor from container of keys. This is called internally from derived factor static factor methods, as a workaround for not being able to call the protected constructors above.

◆ getDim()

DenseIndex gtsam::HessianFactor::getDim ( const_iterator  variable) const
inlineoverridevirtualinherited

Return the dimension of the variable pointed to by the given key iterator todo: Remove this in favor of keeping track of dimensions with variables?

Parameters
variableAn iterator pointing to the slot in this factor. You can use, for example, begin() + 2 to get the 3rd variable in this factor.

Implements gtsam::GaussianFactor.

◆ gradient()

Vector gtsam::HessianFactor::gradient ( Key  key,
const VectorValues x 
) const
overridevirtualinherited

Compute the gradient at a key: \( \grad f(x_i) = \sum_j G_ij*x_j - g_i \)

Implements gtsam::GaussianFactor.

◆ hessianDiagonal()

template<size_t D>
void gtsam::RegularHessianFactor< D >::hessianDiagonal ( double *  d) const
inlineoverridevirtual

Return the diagonal of the Hessian for this factor (raw memory version)

Reimplemented from gtsam::HessianFactor.

◆ info()

SymmetricBlockMatrix& gtsam::HessianFactor::info ( )
inlineinherited

Return non-const information matrix. TODO(gareth): Review the sanity of having non-const access to this.

◆ information()

Matrix gtsam::HessianFactor::information ( ) const
overridevirtualinherited

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

Implements gtsam::GaussianFactor.

◆ keys()

KeyVector& gtsam::Factor::keys ( )
inlineinherited
Returns
keys involved in this factor

◆ linearTerm() [1/3]

SymmetricBlockMatrix::constBlock gtsam::HessianFactor::linearTerm ( const_iterator  j) const
inlineinherited

Return the part of linear term \( g \) as described above corresponding to the requested variable.

Parameters
jWhich block row to get, as an iterator pointing to the slot in this factor. You can use, for example, begin() + 2 to get the 3rd variable in this factor.
Returns
The linear term \( g \)

◆ linearTerm() [2/3]

SymmetricBlockMatrix::constBlock gtsam::HessianFactor::linearTerm ( ) const
inlineinherited

Return the complete linear term \( g \) as described above.

Returns
The linear term \( g \)

◆ linearTerm() [3/3]

SymmetricBlockMatrix::Block gtsam::HessianFactor::linearTerm ( )
inlineinherited

Return the complete linear term \( g \) as described above.

Returns
The linear term \( g \)

◆ multiplyHessianAdd() [1/2]

template<size_t D>
void gtsam::RegularHessianFactor< D >::multiplyHessianAdd ( double  alpha,
const VectorValues x,
VectorValues y 
) const
inlineoverridevirtual

y += alpha * A'*A*x

Reimplemented from gtsam::HessianFactor.

◆ multiplyHessianAdd() [2/2]

template<size_t D>
void gtsam::RegularHessianFactor< D >::multiplyHessianAdd ( double  alpha,
const double *  x,
double *  yvalues 
) const
inline

y += alpha * A'*A*x

◆ negate()

GaussianFactor::shared_ptr gtsam::HessianFactor::negate ( ) const
overridevirtualinherited

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

Returns
a HessianFactor with negated Hessian matrices

Implements gtsam::GaussianFactor.

◆ print()

void gtsam::HessianFactor::print ( const std::string &  s = "",
const KeyFormatter formatter = DefaultKeyFormatter 
) const
overridevirtualinherited

Print the factor for debugging and testing (implementing Testable)

Implements gtsam::GaussianFactor.

◆ rows()

size_t gtsam::HessianFactor::rows ( ) const
inlineinherited

Return the number of columns and rows of the Hessian matrix, including the information vector.

◆ size()

size_t gtsam::Factor::size ( ) const
inlineinherited
Returns
the number of variables involved in this factor

◆ updateHessian() [1/2]

void gtsam::HessianFactor::updateHessian ( const KeyVector keys,
SymmetricBlockMatrix info 
) const
overridevirtualinherited

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

Parameters
keysTHe ordered vector of keys for the information matrix to be updated
infoThe information matrix to be updated

Implements gtsam::GaussianFactor.

◆ updateHessian() [2/2]

void gtsam::HessianFactor::updateHessian ( HessianFactor other) const
inlineinherited

Update another Hessian factor

Parameters
otherthe HessianFactor to be updated

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