Compressed Sparse Blocks  1.2
 All Classes Files Functions Variables Typedefs Friends Macros Pages
mortoncompare.h
Go to the documentation of this file.
1 #ifndef _MORTONCOMPARE_H_
2 #define _MORTONCOMPARE_H_
3 
4 
5 template <class ITYPE>
6 class MortonCompare: public binary_function< ITYPE , ITYPE , bool > // (par1, par2, return_type)
7 {
8 public:
10  MortonCompare (ITYPE nrbits, ITYPE ncbits, ITYPE rmask, ITYPE cmask )
11  : nrowbits(nrbits), ncolbits(ncbits), rowmask(rmask), colmask(cmask) {}
12 
13  // rhs is the splitter that is already in bit-interleaved order
14  // lhs is the actual value that is in row-major order
15  bool operator()(const ITYPE & lhs, const ITYPE & rhs) const
16  {
17  ITYPE rlowbits = ((lhs >> ncolbits) & rowmask);
18  ITYPE clowbits = (lhs & colmask);
19  ITYPE bikey = BitInterleaveLow(rlowbits, clowbits);
20 
21  return bikey < rhs;
22  }
23 
24 private:
25  ITYPE nrowbits;
26  ITYPE ncolbits;
27  ITYPE rowmask;
28  ITYPE colmask;
29 };
30 
31 template <class ITYPE>
32 class MortCompSym: public binary_function< ITYPE , ITYPE , bool > // (par1, par2, return_type)
33 {
34 public:
36  MortCompSym(ITYPE bits, ITYPE lowmask): nbits(bits), lmask(lowmask) {}
37 
38  // rhs is the splitter that is already in bit-interleaved order
39  // lhs is the actual value that is in row-major order
40  bool operator()(const ITYPE & lhs, const ITYPE & rhs) const
41  {
42  ITYPE rlowbits = ((lhs >> nbits) & lmask);
43  ITYPE clowbits = (lhs & lmask);
44  ITYPE bikey = BitInterleaveLow(rlowbits, clowbits);
45 
46  return bikey < rhs;
47  }
48 
49 private:
50  ITYPE nbits;
51  ITYPE lmask;
52 
53 };
54 
55 #endif
56 
bool operator()(const ITYPE &lhs, const ITYPE &rhs) const
Definition: mortoncompare.h:40
MortonCompare(ITYPE nrbits, ITYPE ncbits, ITYPE rmask, ITYPE cmask)
Definition: mortoncompare.h:10
MortCompSym(ITYPE bits, ITYPE lowmask)
Definition: mortoncompare.h:36
ITYPE BitInterleaveLow(ITYPE x, ITYPE y)
Definition: utility.h:344
bool operator()(const ITYPE &lhs, const ITYPE &rhs) const
Definition: mortoncompare.h:15