diff --git a/gtsam_unstable/nonlinear/LinearContainerFactor.cpp b/gtsam_unstable/nonlinear/LinearContainerFactor.cpp index 8a27284f1..75cc171fb 100644 --- a/gtsam_unstable/nonlinear/LinearContainerFactor.cpp +++ b/gtsam_unstable/nonlinear/LinearContainerFactor.cpp @@ -141,6 +141,12 @@ GaussianFactor::shared_ptr LinearContainerFactor::negate(const Ordering& orderin return result; } +/* ************************************************************************* */ +NonlinearFactor::shared_ptr LinearContainerFactor::negate() const { + GaussianFactor::shared_ptr antifactor = factor_->negate(); // already has keys in place + return NonlinearFactor::shared_ptr(new LinearContainerFactor(antifactor)); +} + /* ************************************************************************* */ } // \namespace gtsam diff --git a/gtsam_unstable/nonlinear/LinearContainerFactor.h b/gtsam_unstable/nonlinear/LinearContainerFactor.h index 23705f96e..34da3a886 100644 --- a/gtsam_unstable/nonlinear/LinearContainerFactor.h +++ b/gtsam_unstable/nonlinear/LinearContainerFactor.h @@ -79,6 +79,14 @@ public: */ GaussianFactor::shared_ptr negate(const Ordering& ordering) const; + /** + * Creates the equivalent anti-factor as another LinearContainerFactor, + * so it remains independent of ordering. + */ + NonlinearFactor::shared_ptr negate() const; + + + /** * Creates a shared_ptr clone of the factor - needs to be specialized to allow * for subclasses