Add Testable to GraphAndConstant

release/4.3a0
Frank Dellaert 2023-01-01 11:43:09 -05:00
parent 039c9b91c9
commit 526da2c892
1 changed files with 17 additions and 0 deletions

View File

@ -83,6 +83,19 @@ class GTSAM_EXPORT GaussianMixtureFactor : public HybridFactor {
bool operator==(const GraphAndConstant &other) const {
return graph == other.graph && constant == other.constant;
}
// Implement GTSAM-style print:
void print(const std::string &s = "Graph: ",
const KeyFormatter &formatter = DefaultKeyFormatter) const {
graph.print(s, formatter);
std::cout << "Constant: " << constant << std::endl;
}
// Implement GTSAM-style equals:
bool equals(const GraphAndConstant &other, double tol = 1e-9) const {
return graph.equals(other.graph, tol) &&
fabs(constant - other.constant) < tol;
}
};
using Sum = DecisionTree<Key, GraphAndConstant>;
@ -200,4 +213,8 @@ template <>
struct traits<GaussianMixtureFactor> : public Testable<GaussianMixtureFactor> {
};
template <>
struct traits<GaussianMixtureFactor::GraphAndConstant>
: public Testable<GaussianMixtureFactor::GraphAndConstant> {};
} // namespace gtsam