37 typedef NonlinearFactor::shared_ptr sharedFactor;
44 typedef boost::shared_ptr<AntiFactor> shared_ptr;
55 gtsam::NonlinearFactor::shared_ptr
clone()
const override {
56 return boost::static_pointer_cast<gtsam::NonlinearFactor>(
57 gtsam::NonlinearFactor::shared_ptr(
new This(*
this))); }
62 void print(
const std::string& s,
const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const override {
63 std::cout << s <<
"AntiFactor version of:" << std::endl;
64 factor_->print(s, keyFormatter);
69 const This *e =
dynamic_cast<const This*
> (&expected);
70 return e !=
nullptr &&
Base::equals(*e, tol) && this->factor_->equals(*e->factor_, tol);
80 double error(
const Values& c)
const override {
return -factor_->error(c); }
83 size_t dim()
const override {
return factor_->dim(); }
89 bool active(
const Values& c)
const override {
return factor_->active(c); }
103 return gaussianFactor->negate();
111 template<
class ARCHIVE>
112 void serialize(ARCHIVE & ar,
const unsigned int ) {
113 ar & boost::serialization::make_nvp(
"AntiFactor",
114 boost::serialization::base_object<Base>(*
this));
115 ar & BOOST_SERIALIZATION_NVP(factor_);
A factor with a quadratic error function - a Gaussian.
Non-linear factor base classes.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:35
This is the base class for all factor types.
Definition: Factor.h:56
const KeyVector & keys() const
Access the factor's involved variable keys.
Definition: Factor.h:125
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: GaussianFactor.h:42
Nonlinear factor base class.
Definition: NonlinearFactor.h:43
virtual bool equals(const NonlinearFactor &f, double tol=1e-9) const
Check if two factors are equal.
Definition: NonlinearFactor.cpp:36
A non-templated config holding any types of Manifold-group elements.
Definition: Values.h:63
Definition: AntiFactor.h:31
AntiFactor(NonlinearFactor::shared_ptr factor)
constructor - Creates the equivalent AntiFactor from an existing factor
Definition: AntiFactor.h:50
bool equals(const NonlinearFactor &expected, double tol=1e-9) const override
equals
Definition: AntiFactor.h:68
AntiFactor()
default constructor - only use for serialization
Definition: AntiFactor.h:47
boost::shared_ptr< GaussianFactor > linearize(const Values &c) const override
Linearize to a GaussianFactor.
Definition: AntiFactor.h:97
bool active(const Values &c) const override
Checks whether this factor should be used based on a set of values.
Definition: AntiFactor.h:89
size_t dim() const override
get the dimension of the factor (same as the original factor)
Definition: AntiFactor.h:83
void print(const std::string &s, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
implement functions needed for Testable
Definition: AntiFactor.h:62
double error(const Values &c) const override
implement functions needed to derive from Factor
Definition: AntiFactor.h:80
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition: AntiFactor.h:55
friend class boost::serialization::access
Serialization function.
Definition: AntiFactor.h:110