gtsam 4.1.1
gtsam
gtsam::GaussianDensity Class Reference

Detailed Description

A Gaussian density.

It is implemented as a GaussianConditional without parents. The negative log-probability is given by \( |Rx - d|^2 \) with \( \Lambda = \Sigma^{-1} = R^T R \) and \( \mu = R^{-1} d \)

+ Inheritance diagram for gtsam::GaussianDensity:

Public Member Functions

 GaussianDensity ()
 default constructor needed for serialization
 
 GaussianDensity (const GaussianConditional &conditional)
 Copy constructor from GaussianConditional.
 
 GaussianDensity (Key key, const Vector &d, const Matrix &R, const SharedDiagonal &noiseModel=SharedDiagonal())
 constructor using d, R
 
void print (const std::string &="GaussianDensity", const KeyFormatter &formatter=DefaultKeyFormatter) const override
 print More...
 
Vector mean () const
 Mean \( \mu = R^{-1} d \).
 
Matrix covariance () const
 Covariance matrix \( \Sigma = (R^T R)^{-1} \).
 
- Public Member Functions inherited from gtsam::GaussianConditional
 GaussianConditional ()
 default constructor needed for serialization
 
 GaussianConditional (Key key, const Vector &d, const Matrix &R, const SharedDiagonal &sigmas=SharedDiagonal())
 constructor with no parents |Rx-d|
 
 GaussianConditional (Key key, const Vector &d, const Matrix &R, Key name1, const Matrix &S, const SharedDiagonal &sigmas=SharedDiagonal())
 constructor with only one parent |Rx+Sy-d|
 
 GaussianConditional (Key key, const Vector &d, const Matrix &R, Key name1, const Matrix &S, Key name2, const Matrix &T, const SharedDiagonal &sigmas=SharedDiagonal())
 constructor with two parents |Rx+Sy+Tz-d|
 
template<typename TERMS >
 GaussianConditional (const TERMS &terms, size_t nrFrontals, const Vector &d, const SharedDiagonal &sigmas=SharedDiagonal())
 Constructor with arbitrary number of frontals and parents. More...
 
template<typename KEYS >
 GaussianConditional (const KEYS &keys, size_t nrFrontals, const VerticalBlockMatrix &augmentedMatrix, const SharedDiagonal &sigmas=SharedDiagonal())
 Constructor with arbitrary number keys, and where the augmented matrix is given all together instead of in block terms. More...
 
void print (const std::string &="GaussianConditional", const KeyFormatter &formatter=DefaultKeyFormatter) const override
 print More...
 
bool equals (const GaussianFactor &cg, double tol=1e-9) const override
 equals function More...
 
constABlock R () const
 Return a view of the upper-triangular R block of the conditional.
 
constABlock S () const
 Get a view of the parent blocks.
 
constABlock S (const_iterator it) const
 Get a view of the S matrix for the variable pointed to by the given key iterator.
 
const constBVector d () const
 Get a view of the r.h.s. More...
 
VectorValues solve (const VectorValues &parents) const
 Solves a conditional Gaussian and writes the solution into the entries of x for each frontal variable of the conditional. More...
 
VectorValues solveOtherRHS (const VectorValues &parents, const VectorValues &rhs) const
 
void solveTransposeInPlace (VectorValues &gy) const
 Performs transpose backsubstition in place on values.
 
void scaleFrontalsBySigma (VectorValues &gy) const
 Scale the values in gy according to the sigmas for the frontal variables in this conditional.
 
- Public Member Functions inherited from gtsam::JacobianFactor
 JacobianFactor (const GaussianFactor &gf)
 Convert from other GaussianFactor.
 
 JacobianFactor (const JacobianFactor &jf)
 Copy constructor.
 
 JacobianFactor (const HessianFactor &hf)
 Conversion from HessianFactor (does Cholesky to obtain Jacobian matrix)
 
 JacobianFactor ()
 default constructor for I/O
 
 JacobianFactor (const Vector &b_in)
 Construct Null factor.
 
 JacobianFactor (Key i1, const Matrix &A1, const Vector &b, const SharedDiagonal &model=SharedDiagonal())
 Construct unary factor.
 
 JacobianFactor (Key i1, const Matrix &A1, Key i2, const Matrix &A2, const Vector &b, const SharedDiagonal &model=SharedDiagonal())
 Construct binary factor.
 
 JacobianFactor (Key i1, const Matrix &A1, Key i2, const Matrix &A2, Key i3, const Matrix &A3, const Vector &b, const SharedDiagonal &model=SharedDiagonal())
 Construct ternary factor.
 
