Collection of numeric algorithms.
More...
std::tuple< __int128, __int128, __int128 > xgcd (__int128 p_a, __int128 p_b)
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 hasFloatSyntax (const std::string &p_str)
Checks, if the string has the syntax of a float.
bool hasRationalSyntax (const std::string &p_str)
Checks, if the string has the syntax of a rational number.
bool isSquareFree (__int128 p_n)
Checks if an integer is square free.
std::pair< int32_t, uint32_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.
◆ hasFloatSyntax()
bool algo::hasFloatSyntax
(
const std::string &
p_str )
Checks, if the string has the syntax of a float.
This pure syntax check does not apply the size limits of a 128 bit float.
Parameters
[in] p_str The string to check.
Returns bool ... To use in an assert.
◆ hasRationalSyntax()
bool algo::hasRationalSyntax
(
const std::string &
p_str )
Checks, if the string has the syntax of a rational number.
The regex has to match: [-+]?[0-9]+:[0-9]*[1-9][0-9]*
Parameters
[in] p_str The 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] p_str The string to check
Returns bool ... To use in an assert.
◆ isSquareFree()
bool algo::isSquareFree
(
__int128
p_n )
Checks if an integer is square free.
0 is per definition not square free.
Parameters
[in] p_n The integer to check.
Returns bool ... true, if the integer is square free.
◆ 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()
std::pair< int32_t, uint32_t > algo::rand
(
uint32_t
p_seed )
ISO C rand_r() for 32 bit.
Parameters
[in] p_seed Random generator seed.
Returns std::pair<int32_t,int32_t> ...
- Pseudo random value between 0 and .
- The new seed value.
◆ xgcd()
std::tuple< __int128, __int128, __int128 > algo::xgcd
(
__int128
p_a ,
__int128
p_b
)
Extended Euclidean algorithm.
Calculates the gcd of both input integers as well as
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.
Postcondition gcd(a,b) = p_s*p_a + p_t*p_b
Returns std::tuple<__int128, __int128, __int128> ...
- The gcd of p_a and p_b (first element).
- The Bézout coefficient s for p_a (second element).
- The Bézout coefficient t for p_b (third element).