Fixed warnings due to discrete. GTSAM now Wall-safe?

release/4.3a0
Frank Dellaert 2012-06-22 21:45:36 +00:00
parent 617bf071cb
commit 0fe2d527f9
13 changed files with 26 additions and 25 deletions

View File

@ -17,6 +17,7 @@
#include <CppUnitLite/TestHarness.h>
#undef NDEBUG
#define NDEBUG
#undef GTSAM_ENABLE_DEBUG
#include <gtsam/base/debug.h>

View File

@ -94,7 +94,7 @@ namespace gtsam {
}
/// Convert into a decisiontree
virtual operator DecisionTreeFactor() const {
virtual DecisionTreeFactor toDecisionTreeFactor() const {
return *this;
}

View File

@ -96,7 +96,7 @@ namespace gtsam {
/// Multiply in a DecisionTreeFactor and return the result as DecisionTreeFactor
virtual DecisionTreeFactor operator*(const DecisionTreeFactor&) const = 0;
virtual operator DecisionTreeFactor() const = 0;
virtual DecisionTreeFactor toDecisionTreeFactor() const = 0;
/**
* Permutes the factor, but for efficiency requires the permutation

View File

@ -39,14 +39,14 @@ namespace gtsam {
}
/* ************************************************************************* */
AllDiff::operator DecisionTreeFactor() const {
DecisionTreeFactor AllDiff::toDecisionTreeFactor() const {
// We will do this by converting the allDif into many BinaryAllDiff constraints
DecisionTreeFactor converted;
size_t nrKeys = keys_.size();
for (size_t i1 = 0; i1 < nrKeys; i1++)
for (size_t i2 = i1 + 1; i2 < nrKeys; i2++) {
BinaryAllDiff binary12(discreteKey(i1),discreteKey(i2));
converted = converted * binary12;
converted = converted * binary12.toDecisionTreeFactor();
}
return converted;
}
@ -54,7 +54,7 @@ namespace gtsam {
/* ************************************************************************* */
DecisionTreeFactor AllDiff::operator*(const DecisionTreeFactor& f) const {
// TODO: can we do this more efficiently?
return DecisionTreeFactor(*this) * f;
return toDecisionTreeFactor() * f;
}
/* ************************************************************************* */

View File

@ -40,7 +40,7 @@ namespace gtsam {
virtual double operator()(const Values& values) const;
/// Convert into a decisiontree, can be *very* expensive !
virtual operator DecisionTreeFactor() const;
virtual DecisionTreeFactor toDecisionTreeFactor() const;
/// Multiply into a decisiontree
virtual DecisionTreeFactor operator*(const DecisionTreeFactor& f) const;

View File

@ -44,7 +44,7 @@ namespace gtsam {
}
/// Convert into a decisiontree
virtual operator DecisionTreeFactor() const {
virtual DecisionTreeFactor toDecisionTreeFactor() const {
DiscreteKeys keys;
keys.push_back(DiscreteKey(keys_[0],cardinality0_));
keys.push_back(DiscreteKey(keys_[1],cardinality1_));
@ -59,7 +59,7 @@ namespace gtsam {
/// Multiply into a decisiontree
virtual DecisionTreeFactor operator*(const DecisionTreeFactor& f) const {
// TODO: can we do this more efficiently?
return DecisionTreeFactor(*this) * f;
return toDecisionTreeFactor() * f;
}
/*

View File

@ -29,7 +29,7 @@ namespace gtsam {
}
/* ************************************************************************* */
Domain::operator DecisionTreeFactor() const {
DecisionTreeFactor Domain::toDecisionTreeFactor() const {
DiscreteKeys keys;
keys += DiscreteKey(keys_[0],cardinality_);
vector<double> table;
@ -42,7 +42,7 @@ namespace gtsam {
/* ************************************************************************* */
DecisionTreeFactor Domain::operator*(const DecisionTreeFactor& f) const {
// TODO: can we do this more efficiently?
return DecisionTreeFactor(*this) * f;
return toDecisionTreeFactor() * f;
}
/* ************************************************************************* */

View File

@ -76,7 +76,7 @@ namespace gtsam {
virtual double operator()(const Values& values) const;
/// Convert into a decisiontree
virtual operator DecisionTreeFactor() const;
virtual DecisionTreeFactor toDecisionTreeFactor() const;
/// Multiply into a decisiontree
virtual DecisionTreeFactor operator*(const DecisionTreeFactor& f) const;

View File

@ -27,7 +27,7 @@ namespace gtsam {
}
/* ************************************************************************* */
SingleValue::operator DecisionTreeFactor() const {
DecisionTreeFactor SingleValue::toDecisionTreeFactor() const {
DiscreteKeys keys;
keys += DiscreteKey(keys_[0],cardinality_);
vector<double> table;
@ -40,7 +40,7 @@ namespace gtsam {
/* ************************************************************************* */
DecisionTreeFactor SingleValue::operator*(const DecisionTreeFactor& f) const {
// TODO: can we do this more efficiently?
return DecisionTreeFactor(*this) * f;
return toDecisionTreeFactor() * f;
}
/* ************************************************************************* */

View File

@ -48,7 +48,7 @@ namespace gtsam {
virtual double operator()(const Values& values) const;
/// Convert into a decisiontree
virtual operator DecisionTreeFactor() const;
virtual DecisionTreeFactor toDecisionTreeFactor() const;
/// Multiply into a decisiontree
virtual DecisionTreeFactor operator*(const DecisionTreeFactor& f) const;

View File

@ -27,12 +27,12 @@ TEST_UNSAFE( BinaryAllDif, allInOne)
// Check construction and conversion
BinaryAllDiff c1(ID, UT);
DecisionTreeFactor f1(ID & UT, "0 1 1 0");
EXPECT(assert_equal(f1,(DecisionTreeFactor)c1));
EXPECT(assert_equal(f1,c1.toDecisionTreeFactor()));
// Check construction and conversion
BinaryAllDiff c2(UT, AZ);
DecisionTreeFactor f2(UT & AZ, "0 1 1 0");
EXPECT(assert_equal(f2,(DecisionTreeFactor)c2));
EXPECT(assert_equal(f2,c2.toDecisionTreeFactor()));
DecisionTreeFactor f3 = f1*f2;
EXPECT(assert_equal(f3,c1*f2));
@ -153,11 +153,11 @@ TEST_UNSAFE( CSP, AllDiff)
// Check construction and conversion
SingleValue s(AZ,2);
DecisionTreeFactor f1(AZ,"0 0 1");
EXPECT(assert_equal(f1,(DecisionTreeFactor)s));
EXPECT(assert_equal(f1,s.toDecisionTreeFactor()));
// Check construction and conversion
AllDiff alldiff(dkeys);
DecisionTreeFactor actual = (DecisionTreeFactor)alldiff;
DecisionTreeFactor actual = alldiff.toDecisionTreeFactor();
// GTSAM_PRINT(actual);
// actual.dot("actual");
DecisionTreeFactor f2(ID & AZ & UT,
@ -202,16 +202,16 @@ TEST_UNSAFE( CSP, AllDiff)
known[AZ.first] = 2;
DiscreteFactor::shared_ptr reduced1 = alldiff.partiallyApply(known);
DecisionTreeFactor f3(ID & UT, "0 1 1 1 0 1 1 1 0");
EXPECT(assert_equal(f3,reduced1->operator DecisionTreeFactor()));
EXPECT(assert_equal(f3,reduced1->toDecisionTreeFactor()));
DiscreteFactor::shared_ptr reduced2 = singleValue.partiallyApply(known);
DecisionTreeFactor f4(AZ, "0 0 1");
EXPECT(assert_equal(f4,reduced2->operator DecisionTreeFactor()));
EXPECT(assert_equal(f4,reduced2->toDecisionTreeFactor()));
// Parial application, version 2
DiscreteFactor::shared_ptr reduced3 = alldiff.partiallyApply(domains);
EXPECT(assert_equal(f3,reduced3->operator DecisionTreeFactor()));
EXPECT(assert_equal(f3,reduced3->toDecisionTreeFactor()));
DiscreteFactor::shared_ptr reduced4 = singleValue.partiallyApply(domains);
EXPECT(assert_equal(f4,reduced4->operator DecisionTreeFactor()));
EXPECT(assert_equal(f4,reduced4->toDecisionTreeFactor()));
// full arc-consistency test
csp.runArcConsistency(nrColors);

View File

@ -139,7 +139,7 @@ bool LinearizedFactor::equals(const NonlinearFactor& other, double tol) const {
return false;
KeyMatrixMap::const_iterator map1 = matrices_.begin(), map2 = e->matrices_.begin();
for (; map1 != matrices_.end(), map2 != e->matrices_.end(); ++map1, ++map2)
for (; map1 != matrices_.end() && map2 != e->matrices_.end(); ++map1, ++map2)
if ((map1->first != map2->first) || !equal_with_abs_tol(map1->second, map2->second, tol))
return false;
return true;

View File

@ -61,8 +61,8 @@ public:
throw runtime_error("operator * not implemented");
}
virtual operator DecisionTreeFactor() const{
throw runtime_error("operator DecisionTreeFactor not implemented");
virtual DecisionTreeFactor toDecisionTreeFactor() const{
throw runtime_error("DecisionTreeFactor toDecisionTreeFactor not implemented");
}
};