pop_front

release/4.3a0
Frank Dellaert 2009-11-08 02:49:18 +00:00
parent cc5a2c3183
commit 93da9e0f2c
2 changed files with 29 additions and 0 deletions

View File

@ -64,6 +64,12 @@ namespace gtsam {
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 */
inline size_t size() const {
return conditionals_.size();

View File

@ -43,6 +43,29 @@ TEST( SymbolicBayesNet, constructor )
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() {
TestResult tr;