Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
Enumerations
a
c
d
e
f
g
i
k
l
m
n
p
q
r
s
t
u
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
z
Classes
Class List
Class Hierarchy
Class Members
All
!
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
!
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
a
b
c
d
f
k
l
m
n
o
p
r
s
t
v
z
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Related Functions
:
a
b
c
d
e
g
h
i
l
m
n
o
p
r
s
t
u
v
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
x
z
Enumerations
Enumerator
b
c
e
f
g
i
l
m
n
o
p
r
s
t
u
v
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Examples
gtsam
discrete
DiscreteMarginals.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
21
#pragma once
22
23
#include <
gtsam/base/Vector.h
>
24
#include <
gtsam/discrete/DiscreteBayesTree.h
>
25
#include <
gtsam/discrete/DiscreteFactorGraph.h
>
26
27
namespace
gtsam
{
28
33
class
DiscreteMarginals
{
34
protected
:
35
DiscreteBayesTree::shared_ptr
bayesTree_
;
36
37
public
:
38
DiscreteMarginals
() {}
39
44
DiscreteMarginals
(
const
DiscreteFactorGraph
&
graph
) {
45
bayesTree_
=
graph
.eliminateMultifrontal();
46
}
47
49
DiscreteFactor::shared_ptr
operator()
(
Key
variable)
const
{
50
// Compute marginal
51
DiscreteFactor::shared_ptr
marginalFactor =
52
bayesTree_
->marginalFactor(variable, &
EliminateDiscrete
);
53
return
marginalFactor;
54
}
55
60
Vector
marginalProbabilities
(
const
DiscreteKey
&
key
)
const
{
61
// Compute marginal
62
DiscreteFactor::shared_ptr
marginalFactor = this->
operator()
(key.first);
63
64
// Create result
65
Vector
vResult(
key
.second);
66
for
(
size_t
state
= 0;
state
<
key
.second; ++
state
) {
67
DiscreteValues
values
;
68
values
[
key
.first] =
state
;
69
vResult(
state
) = (*marginalFactor)(
values
);
70
}
71
return
vResult;
72
}
73
};
74
75
}
/* namespace gtsam */
gtsam::EliminateDiscrete
std::pair< DiscreteConditional::shared_ptr, DiscreteFactor::shared_ptr > EliminateDiscrete(const DiscreteFactorGraph &factors, const Ordering &frontalKeys)
Main elimination function for DiscreteFactorGraph.
Definition:
DiscreteFactorGraph.cpp:202
gtsam::DiscreteMarginals::operator()
DiscreteFactor::shared_ptr operator()(Key variable) const
Definition:
DiscreteMarginals.h:49
gtsam::DiscreteFactorGraph
Definition:
DiscreteFactorGraph.h:99
Vector.h
typedef and functions to augment Eigen's VectorXd
gtsam::DiscreteMarginals::DiscreteMarginals
DiscreteMarginals(const DiscreteFactorGraph &graph)
Definition:
DiscreteMarginals.h:44
gtsam::DiscreteBayesTree::shared_ptr
std::shared_ptr< This > shared_ptr
Definition:
DiscreteBayesTree.h:80
DiscreteFactorGraph.h
gtsam::DiscreteMarginals::DiscreteMarginals
DiscreteMarginals()
Definition:
DiscreteMarginals.h:38
different_sigmas::values
HybridValues values
Definition:
testHybridBayesNet.cpp:247
gtsam::DiscreteMarginals::bayesTree_
DiscreteBayesTree::shared_ptr bayesTree_
Definition:
DiscreteMarginals.h:35
gtsam::Vector
Eigen::VectorXd Vector
Definition:
Vector.h:39
gtsam::DiscreteMarginals
Definition:
DiscreteMarginals.h:33
DiscreteBayesTree.h
Discrete Bayes Tree, the result of eliminating a DiscreteJunctionTree.
key
const gtsam::Symbol key('X', 0)
gtsam
traits
Definition:
SFMdata.h:40
gtsam::DiscreteFactor::shared_ptr
std::shared_ptr< DiscreteFactor > shared_ptr
shared_ptr to this class
Definition:
DiscreteFactor.h:45
gtsam::DiscreteValues
Definition:
DiscreteValues.h:34
gtsam::DiscreteKey
std::pair< Key, size_t > DiscreteKey
Definition:
DiscreteKey.h:38
graph
NonlinearFactorGraph graph
Definition:
doc/Code/OdometryExample.cpp:2
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition:
types.h:97
gtsam::DiscreteMarginals::marginalProbabilities
Vector marginalProbabilities(const DiscreteKey &key) const
Definition:
DiscreteMarginals.h:60
make_changelog.state
state
Definition:
make_changelog.py:29
gtsam
Author(s):
autogenerated on Wed Mar 19 2025 03:01:36