more robust product
parent
bc63cc8cb8
commit
713c49c915
|
@ -65,9 +65,16 @@ namespace gtsam {
|
||||||
|
|
||||||
/* ************************************************************************ */
|
/* ************************************************************************ */
|
||||||
DecisionTreeFactor DiscreteFactorGraph::product() const {
|
DecisionTreeFactor DiscreteFactorGraph::product() const {
|
||||||
DiscreteFactor::shared_ptr result = *this->begin();
|
DiscreteFactor::shared_ptr result;
|
||||||
for (auto it = this->begin() + 1; it != this->end(); ++it) {
|
for (auto it = this->begin(); it != this->end(); ++it) {
|
||||||
if (*it) result = result->multiply(*it);
|
if (*it) {
|
||||||
|
if (result) {
|
||||||
|
result = result->multiply(*it);
|
||||||
|
} else {
|
||||||
|
// Assign to the first non-null factor
|
||||||
|
result = *it;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result->toDecisionTreeFactor();
|
return result->toDecisionTreeFactor();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue