Small change in meta-programming, big improvement in clarity
parent
107bcd8bb4
commit
408be628d2
|
@ -65,6 +65,7 @@ void move(JacobianMap& jacobians, std::vector<Matrix>& H) {
|
||||||
*/
|
*/
|
||||||
template<int COLS>
|
template<int COLS>
|
||||||
struct CallRecord {
|
struct CallRecord {
|
||||||
|
static size_t const N = 0;
|
||||||
virtual void print(const std::string& indent) const {
|
virtual void print(const std::string& indent) const {
|
||||||
}
|
}
|
||||||
virtual void startReverseAD(JacobianMap& jacobians) const {
|
virtual void startReverseAD(JacobianMap& jacobians) const {
|
||||||
|
@ -205,12 +206,11 @@ struct Argument {
|
||||||
* C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost
|
* C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost
|
||||||
* and Beyond. Pearson Education.
|
* and Beyond. Pearson Education.
|
||||||
*/
|
*/
|
||||||
template<class T, class AN, class More>
|
template<class T, class A, class More>
|
||||||
struct Record: Argument<T, typename AN::type, AN::value>, More {
|
struct Record: Argument<T, A, More::N+1>, More {
|
||||||
|
|
||||||
typedef T return_type;
|
typedef T return_type;
|
||||||
typedef typename AN::type A;
|
static size_t const N = More::N + 1;
|
||||||
const static size_t N = AN::value;
|
|
||||||
typedef Argument<T, A, N> This;
|
typedef Argument<T, A, N> This;
|
||||||
|
|
||||||
/// Print to std::cout
|
/// Print to std::cout
|
||||||
|
@ -242,14 +242,6 @@ struct Record: Argument<T, typename AN::type, AN::value>, More {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Meta-function for generating a numbered type
|
|
||||||
template<class A, size_t N>
|
|
||||||
struct Numbered {
|
|
||||||
typedef A type;
|
|
||||||
typedef size_t value_type;
|
|
||||||
static const size_t value = N;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Recursive Record class Generator
|
/// Recursive Record class Generator
|
||||||
template<class T, class TYPES>
|
template<class T, class TYPES>
|
||||||
struct GenerateRecord {
|
struct GenerateRecord {
|
||||||
|
@ -559,7 +551,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// CallRecord structure for reverse AD
|
/// CallRecord structure for reverse AD
|
||||||
typedef boost::mpl::vector<Numbered<A1, 1> > Arguments;
|
typedef boost::mpl::vector<A1> Arguments;
|
||||||
typedef typename GenerateRecord<T, Arguments>::type Record;
|
typedef typename GenerateRecord<T, Arguments>::type Record;
|
||||||
|
|
||||||
/// Construct an execution trace for reverse AD
|
/// Construct an execution trace for reverse AD
|
||||||
|
@ -636,7 +628,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// CallRecord structure for reverse AD
|
/// CallRecord structure for reverse AD
|
||||||
typedef boost::mpl::vector<Numbered<A1, 1>, Numbered<A2, 2> > Arguments;
|
typedef boost::mpl::vector<A1, A2> Arguments;
|
||||||
typedef typename GenerateRecord<T, Arguments>::type Record;
|
typedef typename GenerateRecord<T, Arguments>::type Record;
|
||||||
|
|
||||||
/// Construct an execution trace for reverse AD
|
/// Construct an execution trace for reverse AD
|
||||||
|
@ -729,7 +721,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// CallRecord structure for reverse AD
|
/// CallRecord structure for reverse AD
|
||||||
typedef boost::mpl::vector<Numbered<A1, 1>, Numbered<A2, 2>, Numbered<A3, 3> > Arguments;
|
typedef boost::mpl::vector<A1, A2, A3> Arguments;
|
||||||
typedef typename GenerateRecord<T, Arguments>::type Record;
|
typedef typename GenerateRecord<T, Arguments>::type Record;
|
||||||
|
|
||||||
/// Construct an execution trace for reverse AD
|
/// Construct an execution trace for reverse AD
|
||||||
|
|
|
@ -435,8 +435,7 @@ namespace mpl = boost::mpl;
|
||||||
#include <boost/mpl/assert.hpp>
|
#include <boost/mpl/assert.hpp>
|
||||||
template<class T> struct Incomplete;
|
template<class T> struct Incomplete;
|
||||||
|
|
||||||
typedef mpl::vector<Numbered<Pose3, 1>, Numbered<Point3, 2>,
|
typedef mpl::vector<Pose3, Point3, Cal3_S2> MyTypes;
|
||||||
Numbered<Cal3_S2, 3> > MyTypes;
|
|
||||||
typedef GenerateRecord<Point2, MyTypes>::type Generated;
|
typedef GenerateRecord<Point2, MyTypes>::type Generated;
|
||||||
//Incomplete<Generated> incomplete;
|
//Incomplete<Generated> incomplete;
|
||||||
//BOOST_MPL_ASSERT((boost::is_same< Matrix25, Generated::JacobianTA >));
|
//BOOST_MPL_ASSERT((boost::is_same< Matrix25, Generated::JacobianTA >));
|
||||||
|
|
Loading…
Reference in New Issue