generalize DiscreteFactorGraph::product to DiscreteFactor
parent
a09b77ef40
commit
27bbce150a
|
|
@ -64,10 +64,16 @@ namespace gtsam {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
DecisionTreeFactor DiscreteFactorGraph::product() const {
|
DiscreteFactor::shared_ptr DiscreteFactorGraph::product() const {
|
||||||
DecisionTreeFactor result;
|
sharedFactor result = this->at(0);
|
||||||
for(const sharedFactor& factor: *this)
|
for (size_t i = 1; i < this->size(); ++i) {
|
||||||
if (factor) result = (*factor) * result;
|
const sharedFactor factor = this->at(i);
|
||||||
|
if (factor) {
|
||||||
|
// Predicated on the fact that all discrete factors are of a single type
|
||||||
|
// so there is no type-conversion happening which can be expensive.
|
||||||
|
result = result->operator*(factor);
|
||||||
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue