-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.cpp
41 lines (36 loc) · 1.19 KB
/
main.cpp
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
41
#include <bitset>
#include <random>
#include <thread>
#include <iostream>
int main ()
{
static constexpr int L {53}; // Length.
static constexpr int SLL {4}; // Sidelobe limit.
static constexpr int N {8}; // Number of threads.
static constexpr long int from {1};
static constexpr long int to {static_cast <long int> (1) << (L - 1)};
bool stop {false};
const auto task = [& stop](){
std::random_device device;
std::mt19937 generator (device () );
std::uniform_int_distribution <long int> distribution (from, to);
std::bitset <L> s {};
while (!stop) {
s ^= distribution (generator);
for (int i = 1; i < L - SLL; ++i)
if (abs (static_cast <int> ( ( (s >> i ^ s) << i).count () ) * 2 - L + i) > SLL)
goto NEXT;
std::cout << s.to_string ('-', '+') << std::endl;
stop = true;
NEXT:;
}
};
std::vector <std::thread> pull;
for (int i = 0; i < N; ++i) {
pull.push_back (std::thread (task) );
}
for (int i = 0; i < N; ++i) {
pull [i].join ();
}
return EXIT_SUCCESS;
}