fix warnings

release/4.3a0
Duy-Nguyen Ta 2013-10-11 20:26:50 +00:00
parent 19d64460ba
commit 00f109e88f
3 changed files with 23 additions and 16 deletions

View File

@ -45,8 +45,9 @@ namespace gtsam {
/* ************************************************************************* */ /* ************************************************************************* */
bool DecisionTreeFactor::equals(const DiscreteFactor& other, double tol) const { bool DecisionTreeFactor::equals(const DiscreteFactor& other, double tol) const {
if(!dynamic_cast<const DecisionTreeFactor*>(&other)) if(!dynamic_cast<const DecisionTreeFactor*>(&other)) {
return false; return false;
}
else { else {
const DecisionTreeFactor& f(static_cast<const DecisionTreeFactor&>(other)); const DecisionTreeFactor& f(static_cast<const DecisionTreeFactor&>(other));
return Potentials::equals(f, tol); return Potentials::equals(f, tol);

View File

@ -49,7 +49,7 @@ DiscreteConditional::DiscreteConditional(const DecisionTreeFactor& joint,
const DecisionTreeFactor& marginal, const boost::optional<Ordering>& orderedKeys) : const DecisionTreeFactor& marginal, const boost::optional<Ordering>& orderedKeys) :
BaseFactor( BaseFactor(
ISDEBUG("DiscreteConditional::COUNT") ? joint : joint / marginal), BaseConditional( ISDEBUG("DiscreteConditional::COUNT") ? joint : joint / marginal), BaseConditional(
joint.size()-marginal.size()) { joint.size()-marginal.size()) {
if (ISDEBUG("DiscreteConditional::DiscreteConditional")) if (ISDEBUG("DiscreteConditional::DiscreteConditional"))
cout << (firstFrontalKey()) << endl; //TODO Print all keys cout << (firstFrontalKey()) << endl; //TODO Print all keys
if (orderedKeys) { if (orderedKeys) {
@ -60,8 +60,8 @@ DiscreteConditional::DiscreteConditional(const DecisionTreeFactor& joint,
/* ******************************************************************************** */ /* ******************************************************************************** */
DiscreteConditional::DiscreteConditional(const Signature& signature) : DiscreteConditional::DiscreteConditional(const Signature& signature) :
BaseFactor(signature.discreteKeysParentsFirst(), signature.cpt()), BaseConditional( BaseFactor(signature.discreteKeysParentsFirst(), signature.cpt()), BaseConditional(
1) { 1) {
} }
/* ******************************************************************************** */ /* ******************************************************************************** */
@ -72,9 +72,15 @@ void DiscreteConditional::print(const std::string& s,
} }
/* ******************************************************************************** */ /* ******************************************************************************** */
bool DiscreteConditional::equals(const DiscreteConditional& other, bool DiscreteConditional::equals(const DiscreteFactor& other,
double tol) const { double tol) const {
return Potentials::equals(other, tol); if (!dynamic_cast<const DecisionTreeFactor*>(&other))
return false;
else {
const DecisionTreeFactor& f(
static_cast<const DecisionTreeFactor&>(other));
return DecisionTreeFactor::equals(f, tol);
}
} }
/* ******************************************************************************** */ /* ******************************************************************************** */
@ -82,15 +88,15 @@ Potentials::ADT DiscreteConditional::choose(const Values& parentsValues) const {
ADT pFS(*this); ADT pFS(*this);
Index j; size_t value; Index j; size_t value;
BOOST_FOREACH(Index key, parents()) BOOST_FOREACH(Index key, parents())
try { try {
j = (key); j = (key);
value = parentsValues.at(j); value = parentsValues.at(j);
pFS = pFS.choose(j, value); pFS = pFS.choose(j, value);
} catch (exception&) { } catch (exception&) {
cout << "Key: " << j << " Value: " << value << endl; cout << "Key: " << j << " Value: " << value << endl;
pFS.print("pFS: "); pFS.print("pFS: ");
throw runtime_error("DiscreteConditional::choose: parent value missing"); throw runtime_error("DiscreteConditional::choose: parent value missing");
}; };
return pFS; return pFS;
} }

View File

@ -82,7 +82,7 @@ public:
const IndexFormatter& formatter = DefaultIndexFormatter) const; const IndexFormatter& formatter = DefaultIndexFormatter) const;
/// GTSAM-style equals /// GTSAM-style equals
bool equals(const DiscreteConditional& other, double tol = 1e-9) const; bool equals(const DiscreteFactor& other, double tol = 1e-9) const;
/// @} /// @}
/// @name Standard Interface /// @name Standard Interface