Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dellaert committed Oct 23, 2024
1 parent 2c9665f commit 977ac0d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 2 additions & 5 deletions gtsam/hybrid/HybridGaussianConditional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,7 @@ std::shared_ptr<HybridGaussianFactor> HybridGaussianConditional::likelihood(
if (auto conditional =
std::dynamic_pointer_cast<GaussianConditional>(pair.first)) {
const auto likelihood_m = conditional->likelihood(given);
// scalar is already correct.
assert(pair.second ==
conditional->negLogConstant() - negLogConstant_);
// pair.second == conditional->negLogConstant() - negLogConstant_
return {likelihood_m, pair.second};
} else {
return {nullptr, std::numeric_limits<double>::infinity()};
Expand Down Expand Up @@ -320,8 +318,7 @@ HybridGaussianConditional::shared_ptr HybridGaussianConditional::prune(
};

FactorValuePairs prunedConditionals = factors().apply(pruner);
return std::shared_ptr<HybridGaussianConditional>(
new HybridGaussianConditional(discreteKeys(), prunedConditionals));
return std::make_shared<HybridGaussianConditional>(discreteKeys(), prunedConditionals);
}

/* *******************************************************************************/
Expand Down
4 changes: 3 additions & 1 deletion gtsam/hybrid/HybridGaussianFactorGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,16 @@ HybridGaussianFactorGraph::eliminate(const Ordering &keys) const {
// any difference in noise models used.
HybridGaussianProductFactor productFactor = collectProductFactor();

auto isNull = [](const GaussianFactor::shared_ptr& ptr) { return !ptr; };
auto isNull = [](const GaussianFactor::shared_ptr &ptr) { return !ptr; };

// This is the elimination method on the leaf nodes
bool someContinuousLeft = false;
auto eliminate =
[&](const std::pair<GaussianFactorGraph, double> &pair) -> Result {
const auto &[graph, scalar] = pair;

// If any product contains a pruned factor, prune it here. Done here as it's
// non non-trivial to do within collectProductFactor.
if (graph.empty() || std::any_of(graph.begin(), graph.end(), isNull)) {
return {nullptr, 0.0, nullptr, 0.0};
}
Expand Down

0 comments on commit 977ac0d

Please sign in to comment.