implement DiscreteFactor methods in Constraint

release/4.3a0
Varun Agrawal 2025-01-30 21:52:49 -05:00 committed by Frank Dellaert
parent 0d5b03d609
commit 64aa0520ed
1 changed files with 13 additions and 0 deletions

View File

@ -87,6 +87,16 @@ class GTSAM_UNSTABLE_EXPORT Constraint : public DiscreteFactor {
this->operator*(df->toDecisionTreeFactor()));
}
/// Multiply by a scalar
virtual DiscreteFactor::shared_ptr operator*(double s) const override {
return this->toDecisionTreeFactor() * s;
}
/// Multiply by a DecisionTreeFactor and return a DecisionTreeFactor
DecisionTreeFactor operator*(const DecisionTreeFactor& dtf) const override {
return this->toDecisionTreeFactor() * dtf;
}
/// divide by DiscreteFactor::shared_ptr f (safely)
DiscreteFactor::shared_ptr operator/(
const DiscreteFactor::shared_ptr& df) const override {
@ -104,6 +114,9 @@ class GTSAM_UNSTABLE_EXPORT Constraint : public DiscreteFactor {
return toDecisionTreeFactor().sum(keys);
}
/// Find the max value
double max() const override { return toDecisionTreeFactor().max(); }
DiscreteFactor::shared_ptr max(size_t nrFrontals) const override {
return toDecisionTreeFactor().max(nrFrontals);
}