make GaussianMixtureFactor a subclass of HybridGaussianFactor

release/4.3a0
Varun Agrawal 2022-05-29 12:47:45 -04:00
parent 9cbd2ef477
commit 01b9a65e1e
2 changed files with 12 additions and 6 deletions

View File

@ -22,7 +22,7 @@
#include <gtsam/discrete/DecisionTree.h> #include <gtsam/discrete/DecisionTree.h>
#include <gtsam/discrete/DiscreteKey.h> #include <gtsam/discrete/DiscreteKey.h>
#include <gtsam/hybrid/HybridFactor.h> #include <gtsam/hybrid/HybridGaussianFactor.h>
#include <gtsam/linear/GaussianFactor.h> #include <gtsam/linear/GaussianFactor.h>
namespace gtsam { namespace gtsam {
@ -40,9 +40,9 @@ using GaussianFactorVector = std::vector<gtsam::GaussianFactor::shared_ptr>;
* of discrete variables indexes to the continuous gaussian distribution. * of discrete variables indexes to the continuous gaussian distribution.
* *
*/ */
class GaussianMixtureFactor : public HybridFactor { class GaussianMixtureFactor : public HybridGaussianFactor {
public: public:
using Base = HybridFactor; using Base = HybridGaussianFactor;
using This = GaussianMixtureFactor; using This = GaussianMixtureFactor;
using shared_ptr = boost::shared_ptr<This>; using shared_ptr = boost::shared_ptr<This>;
@ -93,7 +93,7 @@ class GaussianMixtureFactor : public HybridFactor {
bool equals(const HybridFactor &lf, double tol = 1e-9) const override; bool equals(const HybridFactor &lf, double tol = 1e-9) const override;
void print( void print(
const std::string &s = "HybridFactor\n", const std::string &s = "GaussianMixtureFactor\n",
const KeyFormatter &formatter = DefaultKeyFormatter) const override; const KeyFormatter &formatter = DefaultKeyFormatter) const override;
/// @} /// @}

View File

@ -27,7 +27,7 @@ namespace gtsam {
* A HybridGaussianFactor is a layer over GaussianFactor so that we do not have * A HybridGaussianFactor is a layer over GaussianFactor so that we do not have
* a diamond inheritance. * a diamond inheritance.
*/ */
class HybridGaussianFactor : public HybridFactor { class GTSAM_EXPORT HybridGaussianFactor : public HybridFactor {
private: private:
GaussianFactor::shared_ptr inner_; GaussianFactor::shared_ptr inner_;
@ -36,6 +36,12 @@ class HybridGaussianFactor : public HybridFactor {
using This = HybridGaussianFactor; using This = HybridGaussianFactor;
using shared_ptr = boost::shared_ptr<This>; using shared_ptr = boost::shared_ptr<This>;
HybridGaussianFactor() = default;
HybridGaussianFactor(const KeyVector &continuousKeys,
const DiscreteKeys &discreteKeys)
: Base(continuousKeys, discreteKeys) {}
// Explicit conversion from a shared ptr of GF // Explicit conversion from a shared ptr of GF
explicit HybridGaussianFactor(GaussianFactor::shared_ptr other); explicit HybridGaussianFactor(GaussianFactor::shared_ptr other);
@ -51,7 +57,7 @@ class HybridGaussianFactor : public HybridFactor {
/// GTSAM print utility. /// GTSAM print utility.
void print( void print(
const std::string &s = "HybridFactor\n", const std::string &s = "HybridGaussianFactor\n",
const KeyFormatter &formatter = DefaultKeyFormatter) const override; const KeyFormatter &formatter = DefaultKeyFormatter) const override;
/// @} /// @}