Driver for showing how to use the core functionalities of the Number Theory module by itself as well as with the openGPMP ThreadPool. This features functions related to integer factorization.
#include <chrono>
#include <cmath>
#include <iostream>
#include <vector>
int64_t n = 9223372036854775803;
std::cout << "The smallest prime factor of " << n << " is " << factor
<< std::endl;
std::vector<uint64_t> nums_to_factorize = {
9223372036854775803, 9223372036854775807, 9223372036854775303,
4567890123456789LL, 5678901234567890LL, 6789012345678901LL,
7890123456789012LL, 8901234567890123LL, 9999999967LL,
12345678901234567LL, 987654321987654321LL, 2147483647LL,
9223372036854775783LL, 1311768467463790320LL, 7237005577332262210LL,
3037000499LL, 2305843009213693951LL, 2305843009213693967LL,
2305843009213693971LL, 2305843009213693973LL, 2305843009213693977LL,
2305843009213693989LL};
std::vector<std::future<uint64_t>> results;
for (const auto &num : nums_to_factorize) {
*pool,
&factors,
num));
}
for (
auto &
res : results) {
std::cout <<
res.get() << std::endl;
}
delete pool;
return 0;
}
uint64_t pollard_rho(uint64_t n)
A class that provides a function to dispatch a function call to a thread pool and return a future obj...