13#define GOLDEN_RATIO 0.61803398875
bool is_prime_miller(int64 p, int k)
checks if p is prime with (1/4)^k probability of a false positive. the larger the k,...
Definition: mmath.c:77
int64 modpow_r(int64 a, int64 m, int64 n)
calculates the exponent of a to the power of m modulo n in O(m log m). _r stands for recursive (a ^ m...
Definition: mmath.c:200
int64 modpow(int64 a, int64 m, int64 n)
calculates the exponent of a to the power of m modulo n in O(m log m). this is the main implementatio...
Definition: mmath.c:169
int64 modpow_naive(int64 a, int64 m, int64 n)
calculates the exponent of a to the power of m modulo n in O(m^2). (a ^ m) % n = x
Definition: mmath.c:147
uint32 jenkins_one_at_a_time_hash(const uint8 *key, size_t len)
Jenkins one at a time hash function https://en.m.wikipedia.org/wiki/Jenkins_hash_function.
Definition: mmath.c:255
int64 random_prime_number(int low_size, int up_size, int k)
Generates a random prime number with number of bits between low_size and up_size. k specifies the cer...
Definition: mmath.c:117
int64 extended_gcd(int64 s, int64 t, int64 *u, int64 *v)
calculates the pgcd and the corresponding Bezout decomposition. pgcd = s*u + t*v
Definition: mmath.c:234
bool is_prime_naive(int64 p)
checks if p is prime. complexity O(p), certainty 100%
Definition: mmath.c:22
int64 rand_int64(int64 low, int64 up)
generates a random int64 inside [low, up]
Definition: mmath.c:62
a file with comfy aliases for long type signatures
#define int64
alias for long long int
Definition: types.h:17
#define uint8
alias for unsigned char
Definition: types.h:32
#define uint32
alias for unsigned long int
Definition: types.h:22