[involves] checks whether variable with that key is involved in any factor
parent
6aba2f1c1c
commit
55e85fd8a5
|
@ -92,6 +92,11 @@ namespace gtsam {
|
|||
/** return keys in some random order */
|
||||
Ordering keys() const;
|
||||
|
||||
/** Check whether a factor with this variable exists */
|
||||
bool involves(const std::string& key) {
|
||||
return !(indices_.find(key)==indices_.end());
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute colamd ordering
|
||||
*/
|
||||
|
|
|
@ -527,6 +527,16 @@ TEST( GaussianFactorGraph, keys )
|
|||
CHECK(assert_equal(expected,fg.keys()));
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
TEST( GaussianFactorGraph, involves )
|
||||
{
|
||||
GaussianFactorGraph fg = createGaussianFactorGraph();
|
||||
CHECK(fg.involves("l1"));
|
||||
CHECK(fg.involves("x1"));
|
||||
CHECK(fg.involves("x2"));
|
||||
CHECK(!fg.involves("x3"));
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
// Tests ported from ConstrainedGaussianFactorGraph
|
||||
/* ************************************************************************* */
|
||||
|
|
Loading…
Reference in New Issue