remove extra calls to Unique

release/4.3a0
Varun Agrawal 2023-06-14 15:23:14 -04:00
parent 29c1816a81
commit 8959982686
2 changed files with 3 additions and 3 deletions

View File

@ -544,7 +544,7 @@ namespace gtsam {
template<typename L, typename Y> template<typename L, typename Y>
template<typename Iterator> DecisionTree<L, Y>::DecisionTree( template<typename Iterator> DecisionTree<L, Y>::DecisionTree(
Iterator begin, Iterator end, const L& label) { Iterator begin, Iterator end, const L& label) {
root_ = Choice::Unique(compose(begin, end, label)); root_ = compose(begin, end, label);
} }
/****************************************************************************/ /****************************************************************************/
@ -552,7 +552,7 @@ namespace gtsam {
DecisionTree<L, Y>::DecisionTree(const L& label, DecisionTree<L, Y>::DecisionTree(const L& label,
const DecisionTree& f0, const DecisionTree& f1) { const DecisionTree& f0, const DecisionTree& f1) {
const std::vector<DecisionTree> functions{f0, f1}; const std::vector<DecisionTree> functions{f0, f1};
root_ = Choice::Unique(compose(functions.begin(), functions.end(), label)); root_ = compose(functions.begin(), functions.end(), label);
} }
/****************************************************************************/ /****************************************************************************/
@ -603,6 +603,7 @@ namespace gtsam {
auto choiceOnLabel = std::make_shared<Choice>(label, end - begin); auto choiceOnLabel = std::make_shared<Choice>(label, end - begin);
for (Iterator it = begin; it != end; it++) for (Iterator it = begin; it != end; it++)
choiceOnLabel->push_back(it->root_); choiceOnLabel->push_back(it->root_);
// If no reordering, no need to call Choice::Unique
return choiceOnLabel; return choiceOnLabel;
} else { } else {
// Set up a new choice on the highest label // Set up a new choice on the highest label

View File

@ -400,7 +400,6 @@ factor 1: f[ (m0,2), (m1,2), (m2,2), (m3,2), ]
1, 1, 1, 1, 0.015366387, 0.0094115739, 1, 1, 1, 1, 1, 1, 0.015366387, 0.0094115739, 1, 1,
1, 1, 1, 1, 0.015366387, 0.0094115652, 0.015365663, 0.009321081}; 1, 1, 1, 1, 0.015366387, 0.0094115652, 0.015365663, 0.009321081};
DecisionTreeFactor f1(d1, p1); DecisionTreeFactor f1(d1, p1);
DecisionTree<Key, double> dt1(d1, p1);
DiscreteFactorGraph dfg; DiscreteFactorGraph dfg;
dfg.add(f0); dfg.add(f0);