template<typename TERMS >
 JacobianFactor (const TERMS &terms, const Vector &b, const SharedDiagonal &model=SharedDiagonal())
 Construct an n-ary factor. More...
 
template<typename KEYS >
 JacobianFactor (const KEYS &keys, const VerticalBlockMatrix &augmentedMatrix, const SharedDiagonal &sigmas=SharedDiagonal())
 Constructor with arbitrary number keys, and where the augmented matrix is given all together instead of in block terms. More...
 
 JacobianFactor (const GaussianFactorGraph &graph)
 Build a dense joint factor from all the factors in a factor graph. More...
 
 JacobianFactor (const GaussianFactorGraph &graph, const VariableSlots &p_variableSlots)
 Build a dense joint factor from all the factors in a factor graph. More...
 
 JacobianFactor (const GaussianFactorGraph &graph, const Ordering &ordering)
 Build a dense joint factor from all the factors in a factor graph. More...
 
 JacobianFactor (const GaussianFactorGraph &graph, const Ordering &ordering, const VariableSlots &p_variableSlots)
 Build a dense joint factor from all the factors in a factor graph. More...
 
 ~JacobianFactor () override
 Virtual destructor.
 
GaussianFactor::shared_ptr clone () const override
 Clone this JacobianFactor. More...
 
void print (const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override
 print More...
 
bool equals (const GaussianFactor &lf, double tol=1e-9) const override
 Equals for testable. More...
 
Vector unweighted_error (const VectorValues &c) const
 
Vector error_vector (const VectorValues &c) const
 (A*x-b)
 
double error (const VectorValues &c) const override
 (A*x-b)/sigma More...
 
Matrix augmentedInformation () const override
 0.5*(A*x-b)'D(A*x-b) More...
 
Matrix information () const override
 Return the non-augmented information matrix represented by this GaussianFactor. More...
 
void hessianDiagonalAdd (VectorValues &d) const override
 Add the current diagonal to a VectorValues instance. More...
 
void hessianDiagonal (double *d) const override
 Raw memory access version of hessianDiagonal. More...
 
std::map< Key, Matrix > hessianBlockDiagonal () const override
 Return the block diagonal of the Hessian for this factor. More...
 
std::pair< Matrix, Vector > jacobian () const override
 Returns (dense) A,b pair associated with factor, bakes in the weights. More...
 
std::pair< Matrix, Vector > jacobianUnweighted () const
 Returns (dense) A,b pair associated with factor, does not bake in weights.
 
Matrix augmentedJacobian () const override
 Return (dense) matrix associated with factor. More...
 
Matrix augmentedJacobianUnweighted () const
 Return (dense) matrix associated with factor. More...
 
const VerticalBlockMatrixmatrixObject () const
 Return the full augmented Jacobian matrix of this factor as a VerticalBlockMatrix object.
 
VerticalBlockMatrixmatrixObject ()
 Mutable access to the full augmented Jacobian matrix of this factor as a VerticalBlockMatrix object.
 
GaussianFactor::shared_ptr negate () const override
 Construct the corresponding anti-factor to negate information stored stored in this factor. More...
 
bool empty () const override
 Check if the factor is empty. More...
 
bool isConstrained () const
 is noise model constrained ?
 
DenseIndex getDim (const_iterator variable) const override
 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? More...
 
size_t rows () const
 return the number of rows in the corresponding linear system
 
size_t cols () const
 return the number of columns in the corresponding linear system
 
const SharedDiagonal & get_model () const
 get a copy of model
 
SharedDiagonal & get_model ()
 get a copy of model (non-const version)
 
const constBVector getb () const
 Get a view of the r.h.s. More...
 
constABlock getA (const_iterator variable) const
 Get a view of the A matrix for the variable pointed to by the given key iterator.
 
constABlock getA () const
 Get a view of the A matrix, not weighted by noise.
 
BVector getb ()
 Get a view of the r.h.s. More...
 
ABlock getA (iterator variable)
 Get a view of the A matrix for the variable pointed to by the given key iterator (non-const version)
 
ABlock getA ()
 Get a view of the A matrix.
 
void updateHessian (const KeyVector &keys, SymmetricBlockMatrix *info) const override
 Update an information matrix by adding the information corresponding to this factor (used internally during elimination). More...
 
Vector operator* (const VectorValues &x) const
 Return A*x.
 
void transposeMultiplyAdd (double alpha, const Vector &e, VectorValues &x) const
 x += alpha * A'*e. More...
 
void multiplyHessianAdd (double alpha, const VectorValues &x, VectorValues &y) const override
 y += alpha * A'*A*x More...
 
void multiplyHessianAdd (double alpha, const double *x, double *y, const std::vector< size_t > &accumulatedDims) const
 Raw memory access version of multiplyHessianAdd y += alpha * A'*A*x Requires the vector accumulatedDims to tell the dimension of each variable: e.g. More...
 
VectorValues gradientAtZero () const override
 A'*b for Jacobian. More...
 
void gradientAtZero (double *d) const override
 A'*b for Jacobian (raw memory version) More...
 
Vector gradient (Key key, const VectorValues &x) const override
 Compute the gradient wrt a key at any values. More...
 
JacobianFactor whiten () const
 Return a whitened version of the factor, i.e. More...
 
std::pair< boost::shared_ptr< GaussianConditional >, shared_ptreliminate (const Ordering &keys)
 Eliminate the requested variables.
 
void setModel (bool anyConstrained, const Vector &sigmas)
 set noiseModel correctly
 
boost::shared_ptr< GaussianConditionalsplitConditional (size_t nrFrontals)
 splits a pre-factorized factor into a conditional, and changes the current factor to be the remaining component. More...
 
- Public Member Functions inherited from gtsam::GaussianFactor
 GaussianFactor ()
 Default constructor creates empty factor.
 
template<typename CONTAINER >
 GaussianFactor (const CONTAINER &keys)
 Construct from container of keys. More...
 
virtual ~GaussianFactor ()
 Destructor.
 
void print (const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override=0
 print More...
 
virtual bool equals (const GaussianFactor &lf, double tol=1e-9) const =0
 Equals for testable. More...
 
virtual double error (const VectorValues &c) const =0
 Print for testable. More...
 
virtual DenseIndex getDim (const_iterator variable) const =0
 0.5*(A*x-b)'D(A*x-b) More...
 
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. More...
 
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. More...
 
virtual Matrix augmentedInformation () const =0
 Return the augmented information matrix represented by this GaussianFactor. More...
 
virtual Matrix information () const =0
 Return the non-augmented information matrix represented by this GaussianFactor. More...
 
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. More...
 
virtual void hessianDiagonal (double *d) const =0
 Raw memory access version of hessianDiagonal. More...
 
virtual std::map< Key, Matrix > hessianBlockDiagonal () const =0
 Return the block diagonal of the Hessian for this factor. More...
 
virtual GaussianFactor::shared_ptr clone () const =0
 Clone a factor (make a deep copy) More...
 
virtual bool empty () const =0
 Test whether the factor is empty. More...
 
virtual GaussianFactor::shared_ptr negate () const =0
 Construct the corresponding anti-factor to negate information stored stored in this factor. More...
 
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). More...
 
virtual void multiplyHessianAdd (double alpha, const VectorValues &x, VectorValues &y) const =0
 y += alpha * A'*A*x More...
 
virtual VectorValues gradientAtZero () const =0
 A'*b for Jacobian, eta for Hessian. More...
 
virtual void gradientAtZero (double *d) const =0
 Raw memory access version of gradientAtZero. More...
 
virtual Vector gradient (Key key, const VectorValues &x) const =0
 Gradient wrt a key at any values. More...
 
- Public Member Functions inherited from gtsam::Factor
virtual ~Factor ()=default
 Default destructor.
 
KeyVectorkeys ()
 
iterator begin ()
 Iterator at beginning of involved variable keys.
 
iterator end ()
 Iterator at end of involved variable keys.
 
virtual void printKeys (const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const
 print only keys More...
 
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
 Iterator at beginning of involved variable keys.
 
const_iterator end () const
 Iterator at end of involved variable keys.
 
size_t size () const
 
- Public Member Functions inherited from gtsam::Conditional< JacobianFactor, GaussianConditional >
void print (const std::string &s="Conditional", const KeyFormatter &formatter=DefaultKeyFormatter) const
 print with optional formatter
 
bool equals (const This &c, double tol=1e-9) const
 check equality
 
size_t nrFrontals () const
 return the number of frontals
 
size_t nrParents () const
 return the number of parents
 
Key firstFrontalKey () const
 Convenience function to get the first frontal key.
 
Frontals frontals () const
 return a view of the frontal keys
 
Parents parents () const
 return a view of the parent keys
 
FACTOR::const_iterator beginFrontals () const
 Iterator pointing to first frontal key.
 
FACTOR::const_iterator endFrontals () const
 Iterator pointing past the last frontal key.
 
FACTOR::const_iterator beginParents () const
 Iterator pointing to the first parent key.
 
FACTOR::const_iterator endParents () const
 Iterator pointing past the last parent key.
 
size_t & nrFrontals ()
 Mutable version of nrFrontals.
 
FACTOR::iterator beginFrontals ()
 Mutable iterator pointing to first frontal key.
 
FACTOR::iterator endFrontals ()
 Mutable iterator pointing past the last frontal key.
 
FACTOR::iterator beginParents ()
 Mutable iterator pointing to the first parent key.
 
FACTOR::iterator endParents ()
 Mutable iterator pointing past the last parent key.
 

Static Public Member Functions

static GaussianDensity FromMeanAndStddev (Key key, const Vector &mean, const double &sigma)
 Construct using a mean and variance.
 
- Static Public Member Functions inherited from gtsam::GaussianConditional
template<typename ITERATOR >
static shared_ptr Combine (ITERATOR firstConditional, ITERATOR lastConditional)
 Combine several GaussianConditional into a single dense GC. More...
 
- Static Public Member Functions inherited from gtsam::GaussianFactor
template<typename CONTAINER >
static DenseIndex Slot (const CONTAINER &keys, Key key)
 

Public Types

typedef boost::shared_ptr< GaussianDensityshared_ptr
 
- Public Types inherited from gtsam::GaussianConditional
typedef GaussianConditional This
 Typedef to this class.
 
typedef boost::shared_ptr< Thisshared_ptr
 shared_ptr to this class
 
typedef JacobianFactor BaseFactor
 Typedef to our factor base class.
 
typedef Conditional< BaseFactor, ThisBaseConditional
 Typedef to our conditional base class.
 
- Public Types inherited from gtsam::JacobianFactor
typedef JacobianFactor This
 Typedef to this class.
 
typedef GaussianFactor Base
 Typedef to base class.
 
typedef boost::shared_ptr< Thisshared_ptr
 shared_ptr to this class
 
typedef VerticalBlockMatrix::Block ABlock
 
typedef VerticalBlockMatrix::constBlock constABlock
 
typedef ABlock::ColXpr BVector
 
typedef constABlock::ConstColXpr constBVector
 
- Public Types inherited from gtsam::GaussianFactor
typedef GaussianFactor This
 This class.
 
typedef boost::shared_ptr< Thisshared_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.
 
- Public Types inherited from gtsam::Conditional< JacobianFactor, GaussianConditional >
typedef boost::iterator_range< typename FACTOR::const_iterator > Frontals
 View of the frontal keys (call frontals())
 
typedef boost::iterator_range< typename FACTOR::const_iterator > Parents
 View of the separator keys (call parents())
 

Additional Inherited Members

- Protected Member Functions inherited from gtsam::JacobianFactor
template<typename TERMS >
void fillTerms (const TERMS &terms, const Vector &b, const SharedDiagonal &noiseModel)
 Internal function to fill blocks and set dimensions.
 
- Protected Member Functions inherited from gtsam::Factor
 Factor ()
 Default constructor for I/O.
 
template<typename CONTAINER >
 Factor (const CONTAINER &keys)
 Construct factor from container of keys. More...
 
template<typename ITERATOR >
 Factor (ITERATOR first, ITERATOR last)
 Construct factor from iterator keys. More...
 
bool equals (const This &other, double tol=1e-9) const
 check equality
 
- Protected Member Functions inherited from gtsam::Conditional< JacobianFactor, GaussianConditional >
 Conditional ()
 Empty Constructor to make serialization possible.
 
 Conditional (size_t nrFrontals)
 Constructor.
 
- Static Protected Member Functions inherited from gtsam::Factor
template<typename CONTAINER >
static Factor FromKeys (const CONTAINER &keys)
 Construct factor from container of keys. More...
 
template<typename ITERATOR >
static Factor FromIterators (ITERATOR first, ITERATOR last)
 Construct factor from iterator keys. More...
 
- Protected Attributes inherited from gtsam::JacobianFactor
VerticalBlockMatrix Ab_
 
noiseModel::Diagonal::shared_ptr model_
 
- Protected Attributes inherited from gtsam::Factor
KeyVector keys_
 The keys involved in this factor.
 
- Protected Attributes inherited from gtsam::Conditional< JacobianFactor, GaussianConditional >
size_t nrFrontals_
 The first nrFrontal variables are frontal and the rest are parents.
 

Member Function Documentation

◆ print()

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

print

Reimplemented from gtsam::GaussianConditional.


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