remove previously added code

release/4.3a0
Varun Agrawal 2024-12-08 15:31:35 -05:00
parent f85284afb2
commit 5e86f7ee51
5 changed files with 13 additions and 37 deletions

View File

@ -82,17 +82,6 @@ namespace gtsam {
ADT::print("", formatter); ADT::print("", formatter);
} }
/* ************************************************************************ */
DiscreteFactor::shared_ptr DecisionTreeFactor::operator*(
const DiscreteFactor::shared_ptr& f) const {
if (auto derived = std::dynamic_pointer_cast<DecisionTreeFactor>(f)) {
return std::make_shared<DecisionTreeFactor>(this->operator*(*derived));
} else {
throw std::runtime_error(
"Cannot convert DiscreteFactor to DecisionTreeFactor");
}
}
/* ************************************************************************ */ /* ************************************************************************ */
DecisionTreeFactor DecisionTreeFactor::apply(Unary op) const { DecisionTreeFactor DecisionTreeFactor::apply(Unary op) const {
// apply operand // apply operand

View File

@ -145,13 +145,10 @@ namespace gtsam {
double error(const DiscreteValues& values) const override; double error(const DiscreteValues& values) const override;
/// multiply two factors /// multiply two factors
DecisionTreeFactor operator*(const DecisionTreeFactor& f) const { DecisionTreeFactor operator*(const DecisionTreeFactor& f) const override {
return apply(f, Ring::mul); return apply(f, Ring::mul);
} }
DiscreteFactor::shared_ptr operator*(
const DiscreteFactor::shared_ptr& f) const override;
static double safe_div(const double& a, const double& b); static double safe_div(const double& a, const double& b);
/// divide by factor f (safely) /// divide by factor f (safely)
@ -159,17 +156,6 @@ namespace gtsam {
return apply(f, safe_div); return apply(f, safe_div);
} }
/// divide by factor f (pointer version)
DiscreteFactor::shared_ptr operator/(
const DiscreteFactor::shared_ptr& f) const override {
if (auto derived = std::dynamic_pointer_cast<DecisionTreeFactor>(f)) {
return std::make_shared<DecisionTreeFactor>(apply(*derived, safe_div));
} else {
throw std::runtime_error(
"Cannot convert DiscreteFactor to Table Factor");
}
}
/// Convert into a decision tree /// Convert into a decision tree
DecisionTreeFactor toDecisionTreeFactor() const override { return *this; } DecisionTreeFactor toDecisionTreeFactor() const override { return *this; }

View File

@ -38,7 +38,8 @@ using std::vector;
namespace gtsam { namespace gtsam {
// Instantiate base class // Instantiate base class
template class GTSAM_EXPORT Conditional<DecisionTreeFactor, DiscreteConditional>; template class GTSAM_EXPORT
Conditional<DecisionTreeFactor, DiscreteConditional>;
/* ************************************************************************** */ /* ************************************************************************** */
DiscreteConditional::DiscreteConditional(const size_t nrFrontals, DiscreteConditional::DiscreteConditional(const size_t nrFrontals,
@ -152,11 +153,11 @@ void DiscreteConditional::print(const string& s,
/* ************************************************************************** */ /* ************************************************************************** */
bool DiscreteConditional::equals(const DiscreteFactor& other, bool DiscreteConditional::equals(const DiscreteFactor& other,
double tol) const { double tol) const {
if (!dynamic_cast<const DecisionTreeFactor*>(&other)) { if (!dynamic_cast<const BaseFactor*>(&other)) {
return false; return false;
} else { } else {
const DecisionTreeFactor& f(static_cast<const DecisionTreeFactor&>(other)); const BaseFactor& f(static_cast<const BaseFactor&>(other));
return DecisionTreeFactor::equals(f, tol); return BaseFactor::equals(f, tol);
} }
} }
@ -377,7 +378,7 @@ std::string DiscreteConditional::markdown(const KeyFormatter& keyFormatter,
ss << "*\n" << std::endl; ss << "*\n" << std::endl;
if (nrParents() == 0) { if (nrParents() == 0) {
// We have no parents, call factor method. // We have no parents, call factor method.
ss << DecisionTreeFactor::markdown(keyFormatter, names); ss << BaseFactor::markdown(keyFormatter, names);
return ss.str(); return ss.str();
} }
@ -429,7 +430,7 @@ string DiscreteConditional::html(const KeyFormatter& keyFormatter,
ss << "</i></p>\n"; ss << "</i></p>\n";
if (nrParents() == 0) { if (nrParents() == 0) {
// We have no parents, call factor method. // We have no parents, call factor method.
ss << DecisionTreeFactor::html(keyFormatter, names); ss << BaseFactor::html(keyFormatter, names);
return ss.str(); return ss.str();
} }

View File

@ -110,16 +110,16 @@ class GTSAM_EXPORT DiscreteConditional
* @brief construct P(X|Y) = f(X,Y)/f(Y) from f(X,Y) and f(Y) * @brief construct P(X|Y) = f(X,Y)/f(Y) from f(X,Y) and f(Y)
* Assumes but *does not check* that f(Y)=sum_X f(X,Y). * Assumes but *does not check* that f(Y)=sum_X f(X,Y).
*/ */
DiscreteConditional(const DiscreteFactor::shared_ptr& joint, DiscreteConditional(const DecisionTreeFactor& joint,
const DiscreteFactor::shared_ptr& marginal); const DecisionTreeFactor& marginal);
/** /**
* @brief construct P(X|Y) = f(X,Y)/f(Y) from f(X,Y) and f(Y) * @brief construct P(X|Y) = f(X,Y)/f(Y) from f(X,Y) and f(Y)
* Assumes but *does not check* that f(Y)=sum_X f(X,Y). * Assumes but *does not check* that f(Y)=sum_X f(X,Y).
* Makes sure the keys are ordered as given. Does not check orderedKeys. * Makes sure the keys are ordered as given. Does not check orderedKeys.
*/ */
DiscreteConditional(const DiscreteFactor::shared_ptr& joint, DiscreteConditional(const DecisionTreeFactor& joint,
const DiscreteFactor::shared_ptr& marginal, const DecisionTreeFactor& marginal,
const Ordering& orderedKeys); const Ordering& orderedKeys);
/** /**

View File

@ -47,7 +47,7 @@ void DiscreteLookupTable::print(const std::string& s,
} }
} }
cout << "):\n"; cout << "):\n";
ADT::print("", formatter); BaseFactor::print("", formatter);
cout << endl; cout << endl;
} }