scale product and sum so we don't get all 0s
parent
c8bafab430
commit
d4d95e2342
|
@ -125,11 +125,8 @@ namespace gtsam {
|
||||||
DiscreteFactor::shared_ptr product = this->product();
|
DiscreteFactor::shared_ptr product = this->product();
|
||||||
gttoc(product);
|
gttoc(product);
|
||||||
|
|
||||||
// Max over all the potentials by pretending all keys are frontal:
|
|
||||||
auto denominator = product->max(product->size());
|
|
||||||
|
|
||||||
// Normalize the product factor to prevent underflow.
|
// Normalize the product factor to prevent underflow.
|
||||||
product = product->operator/(denominator);
|
product = product->scale();
|
||||||
|
|
||||||
return product;
|
return product;
|
||||||
}
|
}
|
||||||
|
@ -222,6 +219,8 @@ namespace gtsam {
|
||||||
// sum out frontals, this is the factor on the separator
|
// sum out frontals, this is the factor on the separator
|
||||||
gttic(sum);
|
gttic(sum);
|
||||||
DiscreteFactor::shared_ptr sum = product->sum(frontalKeys);
|
DiscreteFactor::shared_ptr sum = product->sum(frontalKeys);
|
||||||
|
// Normalize/scale to prevent underflow.
|
||||||
|
sum = sum->scale();
|
||||||
gttoc(sum);
|
gttoc(sum);
|
||||||
|
|
||||||
// Ordering keys for the conditional so that frontalKeys are really in front
|
// Ordering keys for the conditional so that frontalKeys are really in front
|
||||||
|
|
Loading…
Reference in New Issue