18 #include "../common/helper/helper.hpp" 38 std::cerr <<
"Usage: check_square [options]" << std::endl
40 <<
"Options:" << std::endl
41 <<
" --complete check complete path until 1 (by default check only partial path until < n)" << std::endl
42 <<
" --first n square of first odd number to check (9 by default)" << std::endl
43 <<
" --last n square of last odd number to check (10000000000 by default)" << std::endl
44 <<
" --print print partial or complete path for each number checked (by default only some numbers are printed to show progression)" << std::endl;
56 main(
int argc,
const char*
const argv[]) {
67 bool complete =
false;
71 for (
unsigned int i = 1; i < static_cast<unsigned int>(argc); ++i) {
72 const std::string param(argv[i]);
74 if (param ==
"--complete") {
77 else if (param ==
"--first") {
83 else if (param ==
"--last") {
89 else if (param ==
"--print") {
111 std::cout <<
"sequential/check_square" 112 <<
"\tFirst: " << first
113 <<
"\tLast: " << last
114 <<
"\tSqrt first: " << sqrt_first
115 <<
"\tSqrt last: " << sqrt_last
120 std::cout << std::endl
121 <<
"i\ti^2\tLower\tPartial length\tPartial path";
123 std::cout <<
"\tLength\tPath";
125 std::cout << std::endl;
130 const std::chrono::steady_clock::time_point clock_start = std::chrono::steady_clock::now();
136 std::cout << sqrt_first <<
'\t';
149 const bool print_this = print || ((i & 0xFFF) == 1);
151 std::cout << i <<
'\t';
163 std::chrono::duration<double> duration = std::chrono::steady_clock::now() - clock_start;
void sequential_check_varsigma_odd_perfect_square(nat_type n, bool print, bool print_lower, bool print_length, bool print_path)
Return sequential_check_varsigma_odd(), but only for n perfect square.
nat_type floor_square_root(nat_type n)
Return the square root of n rounded to below.
uint64_t nat_type
Type for natural number used in all code, on 64 bits.
nat_type ceil_square_root(nat_type n)
Return the square root of n rounded to above.
int main(int argc, const char *const argv[])
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...
void sequential_check_varsigma_odd_perfect_square_complete(nat_type n, bool print, bool print_lower, bool print_length, bool print_path)
Return sequential_check_varsigma_odd_complete(), but only for n perfect square.
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.
constexpr double square(double x)
Return x*x.
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::string to_string(bool b)
Return the string "true" if b, else "false".