Added a single-element update() for LieConfig

release/4.3a0
Alex Cunningham 2010-05-03 18:07:27 +00:00
parent 0b5ebba67e
commit 3df1f69e6c
3 changed files with 24 additions and 0 deletions

View File

@ -91,6 +91,11 @@ namespace gtsam {
}
}
template<class J, class T>
void LieConfig<J,T>::update(const J& j, const T& val) {
values_[j] = val;
}
template<class J, class T>
std::list<J> LieConfig<J,T>::keys() const {
std::list<J> ret;

View File

@ -100,6 +100,9 @@ namespace gtsam {
/** update the current available values without adding new ones */
void update(const LieConfig& cfg);
/** single element change of existing element */
void update(const J& j, const T& val);
/** Remove a variable from the config */
void erase(const J& j);

View File

@ -79,6 +79,22 @@ TEST( LieConfig, insert_config )
CHECK(assert_equal(cfg1, expected));
}
/* ************************************************************************* */
TEST( LieConfig, insert_overlap )
{
LieConfig<string,Vector> cfg;
Vector v1 = Vector_(3, 5.0, 6.0, 7.0);
Vector v2 = Vector_(3, 8.0, 9.0, 1.0);
cfg.insert("x1", v1);
CHECK(cfg.size() == 1);
CHECK(assert_equal(v1, cfg.at("x1")));
cfg.update("x1", v2);
CHECK(cfg.size() == 1);
CHECK(assert_equal(v2, cfg.at("x1"))); // fails - need to change behavior
}
/* ************************************************************************* */
TEST(LieConfig, dim_zero)
{