Add forwarding constructors and document better.
parent
6b2a8a9323
commit
9787bba22e
|
|
@ -16,20 +16,30 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gtsam/hybrid/HybridGaussianFactor.h>
|
#include <gtsam/hybrid/HybridGaussianFactor.h>
|
||||||
|
#include <gtsam/linear/HessianFactor.h>
|
||||||
|
#include <gtsam/linear/JacobianFactor.h>
|
||||||
|
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
HybridGaussianFactor::HybridGaussianFactor(GaussianFactor::shared_ptr other)
|
HybridGaussianFactor::HybridGaussianFactor(
|
||||||
: Base(other->keys()), inner_(other) {}
|
const boost::shared_ptr<GaussianFactor> &ptr)
|
||||||
|
: Base(ptr->keys()), inner_(ptr) {}
|
||||||
|
|
||||||
|
HybridGaussianFactor::HybridGaussianFactor(
|
||||||
|
boost::shared_ptr<GaussianFactor> &&ptr)
|
||||||
|
: Base(ptr->keys()), inner_(std::move(ptr)) {}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
|
||||||
HybridGaussianFactor::HybridGaussianFactor(JacobianFactor &&jf)
|
HybridGaussianFactor::HybridGaussianFactor(JacobianFactor &&jf)
|
||||||
: Base(jf.keys()),
|
: Base(jf.keys()),
|
||||||
inner_(boost::make_shared<JacobianFactor>(std::move(jf))) {}
|
inner_(boost::make_shared<JacobianFactor>(std::move(jf))) {}
|
||||||
|
|
||||||
|
HybridGaussianFactor::HybridGaussianFactor(HessianFactor &&hf)
|
||||||
|
: Base(hf.keys()),
|
||||||
|
inner_(boost::make_shared<HessianFactor>(std::move(hf))) {}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
bool HybridGaussianFactor::equals(const HybridFactor &other, double tol) const {
|
bool HybridGaussianFactor::equals(const HybridFactor &other, double tol) const {
|
||||||
const This *e = dynamic_cast<const This *>(&other);
|
const This *e = dynamic_cast<const This *>(&other);
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,13 @@
|
||||||
|
|
||||||
#include <gtsam/hybrid/HybridFactor.h>
|
#include <gtsam/hybrid/HybridFactor.h>
|
||||||
#include <gtsam/linear/GaussianFactor.h>
|
#include <gtsam/linear/GaussianFactor.h>
|
||||||
#include <gtsam/linear/JacobianFactor.h>
|
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
|
// Forward declarations
|
||||||
|
class JacobianFactor;
|
||||||
|
class HessianFactor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 i.e. an extra factor type that inherits from both
|
* a diamond inheritance i.e. an extra factor type that inherits from both
|
||||||
|
|
@ -41,12 +44,41 @@ class GTSAM_EXPORT HybridGaussianFactor : public HybridFactor {
|
||||||
|
|
||||||
HybridGaussianFactor() = default;
|
HybridGaussianFactor() = default;
|
||||||
|
|
||||||
// Explicit conversion from a shared ptr of GF
|
/**
|
||||||
explicit HybridGaussianFactor(GaussianFactor::shared_ptr other);
|
* Constructor from shared_ptr of GaussianFactor.
|
||||||
|
* Example:
|
||||||
|
* boost::shared_ptr<GaussianFactor> ptr =
|
||||||
|
* boost::make_shared<JacobianFactor>(...);
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
explicit HybridGaussianFactor(const boost::shared_ptr<GaussianFactor> &ptr);
|
||||||
|
|
||||||
// Forwarding constructor from concrete JacobianFactor
|
/**
|
||||||
|
* Forwarding constructor from shared_ptr of GaussianFactor.
|
||||||
|
* Examples:
|
||||||
|
* HybridGaussianFactor factor = boost::make_shared<JacobianFactor>(...);
|
||||||
|
* HybridGaussianFactor factor(boost::make_shared<JacobianFactor>(...));
|
||||||
|
*/
|
||||||
|
explicit HybridGaussianFactor(boost::shared_ptr<GaussianFactor> &&ptr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forwarding constructor from rvalue reference of JacobianFactor.
|
||||||
|
*
|
||||||
|
* Examples:
|
||||||
|
* HybridGaussianFactor factor = JacobianFactor(...);
|
||||||
|
* HybridGaussianFactor factor(JacobianFactor(...));
|
||||||
|
*/
|
||||||
explicit HybridGaussianFactor(JacobianFactor &&jf);
|
explicit HybridGaussianFactor(JacobianFactor &&jf);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forwarding constructor from rvalue reference of JacobianFactor.
|
||||||
|
*
|
||||||
|
* Examples:
|
||||||
|
* HybridGaussianFactor factor = HessianFactor(...);
|
||||||
|
* HybridGaussianFactor factor(HessianFactor(...));
|
||||||
|
*/
|
||||||
|
explicit HybridGaussianFactor(HessianFactor &&hf);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// @name Testable
|
/// @name Testable
|
||||||
/// @{
|
/// @{
|
||||||
|
|
|
||||||
|
|
@ -394,7 +394,7 @@ void HybridGaussianFactorGraph::add(JacobianFactor &&factor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************ */
|
/* ************************************************************************ */
|
||||||
void HybridGaussianFactorGraph::add(JacobianFactor::shared_ptr factor) {
|
void HybridGaussianFactorGraph::add(boost::shared_ptr<JacobianFactor> &factor) {
|
||||||
FactorGraph::add(boost::make_shared<HybridGaussianFactor>(factor));
|
FactorGraph::add(boost::make_shared<HybridGaussianFactor>(factor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ class HybridEliminationTree;
|
||||||
class HybridBayesTree;
|
class HybridBayesTree;
|
||||||
class HybridJunctionTree;
|
class HybridJunctionTree;
|
||||||
class DecisionTreeFactor;
|
class DecisionTreeFactor;
|
||||||
|
|
||||||
class JacobianFactor;
|
class JacobianFactor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -130,7 +129,7 @@ class GTSAM_EXPORT HybridGaussianFactorGraph
|
||||||
void add(JacobianFactor&& factor);
|
void add(JacobianFactor&& factor);
|
||||||
|
|
||||||
/// Add a Jacobian factor as a shared ptr.
|
/// Add a Jacobian factor as a shared ptr.
|
||||||
void add(JacobianFactor::shared_ptr factor);
|
void add(boost::shared_ptr<JacobianFactor>& factor);
|
||||||
|
|
||||||
/// Add a DecisionTreeFactor to the factor graph.
|
/// Add a DecisionTreeFactor to the factor graph.
|
||||||
void add(DecisionTreeFactor&& factor);
|
void add(DecisionTreeFactor&& factor);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue