diff --git a/gtsam/nonlinear/NonlinearEquality.h b/gtsam/nonlinear/NonlinearEquality.h index 243611433..47083d5d7 100644 --- a/gtsam/nonlinear/NonlinearEquality.h +++ b/gtsam/nonlinear/NonlinearEquality.h @@ -290,24 +290,19 @@ struct traits > * Simple binary equality constraint - this constraint forces two variables to * be the same. */ -template -class NonlinearEquality2: public NoiseModelFactor2 { -public: - typedef VALUE X; +template +class NonlinearEquality2 : public NoiseModelFactor2 { + protected: + using Base = NoiseModelFactor2; + using This = NonlinearEquality2; -protected: - typedef NoiseModelFactor2 Base; - typedef NonlinearEquality2 This; - - GTSAM_CONCEPT_MANIFOLD_TYPE(X) + GTSAM_CONCEPT_MANIFOLD_TYPE(T) /// Default constructor to allow for serialization - NonlinearEquality2() { - } + NonlinearEquality2() {} -public: - - typedef boost::shared_ptr > shared_ptr; + public: + typedef boost::shared_ptr> shared_ptr; /** * Constructor @@ -315,11 +310,10 @@ public: * @param key2 the key for the second unknown variable to be constrained * @param mu a parameter which really turns this into a strong prior */ - NonlinearEquality2(Key key1, Key key2, double mu = 1000.0) : - Base(noiseModel::Constrained::All(traits::dimension, std::abs(mu)), key1, key2) { - } - ~NonlinearEquality2() override { - } + NonlinearEquality2(Key key1, Key key2, double mu = 1e4) + : Base(noiseModel::Constrained::All(traits::dimension, std::abs(mu)), + key1, key2) {} + ~NonlinearEquality2() override {} /// @return a deep copy of this factor gtsam::NonlinearFactor::shared_ptr clone() const override { @@ -328,32 +322,30 @@ public: } /// g(x) with optional derivative2 - Vector evaluateError(const X& x1, const X& x2, boost::optional H1 = - boost::none, boost::optional H2 = boost::none) const override { - static const size_t p = traits::dimension; - if (H1) *H1 = -Matrix::Identity(p,p); - if (H2) *H2 = Matrix::Identity(p,p); - return traits::Local(x1,x2); + Vector evaluateError( + const T& x1, const T& x2, boost::optional H1 = boost::none, + boost::optional H2 = boost::none) const override { + static const size_t p = traits::dimension; + if (H1) *H1 = -Matrix::Identity(p, p); + if (H2) *H2 = Matrix::Identity(p, p); + return traits::Local(x1, x2); } GTSAM_MAKE_ALIGNED_OPERATOR_NEW -private: - + private: /// Serialization function friend class boost::serialization::access; - template - void serialize(ARCHIVE & ar, const unsigned int /*version*/) { - ar - & boost::serialization::make_nvp("NoiseModelFactor2", - boost::serialization::base_object(*this)); + template + void serialize(ARCHIVE& ar, const unsigned int /*version*/) { + ar& boost::serialization::make_nvp( + "NoiseModelFactor2", boost::serialization::base_object(*this)); } }; // \NonlinearEquality2 -template -struct traits > : Testable > { +template +struct traits> : Testable> { }; - }// namespace gtsam