NiHu  2.0
x2p_indexed.hpp
Go to the documentation of this file.
1 
7 #ifndef NIHU_X2P_INDEXED_HPP_INCLUDED
8 #define NIHU_X2P_INDEXED_HPP_INCLUDED
9 
10 #include "fmm_operator.hpp"
11 #include <type_traits>
12 
13 namespace NiHu
14 {
15 namespace fmm
16 {
17 
18 template <class Operator, class It>
20  : public fmm_operator<typename std::decay<Operator>::type::fmm_tag>
21 {
22 public:
23  typedef typename std::decay<Operator>::type operator_t;
24  typedef It iterator_t;
25 
26  typedef typename operator_t::trial_input_t trial_input_t;
27  typedef size_t test_input_t;
28  typedef typename operator_t::result_t result_t;
29 
30  x2p_indexed(Operator &&op, It begin, It end)
31  : m_op(std::forward<Operator>(op))
32  , m_begin(begin)
33  , m_end(end)
34  {
35  }
36 
37  result_t operator()(size_t idx, trial_input_t const &ti) const
38  {
39  return m_op(m_begin[idx], ti);
40  }
41 
42  size_t num_rec() const
43  {
44  return m_end - m_begin;
45  }
46 
47 private:
48  Operator m_op;
49  iterator_t m_begin;
50  iterator_t m_end;
51 };
52 
53 template <class Operator, class It>
54 auto create_x2p_indexed(Operator &&op, It begin, It end)
55 {
56  return x2p_indexed<Operator, It>(std::forward<Operator>(op), begin, end);
57 }
58 
59 } // end of namespace fmm
60 } // namespace NiHu
61 
62 #endif /* NIHU_X2P_INDEXED_HPP_INCLUDED */
fmm_operator.hpp
FMM operator types and tags.
NiHu::fmm::fmm_operator
Operator defining its tag type.
Definition: fmm_operator.hpp:85
NiHu::fmm::x2p_indexed
Definition: x2p_indexed.hpp:19