Collection of numeric algorithms.
More...
__int128 xgcd (__int128 p_a, __int128 p_b, __int128 *p_s, __int128 *p_t)
Extended Euclidean algorithm.
bool isint128 (const std::string &p_str)
Is the string a 128 bit integer.
bool isint128 (const mpz_t p_x)
Is the multiple precision integer a 128 bit integer.
bool isfloat128 (const std::string &p_str)
Is the string a 128 bit float.
int32_t rand (uint32_t *p_seed)
ISO C rand_r() for 32 bit.
__int128 mmod (__int128 p_d, __int128 p_m)
Mathematical modulus.
Collection of numeric algorithms.
◆ isfloat128()
bool algo::isfloat128
(
const std::string &
p_str )
Is the string a 128 bit float.
We accept loosing unsignificant digits.
Parameters
[in] p_str String to check.
Returns bool ... To use in an assert.
◆ isint128() [1/2]
bool algo::isint128
(
const mpz_t
p_x )
Is the multiple precision integer a 128 bit integer.
Parameters
Returns bool ... For an assert.
◆ isint128() [2/2]
bool algo::isint128
(
const std::string &
p_str )
Is the string a 128 bit integer.
Parameters
[in,out] p_str The string to check
Returns bool ... To use in an assert.
◆ mmod()
__int128 algo::mmod
(
__int128
p_d ,
__int128
p_m
)
inline
Mathematical modulus.
It differs from C++ 11 and newer,
which defines the calculation of a remainder such that (a/b)*b + ab = a.
Parameters
[in] p_d The dividend.
[in] p_m The modulus.
Returns __int128 ... The remainder.
◆ rand()
int32_t algo::rand
(
uint32_t *
p_seed )
ISO C rand_r() for 32 bit.
Parameters
[in,out] p_seed Random generator seed.
Returns int32_t ... Pseudo random value between 0 and .
◆ xgcd()
__int128 algo::xgcd
(
__int128
p_a ,
__int128
p_b ,
__int128 *
p_s ,
__int128 *
p_t
)
Extended Euclidean algorithm.
Calculates the gcd of both input integers and additionally calculates
a pair of Bézout coefficients s and t such that gcd(a,b) = s*a + t*b.
Returns 0 if both p_a and p_b are 0.
Parameters
[in] p_a First input number.
[in] p_b Second input number.
[out] p_s A Bézout coefficient of p_a.
[out] p_t A Bézout coefficient of p_b.
Postcondition gcd(a,b) = p_s*p_a + p_t*p_b
Returns __int128 ... gcd of p_a and p_b.