diff --git a/gtsam_unstable/nonlinear/tests/testExpressionFactor.cpp b/gtsam_unstable/nonlinear/tests/testExpressionFactor.cpp index 6441b78a6..d3f80d2a6 100644 --- a/gtsam_unstable/nonlinear/tests/testExpressionFactor.cpp +++ b/gtsam_unstable/nonlinear/tests/testExpressionFactor.cpp @@ -323,10 +323,10 @@ TEST(ExpressionFactor, composeTernary) { namespace mpl = boost::mpl; /// Recursive Trace Class -template +template struct Trace: More { // define dimensions - static const size_t m = 2; + static const size_t m = T::dimension; static const size_t n = A::dimension; // define fixed size Jacobian matrix types @@ -337,6 +337,19 @@ struct Trace: More { typename JacobianTrace::Pointer trace; JacobianTA dTdA; + /// Start the reverse AD process + virtual void startReverseAD(JacobianMap& jacobians) const { + Select::reverseAD(trace, dTdA, jacobians); + } + /// Given df/dT, multiply in dT/dA and continue reverse AD process + virtual void reverseAD(const Matrix& dFdT, JacobianMap& jacobians) const { + trace.reverseAD(dFdT * dTdA, jacobians); + } + /// Version specialized to 2-dimensional output + virtual void reverseAD2(const Jacobian2T& dFdT, + JacobianMap& jacobians) const { + trace.reverseAD2(dFdT * dTdA, jacobians); + } }; #include @@ -344,18 +357,19 @@ struct Trace: More { namespace MPL = mpl::placeholders; /// Recursive Trace Class Generator -template +template struct GenerateTrace { - typedef typename mpl::fold >::type type; + typedef typename mpl::fold, Trace >::type type; }; #include template struct Incomplete; typedef mpl::vector MyTypes; -typedef GenerateTrace::type Generated; -Incomplete incomplete; +typedef GenerateTrace::type Generated; +//Incomplete incomplete; BOOST_MPL_ASSERT((boost::is_same< Matrix25, Generated::JacobianTA >)); +BOOST_MPL_ASSERT((boost::is_same< Matrix2, Generated::Jacobian2T >)); Generated generated;