gtsam
Loading...
Searching...
No Matches
JointMarginal.h
Go to the documentation of this file.
1/* ----------------------------------------------------------------------------
2
3 * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4 * Atlanta, Georgia 30332-0415
5 * All Rights Reserved
6 * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7
8 * See LICENSE for the license information
9
10 * -------------------------------------------------------------------------- */
11
17
18#pragma once
19
21#include <gtsam/inference/Key.h>
23
24namespace gtsam {
25
27class ISAM2;
28class Marginals;
29
34class GTSAM_EXPORT JointMarginal {
35 protected:
36 SymmetricBlockMatrix blockMatrix_;
37 KeyVector keys_;
38 FastMap<Key, size_t> indices_;
39
40 public:
43
53 Matrix operator()(Key iVariable, Key jVariable) const {
54 const auto indexI = indices_.at(iVariable);
55 const auto indexJ = indices_.at(jVariable);
56 return blockMatrix_.block(indexI, indexJ);
57 }
58
60 Matrix at(Key iVariable, Key jVariable) const { return (*this)(iVariable, jVariable); }
61
65 Matrix fullMatrix() const { return blockMatrix_.selfadjointView(); }
66
68 void print(const std::string& s = "",
69 const KeyFormatter& formatter = DefaultKeyFormatter) const;
70
72 JointMarginal(const Matrix& fullMatrix, const Scatter& scatter);
73};
74
75} // namespace gtsam
Access to matrices via blocks of pre-defined sizes.
Maps global variable indices to slot indices.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition Key.cpp:30
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition Key.h:91
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:143
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
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:43
FastMap is a thin wrapper around std::map that uses the boost fast_pool_allocator instead of the defa...
Definition FastMap.h:40
This class stores a dense matrix and allows it to be accessed as a collection of blocks.
Definition SymmetricBlockMatrix.h:80
A Bayes tree representing a Gaussian density.
Definition GaussianBayesTree.h:53
A class to store and access a joint marginal, returned from Gaussian and nonlinear covariance query A...
Definition JointMarginal.h:34
Matrix at(Key iVariable, Key jVariable) const
Synonym for operator() See operator() for indexing semantics.
Definition JointMarginal.h:60
Matrix fullMatrix() const
The full, dense covariance/information matrix of the joint marginal.
Definition JointMarginal.h:65
Matrix operator()(Key iVariable, Key jVariable) const
Access a block, corresponding to a pair of variables, of the joint marginal.
Definition JointMarginal.h:53
JointMarginal()
Default constructor only for wrappers.
Definition JointMarginal.h:42
Scatter is an intermediate data structure used when building a HessianFactor incrementally,...
Definition Scatter.h:49
Implementation of the full ISAM2 algorithm for incremental nonlinear optimization.
Definition ISAM2.h:45
A class for computing Gaussian marginals of variables in a NonlinearFactorGraph.
Definition Marginals.h:31