Loading [MathJax]/extensions/tex2jax.js
NiHu  2.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
x2p_cluster_indexed.hpp
Go to the documentation of this file.
1 
7 #ifndef NIHU_X2P_CLUSTER_INDEXED_HPP_INCLUDED
8 #define NIHU_X2P_CLUSTER_INDEXED_HPP_INCLUDED
9 
10 #include "cluster_tree.hpp"
11 #include "fmm_operator.hpp"
12 #include "util/matrix_traits.hpp"
13 
14 #include <type_traits>
15 
16 namespace NiHu
17 {
18 namespace fmm
19 {
20 
21 template <class Operator>
23  : public fmm_operator<typename std::decay<Operator>::type::fmm_tag>
24 {
25 public:
26  typedef typename std::decay<Operator>::type operator_t;
27  typedef typename operator_t::trial_input_t cluster_t;
29  typedef typename operator_t::result_t op_result_t;
30  typedef typename scalar<op_result_t>::type scalar_t;
31  typedef Eigen::Matrix<scalar_t, Eigen::Dynamic, Eigen::Dynamic> result_t;
32  static size_t const rows = num_rows<op_result_t>::value;
33  static size_t const num_dof_per_rec = rows;
34 
35  x2p_cluster_indexed(Operator &&op, tree_t const &tree)
36  : m_op(std::forward<Operator>(op))
37  , m_tree(tree)
38  {
39  }
40 
41  result_t operator()(size_t to, size_t from) const
42  {
43  cluster_t const &clus_to = m_tree[to];
44  cluster_t const &clus_from = m_tree[from];
45 
47  bool first = true;
48  size_t cols = 0;
49 
50  result_t mat;
51  for (size_t ii = 0; ii < clus_to.get_n_rec_nodes(); ++ii)
52  {
53  size_t i = clus_to.get_rec_node_idx()[ii];
54  typename operator_t::result_t res = m_op(i, clus_from);
55  if (first)
56  {
57  cols = res.cols();
58  mat.resize(clus_to.get_n_rec_nodes() * rows, cols);
59  first = false;
60  }
61  mat.block(rows * ii, 0, rows, cols) = res;
62  }
63 
64  return mat;
65  }
66 
67  result_t operator()(size_t idx) const
68  {
69  return (*this)(idx, idx);
70  }
71 
72  tree_t const &get_tree() const
73  {
74  return m_tree;
75  }
76 
77 private:
78  Operator m_op;
79  tree_t const &m_tree;
80 };
81 
82 
83 template <class Operator>
84 x2p_cluster_indexed<Operator>
85 create_x2p_cluster_indexed(Operator &&op,
86  cluster_tree<typename std::decay<Operator>::type::trial_input_t> const &tree)
87 {
88  return x2p_cluster_indexed<Operator>(std::forward<Operator>(op), tree);
89 }
90 
91 } // end of namespace fmm
92 } // namespace NiHu
93 
94 #endif /* NIHU_X2P_CLUSTER_INDEXED_HPP_INCLUDED */
NiHu::fmm::cluster_tree< cluster_t >
matrix_traits.hpp
compile time properties of matrices
cluster_tree.hpp
Implementation of class NiHu::fmm::cluster_tree.
NiHu::fmm::x2p_cluster_indexed
Definition: x2p_cluster_indexed.hpp:22
NiHu::num_rows
metafunction returning the number of compile time rows
Definition: matrix_traits.hpp:16
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_cluster_indexed::operator()
result_t operator()(size_t to, size_t from) const
Definition: x2p_cluster_indexed.hpp:41