From d00aeb7e70d6ce2b3df11c9e800d543015896455 Mon Sep 17 00:00:00 2001 From: dellaert Date: Sat, 22 Nov 2014 21:48:36 +0100 Subject: [PATCH] Formatting and some small problems --- .../examples/Pose2SLAMExampleExpressions.cpp | 2 +- gtsam_unstable/nonlinear/CallRecord.h | 29 +++++++-------- gtsam_unstable/nonlinear/Expression-inl.h | 37 ++++++++----------- .../nonlinear/tests/testExpressionMeta.cpp | 1 - 4 files changed, 30 insertions(+), 39 deletions(-) diff --git a/gtsam_unstable/examples/Pose2SLAMExampleExpressions.cpp b/gtsam_unstable/examples/Pose2SLAMExampleExpressions.cpp index 936c9957b..ac43fa428 100644 --- a/gtsam_unstable/examples/Pose2SLAMExampleExpressions.cpp +++ b/gtsam_unstable/examples/Pose2SLAMExampleExpressions.cpp @@ -10,7 +10,7 @@ * -------------------------------------------------------------------------- */ /** - * @file Pose2SLAMExample.cpp + * @file Pose2SLAMExampleExpressions.cpp * @brief Expressions version of Pose2SLAMExample.cpp * @date Oct 2, 2014 * @author Frank Dellaert diff --git a/gtsam_unstable/nonlinear/CallRecord.h b/gtsam_unstable/nonlinear/CallRecord.h index 97fe74093..3806f1803 100644 --- a/gtsam_unstable/nonlinear/CallRecord.h +++ b/gtsam_unstable/nonlinear/CallRecord.h @@ -24,6 +24,8 @@ #include #include +#include + namespace gtsam { class JacobianMap; @@ -67,8 +69,7 @@ struct ConvertToDynamicRowsIf { * with Rows in 1..MaxSupportedStaticRows */ template -struct ReverseADInterface: ReverseADInterface { +struct ReverseADInterface: ReverseADInterface { using ReverseADInterface::_reverseAD; virtual void _reverseAD( const Eigen::Matrix & dFdT, @@ -92,19 +93,19 @@ template struct ReverseADImplementor: ReverseADImplementor { private: - using ReverseADImplementor::_reverseAD; + using ReverseADImplementor::_reverseAD; virtual void _reverseAD( const Eigen::Matrix & dFdT, JacobianMap& jacobians) const { static_cast(this)->reverseAD(dFdT, jacobians); } - friend struct internal::ReverseADImplementor; + friend struct internal::ReverseADImplementor; }; template -struct ReverseADImplementor - : virtual internal::ReverseADInterface { +struct ReverseADImplementor : virtual internal::ReverseADInterface< + MaxVirtualStaticRows, Cols> { private: using internal::ReverseADInterface::_reverseAD; const Derived & derived() const { @@ -131,8 +132,8 @@ private: * It is implemented in the function-style ExpressionNode's nested Record class below. */ template -struct CallRecord: virtual private internal::ReverseADInterface { +struct CallRecord: virtual private internal::ReverseADInterface< + MaxVirtualStaticRows, Cols> { inline void print(const std::string& indent) const { _print(indent); @@ -150,8 +151,7 @@ struct CallRecord: virtual private internal::ReverseADInterface::_reverseAD; + using internal::ReverseADInterface::_reverseAD; }; namespace internal { @@ -172,7 +171,7 @@ namespace internal { */ template struct CallRecordImplementor: public CallRecord, - private ReverseADImplementor { + private ReverseADImplementor { private: const Derived & derived() const { return static_cast(*this); @@ -183,7 +182,7 @@ private: virtual void _startReverseAD(JacobianMap& jacobians) const { derived().startReverseAD(jacobians); } - template friend class ReverseADImplementor; + template friend struct ReverseADImplementor; }; } // namespace internal diff --git a/gtsam_unstable/nonlinear/Expression-inl.h b/gtsam_unstable/nonlinear/Expression-inl.h index 40eb49def..a98ab349f 100644 --- a/gtsam_unstable/nonlinear/Expression-inl.h +++ b/gtsam_unstable/nonlinear/Expression-inl.h @@ -28,19 +28,10 @@ #include #include -// template meta-programming headers, TODO not all needed? -#include -#include -#include -#include +// template meta-programming headers #include -#include -#include -#include -#include namespace MPL = boost::mpl::placeholders; -// -//#include // for placement new + #include class ExpressionFactorBinaryTest; @@ -171,8 +162,9 @@ public: content.ptr->startReverseAD(jacobians); } // Either add to Jacobians (Leaf) or propagate (Function) - template - void reverseAD(const Eigen::MatrixBase & dTdA, JacobianMap& jacobians) const { + template + void reverseAD(const Eigen::MatrixBase & dTdA, + JacobianMap& jacobians) const { if (kind == Leaf) handleLeafCase(dTdA.eval(), jacobians, content.key); else if (kind == Function) @@ -435,7 +427,7 @@ struct FunctionalBase: ExpressionNode { } void startReverseAD(JacobianMap& jacobians) const { } - template + template void reverseAD(const SomeMatrix & dFdT, JacobianMap& jacobians) const { } }; @@ -511,8 +503,9 @@ struct GenerateFunctionalNode: Argument, Base { } /// Given df/dT, multiply in dT/dA and continue reverse AD process - template - void reverseAD(const Eigen::Matrix & dFdT, JacobianMap& jacobians) const { + template + void reverseAD(const Eigen::Matrix & dFdT, + JacobianMap& jacobians) const { Base::Record::reverseAD(dFdT, jacobians); This::trace.reverseAD(dFdT * This::dTdA, jacobians); } @@ -571,14 +564,14 @@ struct FunctionalNode { /// Provide convenience access to Record storage and implement /// the virtual function based interface of CallRecord using the CallRecordImplementor - struct Record: - public internal::CallRecordImplementor::value>, - public Base::Record { + struct Record: public internal::CallRecordImplementor::value>, public Base::Record { using Base::Record::print; using Base::Record::startReverseAD; using Base::Record::reverseAD; - virtual ~Record(){} + virtual ~Record() { + } /// Access Value template @@ -690,8 +683,8 @@ public: virtual T value(const Values& values) const { using boost::none; return function_(this->template expression()->value(values), - this->template expression()->value(values), - none, none); + this->template expression()->value(values), + none, none); } /// Construct an execution trace for reverse AD diff --git a/gtsam_unstable/nonlinear/tests/testExpressionMeta.cpp b/gtsam_unstable/nonlinear/tests/testExpressionMeta.cpp index b2cdcdf34..d10e31002 100644 --- a/gtsam_unstable/nonlinear/tests/testExpressionMeta.cpp +++ b/gtsam_unstable/nonlinear/tests/testExpressionMeta.cpp @@ -38,7 +38,6 @@ template struct Incomplete; typedef mpl::vector MyTypes; typedef FunctionalNode::type Generated; //Incomplete incomplete; -BOOST_MPL_ASSERT((boost::is_same< Matrix2, Generated::Record::Jacobian2T >)); // Try generating vectors of ExecutionTrace typedef mpl::vector, ExecutionTrace > ExpectedTraces;