1 #ifndef KALLISTO_REPHASH_H 2 #define KALLISTO_REPHASH_H 8 static const unsigned char twin[32] = {
9 0, 20, 2, 7, 4, 5, 6, 3,
10 8, 9, 10, 11, 12, 13, 14, 15,
11 16, 17, 18, 19, 1, 21, 22, 23,
12 24, 25, 26, 27, 28, 29, 30, 31
15 static const uint64_t hvals[4] = {
16 2053695854357871005ULL, 5073395517033431291ULL,
17 10060236952204337488ULL, 7783083932390163561ULL
40 inline void fastleftshiftk(uint64_t& x) {
41 x = (x << k) | (x >> (64-k));
44 inline void fastrightshiftk(uint64_t& x) {
45 x = (x >> k) | (x << (64-k));
48 inline void fastleftshift1(uint64_t& x) {
49 x = (x << 1) | (x >> 63);
52 inline void fastrightshift1(uint64_t& x) {
53 x = (x >> 1) | (x << 63);
56 inline uint64_t hash()
const {
61 void init(
const char* _s) {
64 const unsigned char* s = (
const unsigned char*) _s;
65 for (
size_t i = 0; i < k; i++) {
67 uint64_t hval = hvals[charmask(s[i])];
71 uint64_t hvalt = hvals[twinmask(s[k-1-i])];
77 inline void update(
const unsigned char out,
const unsigned char in) {
78 uint64_t z(hvals[charmask(out)]);
81 uint64_t hval(hvals[charmask(in)]);
85 uint64_t zt(hvals[twinmask(in)]);
87 uint64_t hvalt(hvals[twinmask(out)]);
94 inline void extendFW(
const unsigned char fw) {
96 uint64_t hval(hvals[charmask(fw)]);
101 uint64_t hvalt(hvals[twinmask(fw)]);
102 fastleftshiftk(hvalt);
109 inline void increaseK() {
121 inline void extendBW(
const unsigned char bw) {
123 uint64_t hval(hvals[charmask(bw)]);
124 fastleftshiftk(hval);
128 uint64_t hvalt(hvals[twinmask(bw)]);
137 inline uint64_t charmask(
unsigned char x) {
141 inline uint64_t twinmask(
unsigned char x) {
154 #endif // KALLISTO_REPHASH_H Definition: RepHash.hpp:23