From 95f8b3bf2e365046838697e78c8f6226be5a6d09 Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Tue, 3 Sep 2013 13:51:24 +0000 Subject: [PATCH] Fixed GaussianConditional equals hiding warning --- gtsam/linear/GaussianConditional.cpp | 55 ++++++++++++++++------------ gtsam/linear/GaussianConditional.h | 2 +- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/gtsam/linear/GaussianConditional.cpp b/gtsam/linear/GaussianConditional.cpp index 57d0a0982..3900082fd 100644 --- a/gtsam/linear/GaussianConditional.cpp +++ b/gtsam/linear/GaussianConditional.cpp @@ -74,39 +74,46 @@ namespace gtsam { } /* ************************************************************************* */ - bool GaussianConditional::equals(const GaussianConditional &c, double tol) const + bool GaussianConditional::equals(const GaussianFactor& f, double tol) const { - // check if the size of the parents_ map is the same - if (parents().size() != c.parents().size()) - return false; + if (const GaussianConditional* c = dynamic_cast(&f)) + { + // check if the size of the parents_ map is the same + if (parents().size() != c->parents().size()) + return false; - // check if R_ and d_ are linear independent - for (DenseIndex i=0; i rows1; rows1.push_back(Vector(get_R().row(i))); - list rows2; rows2.push_back(Vector(c.get_R().row(i))); + // check if R_ and d_ are linear independent + for (DenseIndex i = 0; i < Ab_.rows(); i++) { + list rows1; rows1.push_back(Vector(get_R().row(i))); + list rows2; rows2.push_back(Vector(c->get_R().row(i))); - // check if the matrices are the same - // iterate over the parents_ map - for (const_iterator it = beginParents(); it != endParents(); ++it) { - const_iterator it2 = c.beginParents() + (it-beginParents()); - if(*it != *(it2)) + // check if the matrices are the same + // iterate over the parents_ map + for (const_iterator it = beginParents(); it != endParents(); ++it) { + const_iterator it2 = c->beginParents() + (it - beginParents()); + if (*it != *(it2)) + return false; + rows1.push_back(row(getA(it), i)); + rows2.push_back(row(c->getA(it2), i)); + } + + Vector row1 = concatVectors(rows1); + Vector row2 = concatVectors(rows2); + if (!linear_dependent(row1, row2, tol)) return false; - rows1.push_back(row(getA(it), i)); - rows2.push_back(row(c.getA(it2), i)); } - Vector row1 = concatVectors(rows1); - Vector row2 = concatVectors(rows2); - if (!linear_dependent(row1, row2, tol)) + // check if sigmas are equal + if ((model_ && !c->model_) || (!model_ && c->model_) + || (model_ && c->model_ && !model_->equals(*c->model_, tol))) return false; + + return true; } - - // check if sigmas are equal - if ((model_ && !c.model_) || (!model_ && c.model_) - || (model_ && c.model_ && !model_->equals(*c.model_, tol))) + else + { return false; - - return true; + } } /* ************************************************************************* */ diff --git a/gtsam/linear/GaussianConditional.h b/gtsam/linear/GaussianConditional.h index 5be687d7b..a36de0dc2 100644 --- a/gtsam/linear/GaussianConditional.h +++ b/gtsam/linear/GaussianConditional.h @@ -91,7 +91,7 @@ namespace gtsam { const KeyFormatter& formatter = DefaultKeyFormatter) const; /** equals function */ - bool equals(const GaussianConditional&cg, double tol = 1e-9) const; + bool equals(const GaussianFactor&cg, double tol = 1e-9) const; /** Return a view of the upper-triangular R block of the conditional */ constABlock get_R() const { return Ab_.range(0, nrFrontals()); }