NiHu  2.0
divide.hpp
Go to the documentation of this file.
1 
7 #ifndef NIHU_DIVIDE_HPP_INCLUDED
8 #define NIHU_DIVIDE_HPP_INCLUDED
9 
10 #include "cluster.hpp"
11 #include "util/crtp_base.hpp"
12 
13 #include <algorithm> // std::max
14 
15 namespace NiHu
16 {
17 namespace fmm
18 {
19 
27 template <class Derived>
29 {
30 public:
32 
33  template <class Cluster>
34  bool operator()(Cluster const &c) const
35  {
36  return derived().operator()(c);
37  }
38 };
39 
41 class divide_depth : public divide_base<divide_depth>
42 {
48  size_t m_depth;
49 
50 public:
55  divide_depth(size_t depth)
56  : m_depth(depth)
57  {
58  }
59 
66  template <class Cluster>
67  bool operator()(Cluster const &c) const
68  {
69  return c.get_level() < m_depth;
70  }
71 };
72 
74 class divide_num_nodes : public divide_base<divide_num_nodes>
75 {
76  size_t m_max_nodes;
77 
78 public:
82  divide_num_nodes(size_t max_nodes)
83  : m_max_nodes(max_nodes)
84  {
85  }
86 
92  template <class Cluster>
93  bool operator()(Cluster const &c) const
94  {
95  size_t s = c.get_n_src_nodes();
96  size_t r = c.get_n_rec_nodes();
97  return std::max(s, r) > m_max_nodes;
98  }
99 };
100 
102 class divide_diameter : public divide_base<divide_diameter>
103 {
104  double m_diameter;
105 
106 public:
110  divide_diameter(double d)
111  : m_diameter(d)
112  {
113  }
114 
120  template <class Cluster>
121  bool operator()(Cluster const &c) const
122  {
123  return c.get_bounding_box().get_diameter() > m_diameter;
124  }
125 };
126 
127 } // end of namespace fmm
128 } // end of namespace NiHu
129 
130 #endif /* NIHU_DIVIDE_HPP_INCLUDED */
NiHu::fmm::divide_diameter
class representing a balanced tree division predicate by leaf diameter
Definition: divide.hpp:102
NiHu::fmm::divide_diameter::divide_diameter
divide_diameter(double d)
constructor
Definition: divide.hpp:110
NiHu::fmm::divide_depth::divide_depth
divide_depth(size_t depth)
Constructor.
Definition: divide.hpp:55
NIHU_CRTP_HELPERS
#define NIHU_CRTP_HELPERS
define CRTP helper function
Definition: crtp_base.hpp:29
NiHu::fmm::divide_depth
Class representing a balanced tree division predicate.
Definition: divide.hpp:41
NiHu::fmm::divide_num_nodes
Class representing a cluster division based on number of nodes.
Definition: divide.hpp:74
NiHu::fmm::divide_num_nodes::divide_num_nodes
divide_num_nodes(size_t max_nodes)
constructor
Definition: divide.hpp:82
NiHu::fmm::divide_base
Base CRTP class for cluster division.
Definition: divide.hpp:28
crtp_base.hpp
Define CRTP helper functions and metafunctions.
cluster.hpp
implementation of class NiHu::fmm::cluster_base
NiHu::fmm::divide_diameter::operator()
bool operator()(Cluster const &c) const
determine if a cluster needs to be divided or not
Definition: divide.hpp:121
NiHu::fmm::divide_depth::operator()
bool operator()(Cluster const &c) const
Determine if a cluster needs to be divided.
Definition: divide.hpp:67
NiHu::fmm::divide_num_nodes::operator()
bool operator()(Cluster const &c) const
determine if a cluster needs to be divided
Definition: divide.hpp:93