simplify empty separator check

release/4.3a0
Varun Agrawal 2025-01-02 16:13:24 -05:00
parent 113492f8b5
commit 32317d4416
1 changed files with 4 additions and 8 deletions

View File

@ -348,16 +348,12 @@ discreteElimination(const HybridGaussianFactorGraph &factors,
#if GTSAM_HYBRID_TIMING #if GTSAM_HYBRID_TIMING
gttic_(EliminateDiscrete); gttic_(EliminateDiscrete);
#endif #endif
// Check if separator is empty // Check if separator is empty.
Ordering allKeys(dfg.keyVector()); // This is the same as checking if the number of frontal variables
Ordering separator; // is the same as the number of variables in the DiscreteFactorGraph.
std::set_difference(allKeys.begin(), allKeys.end(), frontalKeys.begin(),
frontalKeys.end(),
std::inserter(separator, separator.begin()));
// If the separator is empty, we have a clique of all the discrete variables // If the separator is empty, we have a clique of all the discrete variables
// so we can use the TableFactor for efficiency. // so we can use the TableFactor for efficiency.
if (separator.size() == 0) { if (frontalKeys.size() == dfg.keys().size()) {
// Get product factor // Get product factor
TableFactor product = TableProduct(dfg); TableFactor product = TableProduct(dfg);