SparseLibrary  Version 1.6.0
SBDTree.hpp
1 /*
2  * Copyright (c) 2007-2014, A. N. Yzelman, Utrecht University 2007-2011;
3  * KU Leuven 2011-2014.
4  * R. H. Bisseling, Utrecht University 2007-2014.
5  *
6  * This file is part of the Sparse Library.
7  *
8  * This library was developed under supervision of Prof. dr. Rob H. Bisseling at
9  * Utrecht University, from 2007 until 2011. From 2011-2014, development continued
10  * at KU Leuven, where Prof. dr. Dirk Roose contributed significantly to the ideas
11  * behind the newer parts of the library code.
12  *
13  * The Sparse Library is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by the
15  * Free Software Foundation, either version 3 of the License, or (at your
16  * option) any later version.
17  *
18  * The Sparse Library is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  * for more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with the Sparse Library. If not, see <http://www.gnu.org/licenses/>.
25  */
26 
27 
28 /*
29  * File created by:
30  * A. N. Yzelman, Dept. of Mathematics, Utrecht University, 2010.
31  */
32 
33 
34 #ifndef _H_SBDTREE
35 #define _H_SBDTREE
36 
37 #include <cstdlib>
38 #include <vector>
39 #include <iostream>
40 #include <limits.h>
41 #include <assert.h>
42 
44 class SBDTree {
45 
46  protected:
47 
49  unsigned long int *parent;
50 
52  unsigned long int *left_child;
53 
55  unsigned long int *right_child;
56 
58  unsigned long int *r_lo;
59 
61  unsigned long int *r_hi;
62 
64  unsigned long int *c_lo;
65 
67  unsigned long int *c_hi;
68 
70  unsigned long int root;
71 
73  unsigned long int nodes;
74 
77 
79  static const unsigned long int NO_SUCH_NODE = ULONG_MAX;
80 
88  void build( std::vector< unsigned long int > &hierarchy,
89  std::vector< unsigned long int > &r_bounds,
90  std::vector< unsigned long int > &c_bounds );
91  public:
92 
94  SBDTree( std::vector< unsigned long int > &r_hierarchy, std::vector< unsigned long int > &c_hierarchy,
95  std::vector< unsigned long int > &r_bounds,
96  std::vector< unsigned long int > &c_bounds );
97 
99  SBDTree( std::vector< unsigned long int > &hierarchy,
100  std::vector< unsigned long int > &r_bounds,
101  std::vector< unsigned long int > &c_bounds );
102 
104  ~SBDTree();
105 
119  void getSeparatorBB( const unsigned long int index,
120  unsigned long int &r_lo, unsigned long int &r_hi,
121  unsigned long int &c_lo, unsigned long int &c_hi );
122 
124  unsigned long int up( const unsigned long int index );
125 
127  unsigned long int left( const unsigned long int index );
128 
130  unsigned long int right( const unsigned long int index );
131 
133  void rowBounds( const unsigned long int index,
134  unsigned long int &r_lo,
135  unsigned long int &r_hi );
136 
138  void columnBounds( const unsigned long int index,
139  unsigned long int &c_lo,
140  unsigned long int &c_hi );
141 
143  char isLeaf( const unsigned long int index );
144 
146  unsigned long int size();
147 
149  unsigned long int getRoot();
150 };
151 
152 #endif
153 
unsigned long int root
Which node ID corresponds to the root.
Definition: SBDTree.hpp:70
void columnBounds(const unsigned long int index, unsigned long int &c_lo, unsigned long int &c_hi)
Returns the column bounds corresponding to a given node.
Definition: SBDTree.cpp:206
char root_is_set
Whether the root node is set.
Definition: SBDTree.hpp:76
unsigned long int * right_child
Array s.t.
Definition: SBDTree.hpp:55
unsigned long int * left_child
Array s.t.
Definition: SBDTree.hpp:52
void build(std::vector< unsigned long int > &hierarchy, std::vector< unsigned long int > &r_bounds, std::vector< unsigned long int > &c_bounds)
Builds the SBD tree using three input vectors.
Definition: SBDTree.cpp:36
unsigned long int * c_lo
Array s.t.
Definition: SBDTree.hpp:64
char isLeaf(const unsigned long int index)
Whether the given node is a leaf node.
Definition: SBDTree.cpp:214
~SBDTree()
Base deconstructor.
Definition: SBDTree.cpp:125
unsigned long int left(const unsigned long int index)
Returns the left child of a given node.
Definition: SBDTree.cpp:180
unsigned long int * r_lo
Array s.t.
Definition: SBDTree.hpp:58
unsigned long int * c_hi
Array s.t.
Definition: SBDTree.hpp:67
unsigned long int * parent
Array s.t.
Definition: SBDTree.hpp:49
void rowBounds(const unsigned long int index, unsigned long int &r_lo, unsigned long int &r_hi)
Returns the row bounds corresponding to a given node.
Definition: SBDTree.cpp:198
unsigned long int up(const unsigned long int index)
Returns the parent of a given node.
Definition: SBDTree.cpp:171
unsigned long int size()
Gets the number of nodes.
Definition: SBDTree.cpp:222
unsigned long int right(const unsigned long int index)
Returns the right child of a given node.
Definition: SBDTree.cpp:189
unsigned long int * r_hi
Array s.t.
Definition: SBDTree.hpp:61
unsigned long int getRoot()
Gets the root index.
Definition: SBDTree.cpp:226
SBDTree(std::vector< unsigned long int > &r_hierarchy, std::vector< unsigned long int > &c_hierarchy, std::vector< unsigned long int > &r_bounds, std::vector< unsigned long int > &c_bounds)
Base constructor.
Definition: SBDTree.cpp:103
static const unsigned long int NO_SUCH_NODE
Integer corresponding to non-existing nodes.
Definition: SBDTree.hpp:79
unsigned long int nodes
The total number of tree nodes.
Definition: SBDTree.hpp:73
Models a Separated Block Diagonal tree structure.
Definition: SBDTree.hpp:44
void getSeparatorBB(const unsigned long int index, unsigned long int &r_lo, unsigned long int &r_hi, unsigned long int &c_lo, unsigned long int &c_hi)
Gets, from a separator node, the bounding box of the nonzeroes contained in the separator.
Definition: SBDTree.cpp:141