NiHu  2.0
fmm_indexed.hpp
Go to the documentation of this file.
1 
7 #ifndef NIHU_FMM_INDEXED_HPP_INCLUDED
8 #define NIHU_FMM_INDEXED_HPP_INCLUDED
9 
10 #include "cluster_tree.hpp"
11 #include "p2x_cluster_indexed.hpp"
12 #include "p2x_indexed.hpp"
13 #include "x2p_cluster_indexed.hpp"
14 #include "x2p_indexed.hpp"
15 #include "p2p_indexed.hpp"
16 #include "x2x_cluster_indexed.hpp"
17 
18 
19 #include <type_traits>
20 
21 namespace NiHu
22 {
23 namespace fmm
24 {
25 
26 template <class Op, class FmmTag = typename std::decay<Op>::type::fmm_tag>
27 class indexed;
28 
29 template <class Op>
30 class indexed<Op, m2l_tag> {
31 public:
32  template <class TestIt, class TrialIt, class ClusterDerived>
33  static auto eval(Op &&op, TestIt test_begin, TestIt test_end, TrialIt trial_begin, TrialIt trial_end, cluster_tree<ClusterDerived> const &tree)
34  {
35  return create_x2x_cluster_indexed(std::forward<Op>(op), tree);
36  }
37 };
38 
39 template <class Op>
40 class indexed<Op, l2l_tag> {
41 public:
42  template <class TestIt, class TrialIt, class ClusterDerived>
43  static auto eval(Op &&op, TestIt test_begin, TestIt test_end, TrialIt trial_begin, TrialIt trial_end, cluster_tree<ClusterDerived> const &tree)
44  {
45  return create_x2x_cluster_indexed(std::forward<Op>(op), tree);
46  }
47 };
48 
49 template <class Op>
50 class indexed<Op, m2m_tag> {
51 public:
52  template <class TestIt, class TrialIt, class ClusterDerived>
53  static auto eval(Op &&op, TestIt test_begin, TestIt test_end, TrialIt trial_begin, TrialIt trial_end, cluster_tree<ClusterDerived> const &tree)
54  {
55  return create_x2x_cluster_indexed(std::forward<Op>(op), tree);
56  }
57 };
58 
59 
60 template <class Op>
61 class indexed<Op, m2p_tag> {
62 public:
63  template <class TestIt, class TrialIt, class ClusterDerived>
64  static auto eval(Op &&op, TestIt test_begin, TestIt test_end, TrialIt trial_begin, TrialIt trial_end, cluster_tree<ClusterDerived> const &tree)
65  {
66  return create_x2p_cluster_indexed(
67  create_x2p_indexed(
68  std::forward<Op>(op),
69  test_begin, test_end
70  ), tree);
71  }
72 };
73 
74 
75 template <class Op>
76 class indexed<Op, l2p_tag> {
77 public:
78  template <class TestIt, class TrialIt, class ClusterDerived>
79  static auto eval(Op &&op, TestIt test_begin, TestIt test_end, TrialIt trial_begin, TrialIt trial_end, cluster_tree<ClusterDerived> const &tree)
80  {
81  return create_x2p_cluster_indexed(
82  create_x2p_indexed(
83  std::forward<Op>(op),
84  test_begin, test_end
85  ), tree);
86  }
87 };
88 
89 
90 template <class Op>
91 class indexed<Op, p2m_tag> {
92 public:
93  template <class TestIt, class TrialIt, class ClusterDerived>
94  static auto eval(Op &&op, TestIt test_begin, TestIt test_end, TrialIt trial_begin, TrialIt trial_end, cluster_tree<ClusterDerived> const &tree)
95  {
96  return create_p2x_cluster_indexed(
97  create_p2x_indexed(
98  std::forward<Op>(op),
99  trial_begin, trial_end
100  ), tree);
101  }
102 };
103 
104 
105 template <class Op>
106 class indexed<Op, p2l_tag> {
107 public:
108  template <class TestIt, class TrialIt, class ClusterDerived>
109  static auto eval(Op &&op, TestIt test_begin, TestIt test_end, TrialIt trial_begin, TrialIt trial_end, cluster_tree<ClusterDerived> const &tree)
110  {
111  return create_p2x_cluster_indexed(
112  create_p2x_indexed(
113  std::forward<Op>(op),
114  trial_begin, trial_end
115  ), tree);
116  }
117 };
118 
119 
120 template <class Op>
121 class indexed<Op, p2p_tag> {
122 public:
123  template <class TestIt, class TrialIt, class ClusterDerived>
124  static auto eval(Op &&op, TestIt test_begin, TestIt test_end, TrialIt trial_begin, TrialIt trial_end, cluster_tree<ClusterDerived> const &)
125  {
126  return create_p2p_indexed(
127  std::forward<Op>(op),
128  test_begin, test_end,
129  trial_begin, trial_end);
130  }
131 };
132 
133 
134 
135 
136 template <class Op, class TestIt, class TrialIt, class ClusterDerived>
137 auto create_indexed(Op &&op, TestIt test_begin, TestIt test_end, TrialIt trial_begin, TrialIt trial_end, cluster_tree<ClusterDerived> const &tree)
138 {
139  return indexed<Op>::eval(std::forward<Op>(op), test_begin, test_end, trial_begin, trial_end, tree);
140 }
141 
142 
143 template <class TestIt, class TrialIt, class ClusterDerived>
145 {
146  indexed_functor(TestIt test_begin, TestIt test_end,
147  TrialIt trial_begin, TrialIt trial_end,
148  cluster_tree<ClusterDerived> const &tree)
149  : m_test_begin(test_begin)
150  , m_test_end(test_end)
151  , m_trial_begin(trial_begin)
152  , m_trial_end(trial_end)
153  , m_tree(tree)
154  {
155  }
156 
157  template <class Op>
158  auto operator()(Op &&op) const
159  {
160  return create_indexed(std::forward<Op>(op), m_test_begin, m_test_end, m_trial_begin, m_trial_end, m_tree);
161  }
162 
163  TestIt m_test_begin, m_test_end;
164  TrialIt m_trial_begin, m_trial_end;
165  cluster_tree<ClusterDerived> const &m_tree;
166 };
167 
168 template <class TestIt, class TrialIt, class ClusterDerived>
170 create_indexed_functor(TestIt test_begin, TestIt test_end,
171  TrialIt trial_begin, TrialIt trial_end,
172  cluster_tree<ClusterDerived> const &tree)
173 {
175  test_begin, test_end, trial_begin, trial_end,
176  tree);
177 }
178 
179 } // end of namespace fmm
180 } // end of namespace NiHu
181 
182 #endif /* NIHU_FMM_INDEXED_HPP_INCLUDED */
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::cluster_tree
Class representing a cluster tree.
Definition: cluster_tree.hpp:33
NiHu::fmm::op_tags::p2m
Definition: fmm_operator.hpp:24
NiHu::fmm::op_tags::m2m
Definition: fmm_operator.hpp:20
cluster_tree.hpp
Implementation of class NiHu::fmm::cluster_tree.
p2x_indexed.hpp
Implementation of class NiHu::fmm::p2x_indexed.
x2p_indexed.hpp
Leaf indexing of M2P and L2P operators.
NiHu::fmm::indexed
Definition: fmm_indexed.hpp:27
NiHu::fmm::op_tags::p2p
Definition: fmm_operator.hpp:29
x2x_cluster_indexed.hpp
Implementation of class template NiHu::fmm::x2x_cluster_indexed.
NiHu::fmm::indexed_functor
Definition: fmm_indexed.hpp:144
p2x_cluster_indexed.hpp
Cluster indexing for P2M and P2L operators.
x2p_cluster_indexed.hpp
M2P and L2P cluster indexing.
NiHu::fmm::op_tags::m2p
Definition: fmm_operator.hpp:27