NiHu  2.0
materialize_sequence.hpp
1 #ifndef NIHU_MATERIALIZE_SEQUENCE_HPP_INCLUDED
2 #define NIHU_MATERIALIZE_SEQUENCE_HPP_INCLUDED
3 
4 #include "tmp/algorithm.hpp"
5 #include "Eigen/Dense"
6 
7 namespace NiHu
8 {
9 
10 template <class Seq>
12 {
13  static unsigned const size = tmp::size<Seq>::value;
14  typedef typename tmp::deref<typename tmp::begin<Seq>::type>::type::value_type scalar_t;
15  typedef Eigen::Matrix<scalar_t, size, 1> eigen_vector_t;
16 
17  template <class Iter, class Dummy = void>
18  struct insert
19  {
20  static void apply(eigen_vector_t &vec, unsigned int pos)
21  {
23  insert<typename tmp::next<Iter>::type, Dummy>::apply(vec, pos+1);
24  }
25  };
26 
27  template <class Dummy>
28  struct insert<typename tmp::end<Seq>::type, Dummy>
29  {
30  static void apply(eigen_vector_t &vec, unsigned int pos)
31  {
32 
33  }
34  };
35 
36  static eigen_vector_t materialize()
37  {
38  eigen_vector_t result;
39  insert<typename tmp::begin<Seq>::type>::apply(result, 0);
40  return result;
41  }
42 
43 };
44 
45 template <class Seq>
46 typename sequence_materializer<Seq>::eigen_vector_t materialize_sequence(Seq const&)
47 {
48  return sequence_materializer<Seq>::materialize();
49 }
50 
51 } // namespace NiHu
52 
53 #endif /* NIHU_MATERIALIZE_SEQUENCE_HPP_INCLUDED */
tmp::deref
metafunction to dereference an iterator
Definition: sequence.hpp:114
tmp
template metaprogramming functions
Definition: asymptotic_types.hpp:101
algorithm.hpp
vectoralgorithms
tmp::size
return size
Definition: sequence.hpp:69
NiHu::sequence_materializer::insert
Definition: materialize_sequence.hpp:18
NiHu::sequence_materializer
Definition: materialize_sequence.hpp:11