pop_front
parent
cc5a2c3183
commit
93da9e0f2c
|
@ -64,6 +64,12 @@ namespace gtsam {
|
||||||
conditionals_.push_front(conditional);
|
conditionals_.push_front(conditional);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pop_front: remove node at the bottom, used in marginalization
|
||||||
|
* For example P(ABC)=P(A|BC)P(B|C)P(C) becomes P(BC)=P(B|C)P(C)
|
||||||
|
*/
|
||||||
|
inline void pop_front() {conditionals_.pop_front();}
|
||||||
|
|
||||||
/** size is the number of nodes */
|
/** size is the number of nodes */
|
||||||
inline size_t size() const {
|
inline size_t size() const {
|
||||||
return conditionals_.size();
|
return conditionals_.size();
|
||||||
|
|
|
@ -43,6 +43,29 @@ TEST( SymbolicBayesNet, constructor )
|
||||||
CHECK(assert_equal(expected, *actual));
|
CHECK(assert_equal(expected, *actual));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************* */
|
||||||
|
TEST( SymbolicBayesNet, pop_front )
|
||||||
|
{
|
||||||
|
SymbolicConditional::shared_ptr
|
||||||
|
A(new SymbolicConditional("A","B","C")),
|
||||||
|
B(new SymbolicConditional("B","C")),
|
||||||
|
C(new SymbolicConditional("C"));
|
||||||
|
|
||||||
|
// Expected after pop_front
|
||||||
|
SymbolicBayesNet expected;
|
||||||
|
expected.push_back(B);
|
||||||
|
expected.push_back(C);
|
||||||
|
|
||||||
|
// Actual
|
||||||
|
SymbolicBayesNet actual;
|
||||||
|
actual.push_back(A);
|
||||||
|
actual.push_back(B);
|
||||||
|
actual.push_back(C);
|
||||||
|
actual.pop_front();
|
||||||
|
|
||||||
|
CHECK(assert_equal(expected,actual));
|
||||||
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
int main() {
|
int main() {
|
||||||
TestResult tr;
|
TestResult tr;
|
||||||
|
|
Loading…
Reference in New Issue