tudocomp
– The TU Dortmund Compression Framework
esp_math.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 //#include <tudocomp/compressors/esp/>
4 
5 namespace tdc {namespace esp {
6  // Implementation that covers all of 64 bit
7  // TODO: This is hardcoded to work for the paper use case
8  inline size_t iter_log(size_t n) {
9  if (n < 7) return 0;
10  if (n < 9) return 1;
11  if (n < 17) return 2;
12  if (n < 257) return 3;
13  return 4;
14  }
15 
16  uint64_t label(uint64_t left, uint64_t right) {
17  auto diff = left ^ right;
18 
19  //std::cout << "l: " << std::setbase(2) << left << "\n";
20  //std::cout << "r: " << std::setbase(2) << right << "\n";
21  //std::cout << "d: " << std::setbase(2) << diff << "\n";
22  //std::cout << "\n";
23 
24 
25  DCHECK(diff != 0);
26 
27  auto l = __builtin_ctz(diff);
28 
29  auto bit = [](uint8_t l, uint64_t v) {
30  // TODO: test
31  return (v >> l) & 1;
32  };
33 
34  // form label(A[i])
35  return 2*l + bit(l, right);
36  };
37 
38 
39 }}
Contains the text compression and encoding framework.
Definition: namespaces.hpp:11
uint64_t label(uint64_t left, uint64_t right)
Definition: esp_math.hpp:16
size_t iter_log(size_t n)
Definition: esp_math.hpp:8