diff --git a/gtsam_unstable/nonlinear/Expression-inl.h b/gtsam_unstable/nonlinear/Expression-inl.h index ac97de40e..30ab3ca4c 100644 --- a/gtsam_unstable/nonlinear/Expression-inl.h +++ b/gtsam_unstable/nonlinear/Expression-inl.h @@ -65,6 +65,7 @@ void move(JacobianMap& jacobians, std::vector& H) { */ template struct CallRecord { + static size_t const N = 0; virtual void print(const std::string& indent) const { } virtual void startReverseAD(JacobianMap& jacobians) const { @@ -205,12 +206,11 @@ struct Argument { * C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost * and Beyond. Pearson Education. */ -template -struct Record: Argument, More { +template +struct Record: Argument, More { typedef T return_type; - typedef typename AN::type A; - const static size_t N = AN::value; + static size_t const N = More::N + 1; typedef Argument This; /// Print to std::cout @@ -242,14 +242,6 @@ struct Record: Argument, More { } }; -/// Meta-function for generating a numbered type -template -struct Numbered { - typedef A type; - typedef size_t value_type; - static const size_t value = N; -}; - /// Recursive Record class Generator template struct GenerateRecord { @@ -559,7 +551,7 @@ public: } /// CallRecord structure for reverse AD - typedef boost::mpl::vector > Arguments; + typedef boost::mpl::vector Arguments; typedef typename GenerateRecord::type Record; /// Construct an execution trace for reverse AD @@ -636,7 +628,7 @@ public: } /// CallRecord structure for reverse AD - typedef boost::mpl::vector, Numbered > Arguments; + typedef boost::mpl::vector Arguments; typedef typename GenerateRecord::type Record; /// Construct an execution trace for reverse AD @@ -729,7 +721,7 @@ public: } /// CallRecord structure for reverse AD - typedef boost::mpl::vector, Numbered, Numbered > Arguments; + typedef boost::mpl::vector Arguments; typedef typename GenerateRecord::type Record; /// Construct an execution trace for reverse AD diff --git a/gtsam_unstable/nonlinear/tests/testExpressionFactor.cpp b/gtsam_unstable/nonlinear/tests/testExpressionFactor.cpp index 015a4ca6e..9b8c8bac3 100644 --- a/gtsam_unstable/nonlinear/tests/testExpressionFactor.cpp +++ b/gtsam_unstable/nonlinear/tests/testExpressionFactor.cpp @@ -262,11 +262,11 @@ TEST(ExpressionFactor, tree) { // Compare reverse and forward { - JacobianMap expectedMap; // via reverse - Point2 expectedValue = uv_hat.reverse(values, expectedMap); - Augmented actual = uv_hat.forward(values); - EXPECT(assert_equal(expectedValue, actual.value())); - EXPECT(actual.jacobians() == expectedMap); + JacobianMap expectedMap; // via reverse + Point2 expectedValue = uv_hat.reverse(values, expectedMap); + Augmented actual = uv_hat.forward(values); + EXPECT(assert_equal(expectedValue, actual.value())); + EXPECT(actual.jacobians() == expectedMap); } // Create factor and check value, dimension, linearization @@ -435,8 +435,7 @@ namespace mpl = boost::mpl; #include template struct Incomplete; -typedef mpl::vector, Numbered, - Numbered > MyTypes; +typedef mpl::vector MyTypes; typedef GenerateRecord::type Generated; //Incomplete incomplete; //BOOST_MPL_ASSERT((boost::is_same< Matrix25, Generated::JacobianTA >));