NiHu  2.0
fmm_operator.hpp
Go to the documentation of this file.
1 
7 #ifndef FMM_OPERATOR_HPP_INCLUDED
8 #define FMM_OPERATOR_HPP_INCLUDED
9 
10 #include <tuple>
11 #include <cstddef>
12 
13 namespace NiHu
14 {
15 namespace fmm
16 {
17 
18 namespace op_tags
19 {
20  struct m2m {};
21  struct l2l {};
22  struct m2l {};
23 
24  struct p2m {};
25  struct p2l {};
26  struct l2p {};
27  struct m2p {};
28 
29  struct p2p {};
30 
31  namespace internal
32  {
33  typedef std::tuple<m2m, l2l, m2l, p2m, p2l, l2p, m2p, p2p> op_tag_order;
34 
35  template <class T, class Tuple>
36  struct index;
37 
38  template <class T, class... Types>
39  struct index<T, std::tuple<T, Types...> >
40  {
41  static const size_t value = 0;
42  };
43 
44  template <class T, class U, class... Types>
45  struct index<T, std::tuple<U, Types...> >
46  {
47  static const size_t value = 1 + index<T, std::tuple<Types...>>::value;
48  };
49  }
50 
51  constexpr size_t num_tags()
52  {
53  return std::tuple_size<internal::op_tag_order>::value;
54  }
55 
56  template <class Tag>
57  constexpr size_t tag2idx(Tag const &tag = Tag())
58  {
59  return internal::index<Tag, internal::op_tag_order>::value;
60  }
61 
62  template <size_t idx>
63  struct idx2tag
64  {
65  typedef typename std::tuple_element<idx, internal::op_tag_order>::type type;
66  };
67 }
68 
73 typedef op_tags::l2l l2l_tag;
74 typedef op_tags::m2l m2l_tag;
75 
76 typedef op_tags::m2p m2p_tag;
77 typedef op_tags::l2p l2p_tag;
78 typedef op_tags::p2l p2l_tag;
79 typedef op_tags::p2m p2m_tag;
80 
81 typedef op_tags::p2p p2p_tag;
82 
84 template <class FmmTag>
86 {
87  typedef FmmTag fmm_tag;
88 };
89 
90 } // end of namespace fmm
91 } // end of namespace NiHu
92 
93 
94 #endif
NiHu::fmm::op_tags::m2l
Definition: fmm_operator.hpp:22
NiHu::fmm::op_tags::l2p
Definition: fmm_operator.hpp:26
NiHu::fmm::op_tags::p2l
Definition: fmm_operator.hpp:25
NiHu::fmm::op_tags::l2l
Definition: fmm_operator.hpp:21
NiHu::fmm::op_tags::p2m
Definition: fmm_operator.hpp:24
NiHu::fmm::op_tags::m2m
Definition: fmm_operator.hpp:20
NiHu::fmm::fmm_operator
Operator defining its tag type.
Definition: fmm_operator.hpp:85
NiHu::fmm::op_tags::p2p
Definition: fmm_operator.hpp:29
NiHu::fmm::op_tags::idx2tag
Definition: fmm_operator.hpp:63
NiHu::fmm::op_tags::m2p
Definition: fmm_operator.hpp:27