|
|
|
|
@ -6,6 +6,7 @@
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <random>
|
|
|
|
|
#include <stdexcept>
|
|
|
|
|
#include <unordered_set>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#ifdef _OPENMP
|
|
|
|
|
@ -50,18 +51,18 @@ std::vector<int> unrank_combination(long n, long k, long long idx) {
|
|
|
|
|
// sample c indices in [0,total] for our c = # of clauses
|
|
|
|
|
// this is the heart of the program as we are flattening the problem with our sampled indices and the unrank function!
|
|
|
|
|
std::vector<long long> sample_indices(long long total, long c) {
|
|
|
|
|
std::vector<long long> idx;
|
|
|
|
|
idx.reserve(c);
|
|
|
|
|
std::unordered_set<long long> set;
|
|
|
|
|
set.reserve(c);
|
|
|
|
|
|
|
|
|
|
std::random_device rd;
|
|
|
|
|
std::mt19937 gen(rd());
|
|
|
|
|
std::uniform_int_distribution<long long> dist(0, total - 1);
|
|
|
|
|
|
|
|
|
|
for (long i = 0; i < c; i++) {
|
|
|
|
|
idx.push_back(dist(gen));
|
|
|
|
|
while ((long)set.size() < c) {
|
|
|
|
|
set.insert(dist(gen));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return idx;
|
|
|
|
|
return std::vector<long long>(set.begin(), set.end());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// decode one clause from global index (think of it like a hash function for better understanding!)
|
|
|
|
|
|