tree03.hh

Go to the documentation of this file.
1 
6 #ifndef clusterTree03_hh
7 #define clusterTree03_hh
8 
9 #include "toolbox/hashMap.hh"
10 #include "cluster/tree.hh"
11 
12 namespace cluster {
13 
14  // ********************************************************** TreeTraits03 **
15 
20  template<class Node>
21  class TreeTraits03 : public TreeTraits<Node> {
22  public:
23  typedef typename TreeTraits<Node>::F F;
24 
25  static Node* newNode(const concepts::Element<F>& elm, const BBall<F>& ball,
26  Node* lnk) {return new Node(elm, ball, lnk);}
27  static Node* newNode(uint idx, Node& chld, const concepts::Real3d& c,
28  concepts::Real r, uint nlf = 0) {
29  return new Node(idx, chld, c, r, nlf);
30  }
31 
32  static Node* child(const Node* nd) {return nd->child();}
33  static Node* link(const Node* nd) {return nd->link();}
34  static Node*& link(Node* nd) {return nd->link();}
35  };
36 
37  // ************************************************************ CebyCenter **
38 
43  template<class Node>
44  class CebyCenter {
45  public:
48  typedef typename Traits::F F;
49 
53  inline CebyCenter(uint nvtx);
54  inline ~CebyCenter() {delete[] vtx_;}
55 
64  void operator()(const Node* lfset, concepts::Real3d& c, concepts::Real& r,
65  const concepts::Real3d* (&e)[4], uint& ne);
66 
67  private:
70  uint nvtx_;
74  std::unordered_map<uint, uint> vtxtag_;
76  uint tag_;
77  };
78 
79  template<class Node>
80  inline CebyCenter<Node>::CebyCenter(uint nvtx)
81  : nvtx_(nvtx), vtxtag_(), tag_(0) {
82  vtx_ = new const concepts::Real3d*[nvtx_];
83  }
84 
85  // **************************************************************** Tree03 **
86 
92  template<class CNode>
93  class Tree03 : public Tree<CNode> {
94  public:
97  typedef typename Traits::F F;
98 
105  Tree03(const concepts::Space<F>& spc, const BBall<F>& ball,
106  uint nlfmin = 1);
107  inline ~Tree03() {destructor_(root_); delete root_;}
108 
110  inline uint nclst() const {return nclst_;}
112  inline uint nleaf() const {return nlf_;}
114  inline const CNode* root() const {return root_;}
115 
121  void sketch(std::ostream& os, const CNode* lnk = 0, uint l = 0);
122 
123  private:
125  uint nlfmin_;
127  uint nlf_;
129  uint nclst_;
131  CNode* root_;
132 
136  CNode* constructor_(CNode* lfset, CebyCenter<CNode>& cby);
138  void destructor_(CNode* clst);
140  CNode* concat_(CNode* a, CNode* b);
141  };
142 
143 } // namespace cluster
144 
145 #endif // clusterTree03_hh
An abstract class for an element of a space.
Definition: exceptions.hh:15
const concepts::Real3d ** vtx_
List containing the points to compute the Cebysev ball.
Definition: tree03.hh:72
std::unordered_map< uint, uint > vtxtag_
Hash map to select the vertices of the Node list.
Definition: tree03.hh:74
CNode * root_
Root of the cluster tree.
Definition: tree03.hh:131
static Node *& link(Node *nd)
Definition: tree03.hh:34
uint nvtx_
Maximal number of vertices to compute the Cebysev ball.
Definition: tree03.hh:70
Abstract class for a space.
Interface class for a node in the cluster tree Tree01.
Definition: tree03.hh:21
uint nclst() const
Number of clusters.
Definition: tree03.hh:110
uint nlfmin_
Minimal leafs contained in a cluster.
Definition: tree03.hh:125
Tree03(const concepts::Space< F > &spc, const BBall< F > &ball, uint nlfmin=1)
Constructor.
static concepts::Real eps_
Definition: tree03.hh:68
CNode * constructor_(CNode *lfset, CebyCenter< CNode > &cby)
Constructor used for recursive calls.
static Node * newNode(const concepts::Element< F > &elm, const BBall< F > &ball, Node *lnk)
Definition: tree03.hh:25
Interface class for a node in a cluster tree.
Definition: tree.hh:252
Traits::F F
Definition: tree03.hh:48
CNode * concat_(CNode *a, CNode *b)
Concats two lists.
void destructor_(CNode *clst)
Destructor used for recursive calls.
static Node * newNode(uint idx, Node &chld, const concepts::Real3d &c, concepts::Real r, uint nlf=0)
Definition: tree03.hh:27
Cluster tree.
Definition: tree03.hh:93
Abstract class to compute a bounding ball of an element (the leafs of a cluster tree).
Definition: tree.hh:36
Class to compute the Cebysev ball of a point set, i.e., the smallest ball containing all points.
Definition: tree03.hh:44
void operator()(const Node *lfset, concepts::Real3d &c, concepts::Real &r, const concepts::Real3d *(&e)[4], uint &ne)
Application operator computes the Cebysev ball.
uint nlf_
Number of leafs in the tree.
Definition: tree03.hh:127
Node::CF F
Field of the node (Real or Cmplx)
Definition: tree.hh:255
Abstract class for a cluster tree.
Definition: tree.hh:274
uint nclst_
Number of clusters in the tree.
Definition: tree03.hh:129
TreeTraits03< Node > Traits
Interface for the algorithm.
Definition: tree03.hh:47
CebyCenter(uint nvtx)
Constructor.
Definition: tree03.hh:80
Used for the cluster classes for the boundary element method.
Definition: cebysev.hh:13
static Node * child(const Node *nd)
Definition: tree03.hh:32
uint nleaf() const
Number of leafs.
Definition: tree03.hh:112
TreeTraits< Node >::F F
Definition: tree03.hh:23
const CNode * root() const
Root node of the tree.
Definition: tree03.hh:114
uint tag_
Actual tag for vertices in the Node list.
Definition: tree03.hh:76
TreeTraits03< CNode > Traits
Interface of the tree.
Definition: tree03.hh:96
static Node * link(const Node *nd)
Definition: tree03.hh:33
Traits::F F
Definition: tree03.hh:97
void sketch(std::ostream &os, const CNode *lnk=0, uint l=0)
Sketch of a subtree.
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich