From 793a9d58ae1efd586201ace21f19ab8f1eedafb8 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Wed, 30 Dec 2009 17:13:36 +0000 Subject: [PATCH] Errors is now a list --- cpp/Errors.cpp | 24 ++++++++++++++---------- cpp/Errors.h | 2 +- cpp/GaussianFactorGraph.cpp | 4 ++-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/cpp/Errors.cpp b/cpp/Errors.cpp index 55bbeb091..d75da2b2d 100644 --- a/cpp/Errors.cpp +++ b/cpp/Errors.cpp @@ -16,19 +16,22 @@ namespace gtsam { /* ************************************************************************* */ void Errors::print(const std::string& s) const { odprintf("%s:\n", s.c_str()); - for (size_t i=0;i { + double tol_; + equalsVector(double tol = 1e-9) : tol_(tol) {} + bool operator()(const Vector& expected, const Vector& actual) { + return equal_with_abs_tol(expected, actual,tol_); + } +}; + bool Errors::equals(const Errors& expected, double tol) const { if( size() != expected.size() ) return false; - for (size_t i=0;i, public Testable { + class Errors : public std::list, public Testable { public: diff --git a/cpp/GaussianFactorGraph.cpp b/cpp/GaussianFactorGraph.cpp index c0fe723ba..0d4c09f78 100644 --- a/cpp/GaussianFactorGraph.cpp +++ b/cpp/GaussianFactorGraph.cpp @@ -60,9 +60,9 @@ Errors GaussianFactorGraph::operator*(const VectorConfig& x) const { VectorConfig GaussianFactorGraph::operator^(const Errors& e) const { VectorConfig x; // For each factor add the gradient contribution - size_t i=0; + Errors::const_iterator it = e.begin(); BOOST_FOREACH(sharedFactor Ai,factors_) - x += (*Ai)^e[i++]; + x += (*Ai)^(*(it++)); return x; }