Leonardus
Loading...
Searching...
No Matches
algo.h
Go to the documentation of this file.
1
17#pragma once
18
19// Inc Library
20#include <utility>
21#include <tuple>
22#include <string>
23#include <cstdint>
24#include <gmp.h>
25
26
28namespace algo {
29
42 std::tuple<__int128,__int128,__int128> xgcd( __int128 p_a, __int128 p_b );
43
44
49 bool isint128( const std::string & p_str );
50
51
56 bool isint128( const mpz_t p_x );
57
58
64 bool hasFloatSyntax( const std::string & p_str );
65
66
72 bool hasRationalSyntax( const std::string & p_str );
73
74
80 bool isSquareFree( __int128 p_n );
81
82
89 std::pair<int32_t,uint32_t> rand( uint32_t p_seed );
90
91
99 inline __int128 mmod( __int128 p_d, __int128 p_m ) {
100 const __int128 rem = p_d % p_m;
101 return rem>=0 ? rem : rem+p_m;
102 }
103
104} // namespace algo
Collection of numeric algorithms.
Definition algo.h:28
bool isSquareFree(__int128 p_n)
Checks if an integer is square free.
Definition algo.cpp:131
__int128 mmod(__int128 p_d, __int128 p_m)
Mathematical modulus.
Definition algo.h:99
bool hasFloatSyntax(const std::string &p_str)
Checks, if the string has the syntax of a float.
Definition algo.cpp:114
std::pair< int32_t, uint32_t > rand(uint32_t p_seed)
ISO C rand_r() for 32 bit.
Definition algo.cpp:175
bool isint128(const std::string &p_str)
Is the string a 128 bit integer.
Definition algo.cpp:74
std::tuple< __int128, __int128, __int128 > xgcd(__int128 p_a, __int128 p_b)
Extended Euclidean algorithm.
Definition algo.cpp:36
bool hasRationalSyntax(const std::string &p_str)
Checks, if the string has the syntax of a rational number.
Definition algo.cpp:125