clarify TableProduct function
parent
bb4ee207b8
commit
2894c957b1
|
|
@ -256,13 +256,12 @@ static TableFactor::shared_ptr DiscreteFactorFromErrors(
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Multiply all the `factors` and normalize the
|
* @brief Multiply all the `factors` using the machinery of the TableFactor.
|
||||||
* product to prevent underflow.
|
|
||||||
*
|
*
|
||||||
* @param factors The factors to multiply as a DiscreteFactorGraph.
|
* @param factors The factors to multiply as a DiscreteFactorGraph.
|
||||||
* @return TableFactor
|
* @return TableFactor
|
||||||
*/
|
*/
|
||||||
static TableFactor ProductAndNormalize(const DiscreteFactorGraph &factors) {
|
static TableFactor TableProduct(const DiscreteFactorGraph &factors) {
|
||||||
// PRODUCT: multiply all factors
|
// PRODUCT: multiply all factors
|
||||||
#if GTSAM_HYBRID_TIMING
|
#if GTSAM_HYBRID_TIMING
|
||||||
gttic_(DiscreteProduct);
|
gttic_(DiscreteProduct);
|
||||||
|
|
@ -282,14 +281,13 @@ static TableFactor ProductAndNormalize(const DiscreteFactorGraph &factors) {
|
||||||
gttoc_(DiscreteProduct);
|
gttoc_(DiscreteProduct);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Max over all the potentials by pretending all keys are frontal:
|
|
||||||
auto normalizer = product.max(product.size());
|
|
||||||
|
|
||||||
#if GTSAM_HYBRID_TIMING
|
#if GTSAM_HYBRID_TIMING
|
||||||
gttic_(DiscreteNormalize);
|
gttic_(DiscreteNormalize);
|
||||||
#endif
|
#endif
|
||||||
|
// 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 / (*normalizer);
|
product = product / (*denominator);
|
||||||
#if GTSAM_HYBRID_TIMING
|
#if GTSAM_HYBRID_TIMING
|
||||||
gttoc_(DiscreteNormalize);
|
gttoc_(DiscreteNormalize);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -352,7 +350,7 @@ discreteElimination(const HybridGaussianFactorGraph &factors,
|
||||||
// so we can use the TableFactor for efficiency.
|
// so we can use the TableFactor for efficiency.
|
||||||
if (separator.size() == 0) {
|
if (separator.size() == 0) {
|
||||||
// Get product factor
|
// Get product factor
|
||||||
TableFactor product = ProductAndNormalize(dfg);
|
TableFactor product = TableProduct(dfg);
|
||||||
|
|
||||||
#if GTSAM_HYBRID_TIMING
|
#if GTSAM_HYBRID_TIMING
|
||||||
gttic_(EliminateDiscreteFormDiscreteConditional);
|
gttic_(EliminateDiscreteFormDiscreteConditional);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue