75# if defined(__SIZEOF_INT128__) && !defined(_WIN32)
94 d = std::gcd(
diff, n);
115 if (n % 2 == 0)
return 2;
116 if (n % 3 == 0)
return 3;
117 if (n % 5 == 0)
return 5;
120 thread_local std::mt19937_64
rng([]() {
121 std::random_device rd;
135 <<
"pollard_rho: failed to find a factor of " << n
138# if defined(__GNUC__) || defined(__clang__)
140# 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.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
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.
Array< uint64_t > pollard_rho(uint64_t n)
Compute the prime factorization of a number using Pollard's rho.
and
Check uniqueness with explicit hash + equality functors.
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.