From bac1faa68e86ae311eb066a39861b98f98b38b03 Mon Sep 17 00:00:00 2001 From: Alex Cunningham Date: Mon, 20 Aug 2012 18:28:19 +0000 Subject: [PATCH] Added ordering-less negate() --- gtsam_unstable/nonlinear/LinearContainerFactor.cpp | 6 ++++++ gtsam_unstable/nonlinear/LinearContainerFactor.h | 8 ++++++++ 2 files changed, 14 insertions(+) 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