-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyncmer.hpp
40 lines (36 loc) · 1.13 KB
/
syncmer.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef SYNCMER_H_
#define SYNCMER_H_
#include<vector>
#include "divisor.hpp"
#include "permutations.hpp"
template<typename mer_ops, typename mer_t = typename mer_ops::mer_t>
unsigned min_smer(mer_t m, unsigned s, const std::vector<mer_t>& smer_order, const jflib::divisor64& div_s) {
// std::cout << "min_smer " << (size_t)m;
unsigned min = 0;
mer_t min_val = smer_order[m % div_s];
m /= mer_ops::alpha;
for(unsigned i = 1; i < mer_ops::k - s + 1; ++i, m /= mer_ops::alpha) {
mer_t smer = smer_order[m % div_s];
if(smer <= min_val) {
min = i;
min_val = smer;
}
}
// std::cout << ' ' << mer_ops::k - s - min << '\n';
return mer_ops::k - s - min;
}
template<typename mer_ops, typename mer_t = typename mer_ops::mer_t>
unsigned min_large_smer(mer_t m, unsigned s, const LubyRackofPermutation<mer_t>& perm, const jflib::divisor64& div_s) {
unsigned min = 0;
mer_t min_val = perm(m % div_s);
m /= mer_ops::alpha;
for(unsigned i = 1; i < mer_ops::k - s + 1; ++i, m /= mer_ops::alpha) {
mer_t smer = perm(m % div_s);
if(smer <= min_val) {
min = i;
min_val = smer;
}
}
return mer_ops::k - s - min;
}
#endif // SYNCMER_H_