Loading...
Searching...
No Matches
GaussianConditional.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 <boost/utility.hpp>
#include <gtsam/global_includes.h>
#include <gtsam/linear/JacobianFactor.h>
#include <gtsam/inference/Conditional.h>
#include <gtsam/inference/Conditional-inst.h>
#include <gtsam/linear/VectorValues.h>
#include <random> // for std::mt19937_64
namespace gtsam {
class GTSAM_EXPORT GaussianConditional :
public JacobianFactor,
public Conditional<JacobianFactor, GaussianConditional>
{
public:
typedef GaussianConditional This;
typedef boost::shared_ptr<This> shared_ptr;
typedef JacobianFactor BaseFactor;
typedef Conditional<BaseFactor, This> BaseConditional;
GaussianConditional() {}
GaussianConditional(Key key, const Vector& d, const Matrix& R,
const SharedDiagonal& sigmas = SharedDiagonal());
GaussianConditional(Key key, const Vector& d, const Matrix& R, Key parent1,
const Matrix& S,
const SharedDiagonal& sigmas = SharedDiagonal());
GaussianConditional(Key key, const Vector& d, const Matrix& R, Key parent1,
const Matrix& S, Key parent2, const Matrix& T,
const SharedDiagonal& sigmas = SharedDiagonal());
template<typename TERMS>
GaussianConditional(const TERMS& terms,
size_t nrFrontals, const Vector& d,
const SharedDiagonal& sigmas = SharedDiagonal());
template<typename KEYS>
GaussianConditional(
const KEYS& keys, size_t nrFrontals, const VerticalBlockMatrix& augmentedMatrix,
const SharedDiagonal& sigmas = SharedDiagonal());
static GaussianConditional FromMeanAndStddev(Key key, const Vector& mu,
double sigma);
static GaussianConditional FromMeanAndStddev(Key key, const Matrix& A,
Key parent, const Vector& b,
double sigma);
static GaussianConditional FromMeanAndStddev(Key key, //
const Matrix& A1, Key parent1,
const Matrix& A2, Key parent2,
const Vector& b, double sigma);
template<typename... Args>
static shared_ptr sharedMeanAndStddev(Args&&... args) {
return boost::make_shared<This>(FromMeanAndStddev(std::forward<Args>(args)...));
}
template<typename ITERATOR>
static shared_ptr Combine(ITERATOR firstConditional, ITERATOR lastConditional);
void print(
const std::string& = "GaussianConditional",
const KeyFormatter& formatter = DefaultKeyFormatter) const override;
bool equals(const GaussianFactor&cg, double tol = 1e-9) const override;
double logNormalizationConstant() const override;
double logProbability(const VectorValues& x) const;
double evaluate(const VectorValues& x) const;
double operator()(const VectorValues& x) const {
return evaluate(x);
}
VectorValues solve(const VectorValues& parents) const;
VectorValues solveOtherRHS(const VectorValues& parents, const VectorValues& rhs) const;
void solveTransposeInPlace(VectorValues& gy) const;
JacobianFactor::shared_ptr likelihood(
const VectorValues& frontalValues) const;
JacobianFactor::shared_ptr likelihood(const Vector& frontal) const;
VectorValues sample(std::mt19937_64* rng) const;
VectorValues sample(const VectorValues& parentsValues,
std::mt19937_64* rng) const;
VectorValues sample() const;
VectorValues sample(const VectorValues& parentsValues) const;
constABlock R() const { return Ab_.range(0, nrFrontals()); }
constABlock S() const { return Ab_.range(nrFrontals(), size()); }
constABlock S(const_iterator it) const { return BaseFactor::getA(it); }
const constBVector d() const { return BaseFactor::getb(); }
inline double determinant() const { return exp(logDeterminant()); }
double logDeterminant() const;
double logProbability(const HybridValues& x) const override;
double evaluate(const HybridValues& x) const override;
using Conditional::operator(); // Expose evaluate(const HybridValues&) method..
using JacobianFactor::error; // Expose error(const HybridValues&) method..
#ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V42
void GTSAM_DEPRECATED scaleFrontalsBySigma(VectorValues& gy) const;
#endif
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int /*version*/) {
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(BaseFactor);
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(BaseConditional);
}
}; // GaussianConditional
template<>
struct traits<GaussianConditional> : public Testable<GaussianConditional> {};
} // \ namespace gtsam
#include <gtsam/linear/GaussianConditional-inl.h>
Conditional.h
Base class for conditional densities.
GaussianConditional-inl.h
Conditional Gaussian Base class.
VectorValues.h
Factor Graph Values.
JacobianFactor.h
global_includes.h
Included from all GTSAM files.
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
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::Testable
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:151
gtsam::VerticalBlockMatrix
This class stores a dense matrix and allows it to be accessed as a collection of vertical blocks.
Definition VerticalBlockMatrix.h:43
gtsam::HybridValues
HybridValues represents a collection of DiscreteValues and VectorValues.
Definition HybridValues.h:38
gtsam::Conditional< JacobianFactor, GaussianConditional >::nrFrontals
size_t nrFrontals() const
Definition Conditional.h:110
gtsam::Conditional< JacobianFactor, GaussianConditional >::Conditional
Conditional()
Definition Conditional.h:85
gtsam::Factor::const_iterator
KeyVector::const_iterator const_iterator
Const iterator over keys.
Definition Factor.h:80
gtsam::Factor::size
size_t size() const
Definition Factor.h:157
gtsam::GaussianConditional
A GaussianConditional functions as the node in a Bayes network.
Definition GaussianConditional.h:43
gtsam::GaussianConditional::This
GaussianConditional This
Typedef to this class.
Definition GaussianConditional.h:45
gtsam::GaussianConditional::logDeterminant
double logDeterminant() const
Compute the log determinant of the R matrix.
Definition GaussianConditional.cpp:176
gtsam::GaussianConditional::logProbability
double logProbability(const VectorValues &x) const
Calculate log-probability log(evaluate(x)) for given values x: -error(x) - 0.5 * n*log(2*pi) - 0....
Definition GaussianConditional.cpp:199
gtsam::GaussianConditional::logNormalizationConstant
double logNormalizationConstant() const override
normalization constant = 1.0 / sqrt((2*pi)^n*det(Sigma)) log = - 0.5 * n*log(2*pi) - 0....
Definition GaussianConditional.cpp:189
gtsam::GaussianConditional::S
constABlock S(const_iterator it) const
Get a view of the S matrix for the variable pointed to by the given key iterator.
Definition GaussianConditional.h:224
gtsam::GaussianConditional::R
constABlock R() const
Return a view of the upper-triangular R block of the conditional.
Definition GaussianConditional.h:218
gtsam::GaussianConditional::BaseFactor
JacobianFactor BaseFactor
Typedef to our factor base class.
Definition GaussianConditional.h:47
gtsam::GaussianConditional::GaussianConditional
GaussianConditional()
default constructor needed for serialization
Definition GaussianConditional.h:54
gtsam::GaussianConditional::BaseConditional
Conditional< BaseFactor, This > BaseConditional
Typedef to our conditional base class.
Definition GaussianConditional.h:48
gtsam::GaussianConditional::FromMeanAndStddev
static GaussianConditional FromMeanAndStddev(Key key, const Vector &mu, double sigma)
Construct from mean mu and standard deviation sigma.
Definition GaussianConditional.cpp:69
gtsam::GaussianConditional::equals
bool equals(const GaussianFactor &cg, double tol=1e-9) const override
equals function
Definition GaussianConditional.cpp:136
gtsam::GaussianConditional::evaluate
double evaluate(const VectorValues &x) const
Calculate probability density for given values x: exp(logProbability(x)) == exp(-GaussianFactor::erro...
Definition GaussianConditional.cpp:208
gtsam::GaussianConditional::Combine
static shared_ptr Combine(ITERATOR firstConditional, ITERATOR lastConditional)
Combine several GaussianConditional into a single dense GC.
gtsam::GaussianConditional::determinant
double determinant() const
Compute the determinant of the R matrix.
Definition GaussianConditional.h:240
gtsam::GaussianConditional::operator()
double operator()(const VectorValues &x) const
Evaluate probability density, sugar.
Definition GaussianConditional.h:158
gtsam::GaussianConditional::sharedMeanAndStddev
static shared_ptr sharedMeanAndStddev(Args &&... args)
Create shared pointer by forwarding arguments to fromMeanAndStddev.
Definition GaussianConditional.h:105
gtsam::GaussianConditional::S
constABlock S() const
Get a view of the parent blocks.
Definition GaussianConditional.h:221
gtsam::GaussianConditional::print
void print(const std::string &="GaussianConditional", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print
Definition GaussianConditional.cpp:104
gtsam::GaussianConditional::shared_ptr
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition GaussianConditional.h:46
gtsam::GaussianConditional::d
const constBVector d() const
Get a view of the r.h.s.
Definition GaussianConditional.h:227
gtsam::GaussianFactor
An abstract virtual base class for JacobianFactor and HessianFactor.
Definition GaussianFactor.h:39
gtsam::JacobianFactor::getb
const constBVector getb() const
Get a view of the r.h.s.
Definition JacobianFactor.h:297
gtsam::JacobianFactor::JacobianFactor
JacobianFactor(const GaussianFactor &gf)
Convert from other GaussianFactor.
Definition JacobianFactor.cpp:60
gtsam::JacobianFactor::shared_ptr
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition JacobianFactor.h:96
gtsam::JacobianFactor::getA
constABlock getA(const_iterator variable) const
Get a view of the A matrix for the variable pointed to by the given key iterator.
Definition JacobianFactor.h:300
gtsam::VectorValues
VectorValues represents a collection of vector-valued variables associated each with a unique integer...
Definition VectorValues.h:74