use product method since it has a nullptr check
parent
77ba91bf52
commit
80b1fe569a
|
@ -66,8 +66,9 @@ namespace gtsam {
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
DecisionTreeFactor DiscreteFactorGraph::product() const {
|
DecisionTreeFactor DiscreteFactorGraph::product() const {
|
||||||
DecisionTreeFactor result;
|
DecisionTreeFactor result;
|
||||||
for(const sharedFactor& factor: *this)
|
for (const sharedFactor& factor : *this) {
|
||||||
if (factor) result = (*factor) * result;
|
if (factor) result = (*factor) * result;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,8 +76,9 @@ namespace gtsam {
|
||||||
double DiscreteFactorGraph::operator()(
|
double DiscreteFactorGraph::operator()(
|
||||||
const DiscreteValues &values) const {
|
const DiscreteValues &values) const {
|
||||||
double product = 1.0;
|
double product = 1.0;
|
||||||
for( const sharedFactor& factor: factors_ )
|
for (const sharedFactor& factor : factors_) {
|
||||||
product *= (*factor)(values);
|
product *= (*factor)(values);
|
||||||
|
}
|
||||||
return product;
|
return product;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,8 +119,7 @@ namespace gtsam {
|
||||||
const Ordering& frontalKeys) {
|
const Ordering& frontalKeys) {
|
||||||
// PRODUCT: multiply all factors
|
// PRODUCT: multiply all factors
|
||||||
gttic(product);
|
gttic(product);
|
||||||
DecisionTreeFactor product;
|
DecisionTreeFactor product = factors.product();
|
||||||
for (auto&& factor : factors) product = (*factor) * product;
|
|
||||||
gttoc(product);
|
gttoc(product);
|
||||||
|
|
||||||
// Max over all the potentials by pretending all keys are frontal:
|
// Max over all the potentials by pretending all keys are frontal:
|
||||||
|
@ -206,8 +207,7 @@ namespace gtsam {
|
||||||
const Ordering& frontalKeys) {
|
const Ordering& frontalKeys) {
|
||||||
// PRODUCT: multiply all factors
|
// PRODUCT: multiply all factors
|
||||||
gttic(product);
|
gttic(product);
|
||||||
DecisionTreeFactor product;
|
DecisionTreeFactor product = factors.product();
|
||||||
for (auto&& factor : factors) product = (*factor) * product;
|
|
||||||
gttoc(product);
|
gttoc(product);
|
||||||
|
|
||||||
// Max over all the potentials by pretending all keys are frontal:
|
// Max over all the potentials by pretending all keys are frontal:
|
||||||
|
|
Loading…
Reference in New Issue