Loading...
Searching...
No Matches
GaussianFactor.h
Go to the documentation of this file.
/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
// \callgraph
#pragma once
#include <gtsam/inference/Factor.h>
#include <gtsam/base/Matrix.h>
#include <gtsam/base/Testable.h>
namespace gtsam {
// Forward declarations
class VectorValues;
class Scatter;
class SymmetricBlockMatrix;
class GTSAM_EXPORT GaussianFactor : public Factor
{
public:
typedef GaussianFactor This;
typedef boost::shared_ptr<This> shared_ptr;
typedef Factor Base;
GaussianFactor() {}
template<typename CONTAINER>
GaussianFactor(const CONTAINER& keys) : Base(keys) {}
virtual ~GaussianFactor() {}
// Implementing Testable interface
void print(
const std::string& s = "",
const KeyFormatter& formatter = DefaultKeyFormatter) const override = 0;
virtual bool equals(const GaussianFactor& lf, double tol = 1e-9) const = 0;
virtual double error(const VectorValues& c) const;
double error(const HybridValues& c) const override;
virtual DenseIndex getDim(const_iterator variable) const = 0;
virtual Matrix augmentedJacobian() const = 0;
virtual std::pair<Matrix,Vector> jacobian() const = 0;
virtual Matrix augmentedInformation() const = 0;
virtual Matrix information() const = 0;
VectorValues hessianDiagonal() const;
virtual void hessianDiagonalAdd(VectorValues& d) const = 0;
virtual void hessianDiagonal(double* d) const = 0;
virtual std::map<Key,Matrix> hessianBlockDiagonal() const = 0;
virtual GaussianFactor::shared_ptr clone() const = 0;
virtual GaussianFactor::shared_ptr negate() const = 0;
virtual void updateHessian(const KeyVector& keys,
SymmetricBlockMatrix* info) const = 0;
virtual void multiplyHessianAdd(double alpha, const VectorValues& x, VectorValues& y) const = 0;
virtual VectorValues gradientAtZero() const = 0;
virtual void gradientAtZero(double* d) const = 0;
virtual Vector gradient(Key key, const VectorValues& x) const = 0;
// Determine position of a given key
template <typename CONTAINER>
static DenseIndex Slot(const CONTAINER& keys, Key key) {
return std::find(keys.begin(), keys.end(), key) - keys.begin();
}
private:
friend class boost::serialization::access;
template<class ARCHIVE>
void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
}
}; // GaussianFactor
template<>
struct traits<GaussianFactor> : public Testable<GaussianFactor> {
};
} // \ namespace gtsam
Matrix.h
typedef and functions to augment Eigen's MatrixXd
Testable.h
Concept check for values that can be used in unit tests.
Factor.h
The base class for all factors.
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
gtsam::DenseIndex
ptrdiff_t DenseIndex
The index type for Eigen objects.
Definition types.h:106
gtsam::KeyVector
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition Key.h:86
gtsam::KeyFormatter
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition Key.h:35
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:100
gtsam::traits
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition concepts.h:30
gtsam::SymmetricBlockMatrix
This class stores a dense matrix and allows it to be accessed as a collection of blocks.
Definition SymmetricBlockMatrix.h:52
gtsam::Testable
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:151
gtsam::Factor::keys
const KeyVector & keys() const
Access the factor's involved variable keys.
Definition Factor.h:140
gtsam::Factor::Factor
Factor()
Default constructor for I/O.
Definition Factor.h:91
gtsam::Factor::const_iterator
KeyVector::const_iterator const_iterator
Const iterator over keys.
Definition Factor.h:80
gtsam::GaussianFactor
An abstract virtual base class for JacobianFactor and HessianFactor.
Definition GaussianFactor.h:39
gtsam::GaussianFactor::getDim
virtual DenseIndex getDim(const_iterator variable) const =0
Return the dimension of the variable pointed to by the given key iterator.
gtsam::GaussianFactor::hessianBlockDiagonal
virtual std::map< Key, Matrix > hessianBlockDiagonal() const =0
Return the block diagonal of the Hessian for this factor.
gtsam::GaussianFactor::shared_ptr
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition GaussianFactor.h:42
gtsam::GaussianFactor::jacobian
virtual std::pair< Matrix, Vector > jacobian() const =0
Return the dense Jacobian and right-hand-side , with the noise models baked into A and b.
gtsam::GaussianFactor::gradient
virtual Vector gradient(Key key, const VectorValues &x) const =0
Gradient wrt a key at any values.
gtsam::GaussianFactor::clone
virtual GaussianFactor::shared_ptr clone() const =0
Clone a factor (make a deep copy).
gtsam::GaussianFactor::information
virtual Matrix information() const =0
Return the non-augmented information matrix represented by this GaussianFactor.
gtsam::GaussianFactor::Base
Factor Base
Our base class.
Definition GaussianFactor.h:43
gtsam::GaussianFactor::~GaussianFactor
virtual ~GaussianFactor()
Destructor.
Definition GaussianFactor.h:54
gtsam::GaussianFactor::gradientAtZero
virtual VectorValues gradientAtZero() const =0
A'*b for Jacobian, eta for Hessian.
gtsam::GaussianFactor::GaussianFactor
GaussianFactor(const CONTAINER &keys)
Construct from container of keys.
Definition GaussianFactor.h:51
gtsam::GaussianFactor::multiplyHessianAdd
virtual void multiplyHessianAdd(double alpha, const VectorValues &x, VectorValues &y) const =0
y += alpha * A'*A*x
gtsam::GaussianFactor::equals
virtual bool equals(const GaussianFactor &lf, double tol=1e-9) const =0
Equals for testable.
gtsam::GaussianFactor::augmentedInformation
virtual Matrix augmentedInformation() const =0
Return the augmented information matrix represented by this GaussianFactor.
gtsam::GaussianFactor::augmentedJacobian
virtual Matrix augmentedJacobian() const =0
Return a dense Jacobian matrix, augmented with b with the noise models baked into A and b.
gtsam::GaussianFactor::GaussianFactor
GaussianFactor()
Default constructor creates empty factor.
Definition GaussianFactor.h:46
gtsam::GaussianFactor::hessianDiagonal
VectorValues hessianDiagonal() const
Return the diagonal of the Hessian for this factor.
Definition GaussianFactor.cpp:35
gtsam::GaussianFactor::negate
virtual GaussianFactor::shared_ptr negate() const =0
Construct the corresponding anti-factor to negate information stored stored in this factor.
gtsam::GaussianFactor::hessianDiagonal
virtual void hessianDiagonal(double *d) const =0
Raw memory access version of hessianDiagonal.
gtsam::GaussianFactor::This
GaussianFactor This
This class.
Definition GaussianFactor.h:41
gtsam::GaussianFactor::updateHessian
virtual void updateHessian(const KeyVector &keys, SymmetricBlockMatrix *info) const =0
Update an information matrix by adding the information corresponding to this factor (used internally ...
gtsam::GaussianFactor::print
void print(const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override=0
print
gtsam::GaussianFactor::hessianDiagonalAdd
virtual void hessianDiagonalAdd(VectorValues &d) const =0
Add the current diagonal to a VectorValues instance.
gtsam::GaussianFactor::gradientAtZero
virtual void gradientAtZero(double *d) const =0
Raw memory access version of gradientAtZero.
gtsam::Scatter
Scatter is an intermediate data structure used when building a HessianFactor incrementally,...
Definition Scatter.h:49
gtsam::VectorValues
VectorValues represents a collection of vector-valued variables associated each with a unique integer...
Definition VectorValues.h:74
HybridValues
the error.
VectorValues
The Factor::error simply extracts the.