Leonardus
Loading...
Searching...
No Matches
algo.h
Go to the documentation of this file.
1
17#pragma once
18
19// Inc Library
20#include <string>
21#include <cstdint>
22#include <gmp.h>
23
24
27namespace algo {
28
40 __int128 xgcd( __int128 p_a, __int128 p_b, __int128 & p_s, __int128 & p_t );
41
46 bool isint128( std::string p_str );
47
52 bool isint128( const mpz_t p_x );
53
58 int32_t rand( uint32_t * seed );
59
62 inline __int128 mmod( __int128 p_x, __int128 p_m ) {
63 const __int128 res = p_x % p_m;
64 return res>=0 ? res : res+p_m;
65 }
66
67} // namespace algo
Collection of numeric algorithms.
Definition algo.h:27
__int128 xgcd(__int128 p_a, __int128 p_b, __int128 &p_s, __int128 &p_t)
Extended Euclidean algorithm.
Definition algo.cpp:31
bool isint128(std::string p_str)
Is the string a 128 bit integer.
Definition algo.cpp:72
__int128 mmod(__int128 p_x, __int128 p_m)
Mathematical modulus.
Definition algo.h:62
int32_t rand(uint32_t *seed)
ISO C rand_r() for 32 bit.
Definition algo.cpp:133