From 0c292150180abe014b3051facce7187132d92b9b Mon Sep 17 00:00:00 2001 From: dellaert Date: Wed, 8 Jul 2015 19:14:23 -0700 Subject: [PATCH] Slight refactor/reformatting --- gtsam/nonlinear/ExpressionFactor.h | 20 ++++++++++++-------- gtsam/nonlinear/internal/JacobianMap.h | 7 +++---- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/gtsam/nonlinear/ExpressionFactor.h b/gtsam/nonlinear/ExpressionFactor.h index b32b84df3..cac55563f 100644 --- a/gtsam/nonlinear/ExpressionFactor.h +++ b/gtsam/nonlinear/ExpressionFactor.h @@ -32,7 +32,7 @@ namespace gtsam { template class ExpressionFactor: public NoiseModelFactor { - protected: +protected: typedef ExpressionFactor This; @@ -42,7 +42,7 @@ class ExpressionFactor: public NoiseModelFactor { static const int Dim = traits::dimension; - public: +public: typedef boost::shared_ptr > shared_ptr; @@ -83,13 +83,16 @@ class ExpressionFactor: public NoiseModelFactor { if (!active(x)) return boost::shared_ptr(); - // Create a writeable JacobianFactor in advance // In case noise model is constrained, we need to provide a noise model - bool constrained = noiseModel_->isConstrained(); + SharedDiagonal noiseModel; + if (noiseModel_->isConstrained()) { + noiseModel = boost::static_pointer_cast( + noiseModel_)->unit(); + } + + // Create a writeable JacobianFactor in advance boost::shared_ptr factor( - constrained ? new JacobianFactor(keys_, dims_, Dim, - boost::static_pointer_cast(noiseModel_)->unit()) : - new JacobianFactor(keys_, dims_, Dim)); + new JacobianFactor(keys_, dims_, Dim, noiseModel)); // Wrap keys and VerticalBlockMatrix into structure passed to expression_ VerticalBlockMatrix& Ab = factor->matrixObject(); @@ -114,7 +117,8 @@ class ExpressionFactor: public NoiseModelFactor { /// @return a deep copy of this factor virtual gtsam::NonlinearFactor::shared_ptr clone() const { return boost::static_pointer_cast( - gtsam::NonlinearFactor::shared_ptr(new This(*this))); } + gtsam::NonlinearFactor::shared_ptr(new This(*this))); + } }; // ExpressionFactor diff --git a/gtsam/nonlinear/internal/JacobianMap.h b/gtsam/nonlinear/internal/JacobianMap.h index f4d2e9565..c99f05b7d 100644 --- a/gtsam/nonlinear/internal/JacobianMap.h +++ b/gtsam/nonlinear/internal/JacobianMap.h @@ -31,19 +31,18 @@ namespace internal { // The JacobianMap provides a mapping from keys to the underlying blocks. class JacobianMap { private: - typedef FastVector Keys; - const FastVector& keys_; + const KeyVector& keys_; VerticalBlockMatrix& Ab_; public: /// Construct a JacobianMap for writing into a VerticalBlockMatrix Ab - JacobianMap(const Keys& keys, VerticalBlockMatrix& Ab) : + JacobianMap(const KeyVector& keys, VerticalBlockMatrix& Ab) : keys_(keys), Ab_(Ab) { } /// Access blocks of via key VerticalBlockMatrix::Block operator()(Key key) { - Keys::const_iterator it = std::find(keys_.begin(), keys_.end(), key); + KeyVector::const_iterator it = std::find(keys_.begin(), keys_.end(), key); DenseIndex block = it - keys_.begin(); return Ab_(block); }