19 #include "../common/helper/helper.hpp" 39 std::cerr <<
"Usage: check_gentle [options] (sequential version)" << std::endl
41 <<
"Options:" << std::endl
42 <<
" --bad-table filename load bad numbers from this file" << std::endl
43 <<
" (If load bad numbers then must be contains all bad numbers < first." << std::endl
44 <<
" Can load them with several files.)" << std::endl
45 <<
" --first n first odd number to check (3 by default)" << std::endl
46 <<
" --last n last odd number to check (1000001 by default)" << std::endl
47 <<
" --nb n number of odd numbers to check" << std::endl
48 <<
" --no-print do not print bad numbers" << std::endl;
60 main(
int argc,
const char*
const argv[]) {
69 std::vector<sigmaodd::nat_type> bad_table;
72 bool print_bad =
true;
76 for (
unsigned int i = 1; i < static_cast<unsigned int>(argc); ++i) {
77 const std::string param(argv[i]);
79 if (param ==
"--bad-table") {
83 std::cerr <<
"! Failed reading file \"" << filename <<
'"' << std::endl;
88 if (bad_table.empty()) {
89 std::cerr <<
"! Wrong format for the bad table file \"" << filename <<
'"' << std::endl;
93 else if (param ==
"--first") {
99 else if (param ==
"--last") {
105 else if (param ==
"--nb") {
108 else if (param ==
"--no-print") {
116 const std::set<sigmaodd::nat_type> bad_table_set(bad_table.cbegin(), bad_table.cend());
120 const auto minmax = std::minmax_element(bad_table_set.cbegin(), bad_table_set.cend());
127 std::cout <<
"sequential/check_gentle" 128 <<
"\tFirst: " << first
129 <<
"\tLast: " << last
130 <<
"\tNb: " << (first <= last
131 ? (last - first)/2 + 1
133 if (!bad_table_set.empty()) {
134 std::cout <<
"\t# bad numbers loaded: " << bad_table_set.size()
135 <<
"\tBetween " << *minmax.first
136 <<
"\tand " << *minmax.second << std::endl;
138 std::cout << std::endl;
141 std::cout << std::endl
147 const std::chrono::steady_clock::time_point clock_start = std::chrono::steady_clock::now();
149 if (bad_table_set.empty()) {
156 0, std::max(first - 1, *minmax.second),
161 const std::chrono::duration<double> duration = std::chrono::steady_clock::now() - clock_start;
std::set< nat_type > sequential_check_gentle_varsigma_odd(nat_type first_n, nat_type last_n, bool print_bad)
Check in the order all odd gentle numbers between first_n and last_n, and if print_bad then print all...
uint64_t nat_type
Type for natural number used in all code, on 64 bits.
const std::string prime_filename
Default filename for the binary file "big_data/prime28.bin".
constexpr bool is_even(nat_type n)
Return true iff n is even.
std::string duration_to_string(std::chrono::duration< double > duration_second)
Return a string with the duration expressed in milliseconds, seconds, minutes and hours...
bool read_primes_table()
Read the binary file prime_filename to fill the table with all primes < 2^28. This table must be read...
bool is_file_exists(std::string filename)
Return true iff the file (or directory) exists.
std::string get_string(int argc, const char *const argv[], unsigned int i, void(*help_and_exit_function)())
Return argv[i] converted in string.
int main(int argc, const char *const argv[])
Implementation of the sequential algorithms presented in the report. (Some functions are not use in t...
void print_intern_config_compiler()
Print to stdcout the intern configuration of the compiler.
unsigned long get_ulong(int argc, const char *const argv[], unsigned int i, void(*help_and_exit_function)())
Return argv[i] converted in integer.
std::vector< nat_type > load_bad_table(const std::string &filename, const std::vector< nat_type > &bad_table)
Read a file that contains list of bad numbers, add after bad_table, and return the result...