74# if defined(__SIZEOF_INT128__)
93 d = std::gcd(
diff, n);
114 if (n % 2 == 0)
return 2;
115 if (n % 3 == 0)
return 3;
116 if (n % 5 == 0)
return 5;
119 thread_local std::mt19937_64
rng([]() {
120 std::random_device rd;
134 <<
"pollard_rho: failed to find a factor of " << n
137# if defined(__GNUC__) || defined(__clang__)
139# elif defined(_MSC_VER)
Exception handling system with formatted messages for Aleph-w.
#define ah_runtime_error()
Throws std::runtime_error unconditionally.
#define ah_invalid_argument_if(C)
Throws std::invalid_argument if condition holds.
High-level sorting functions for Aleph containers.
Simple dynamic array with automatic resizing and functional operations.
Safe modular arithmetic, extended Euclidean algorithm, and Chinese Remainder Theorem.
uint64_t pollard_rho_step(const uint64_t n, const uint64_t seed, const uint64_t c)
Inner function for Pollard's rho algorithm.
void extract_prime_factors(const uint64_t n, Array< uint64_t > &factors)
Recursive extraction of all prime factors.
uint64_t find_any_factor(const uint64_t n)
Helper to repeatedly apply Pollard's rho until a factor is found.
Main namespace for Aleph-w library functions.
and
Check uniqueness with explicit hash + equality functors.
Array< uint64_t > pollard_rho(uint64_t n)
Compute the prime factorization of a number using Pollard's rho.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
DynArray< T > & in_place_sort(DynArray< T > &c, Cmp cmp=Cmp())
Sorts a DynArray in place.
bool miller_rabin(uint64_t n) noexcept
Miller-Rabin primality test for 64-bit integers.
bool diff(const C1 &c1, const C2 &c2, Eq e=Eq())
Check if two containers differ.
uint64_t mod_mul(uint64_t a, uint64_t b, uint64_t m)
Safe 64-bit modular multiplication.
Advanced primality testing algorithms.
Dynamic array container with automatic resizing.