7 #ifndef SYMENGINE_NTHEORY_H
8 #define SYMENGINE_NTHEORY_H
19 RCP<const Integer>
nextprime(
const Integer &a);
23 RCP<const Integer>
gcd(
const Integer &a,
const Integer &b);
25 RCP<const Integer>
lcm(
const Integer &a,
const Integer &b);
27 void gcd_ext(
const Ptr<RCP<const Integer>> &g,
const Ptr<RCP<const Integer>> &s,
28 const Ptr<RCP<const Integer>> &t,
const Integer &a,
31 RCP<const Integer>
mod(
const Integer &n,
const Integer &d);
33 RCP<const Integer>
quotient(
const Integer &n,
const Integer &d);
36 const Ptr<RCP<const Integer>> &r,
const Integer &a,
39 RCP<const Integer>
mod_f(
const Integer &n,
const Integer &d);
41 RCP<const Integer>
quotient_f(
const Integer &n,
const Integer &d);
44 const Ptr<RCP<const Integer>> &r,
const Integer &a,
47 int mod_inverse(
const Ptr<RCP<const Integer>> &b,
const Integer &a,
51 bool crt(
const Ptr<RCP<const Integer>> &R,
56 RCP<const Integer>
fibonacci(
unsigned long n);
59 void fibonacci2(
const Ptr<RCP<const Integer>> &g,
60 const Ptr<RCP<const Integer>> &s,
unsigned long n);
63 RCP<const Integer>
lucas(
unsigned long n);
66 void lucas2(
const Ptr<RCP<const Integer>> &g,
const Ptr<RCP<const Integer>> &s,
70 RCP<const Integer>
binomial(
const Integer &n,
unsigned long k);
73 RCP<const Integer>
factorial(
unsigned long n);
76 bool divides(
const Integer &a,
const Integer &b);
80 int factor(
const Ptr<RCP<const Integer>> &f,
const Integer &n,
double B1 = 1.0);
91 const Integer &n,
unsigned B = 10,
92 unsigned retries = 5);
96 const Integer &n,
unsigned retries = 5);
105 RCP<const Number>
bernoulli(
unsigned long n);
107 RCP<const Number>
harmonic(
unsigned long n,
long m = 1);
110 bool primitive_root(
const Ptr<RCP<const Integer>> &g,
const Integer &n);
116 RCP<const Integer>
totient(
const RCP<const Integer> &n);
118 RCP<const Integer>
carmichael(
const RCP<const Integer> &n);
121 const RCP<const Integer> &a,
122 const RCP<const Integer> &n);
124 int legendre(
const Integer &a,
const Integer &n);
126 int jacobi(
const Integer &a,
const Integer &n);
128 int kronecker(
const Integer &a,
const Integer &n);
131 const RCP<const Integer> &a,
const RCP<const Integer> &n,
132 const RCP<const Integer> &m);
134 bool nthroot_mod(
const Ptr<RCP<const Integer>> &root,
135 const RCP<const Integer> &a,
const RCP<const Integer> &n,
136 const RCP<const Integer> &m);
139 bool powermod(
const Ptr<RCP<const Integer>> &powm,
const RCP<const Integer> &a,
140 const RCP<const Number> &b,
const RCP<const Integer> &m);
144 const RCP<const Integer> &a,
const RCP<const Number> &b,
145 const RCP<const Integer> &m);
160 int mobius(
const Integer &a);
163 long mertens(
const unsigned long a);
166 const integer_class &n);
168 const integer_class &x);
182 bool lowest_exponent =
false);
Main namespace for SymEngine package.
integer_class mp_polygonal_number(const integer_class &s, const integer_class &n)
Numeric calculation of the n:th s-gonal number.
bool divides(const Integer &a, const Integer &b)
bool powermod(const Ptr< RCP< const Integer >> &powm, const RCP< const Integer > &a, const RCP< const Number > &b, const RCP< const Integer > &m)
RCP< const Integer > nextprime(const Integer &a)
int kronecker(const Integer &a, const Integer &n)
Kronecker Function.
void fibonacci2(const Ptr< RCP< const Integer >> &g, const Ptr< RCP< const Integer >> &s, unsigned long n)
Fibonacci n and n-1.
void prime_factor_multiplicities(map_integer_uint &primes_mul, const Integer &n)
Find multiplicities of prime factors of n
RCP< const Integer > gcd(const Integer &a, const Integer &b)
Greatest Common Divisor.
bool nthroot_mod(const Ptr< RCP< const Integer >> &root, const RCP< const Integer > &a, const RCP< const Integer > &n, const RCP< const Integer > &mod)
A solution to x**n == a mod m. Return false if none exists.
bool primitive_root(const Ptr< RCP< const Integer >> &g, const Integer &n)
Computes a primitive root. Returns false if no primitive root exists.
RCP< const Integer > mod(const Integer &n, const Integer &d)
modulo round toward zero
int mobius(const Integer &a)
Mobius Function.
RCP< const Integer > lucas(unsigned long n)
Lucas number.
RCP< const Integer > quotient_f(const Integer &n, const Integer &d)
void nthroot_mod_list(std::vector< RCP< const Integer >> &roots, const RCP< const Integer > &a, const RCP< const Integer > &n, const RCP< const Integer > &m)
All Solutions to x**n == a mod m. Return false if none exists.
RCP< const Integer > fibonacci(unsigned long n)
Fibonacci number.
bool is_quad_residue(const Integer &a, const Integer &p)
Returns true if 'a' is a quadratic residue of 'p'.
RCP< const Integer > mod_f(const Integer &n, const Integer &d)
modulo round toward -inf
RCP< const Integer > quotient(const Integer &n, const Integer &d)
void prime_factors(std::vector< RCP< const Integer >> &prime_list, const Integer &n)
Find prime factors of n
int mod_inverse(const Ptr< RCP< const Integer >> &b, const Integer &a, const Integer &m)
inverse modulo
vec_integer_class quadratic_residues(const Integer &a)
Finds all Quadratic Residues of a Positive Integer.
int jacobi(const Integer &a, const Integer &n)
Jacobi Function.
RCP< const Integer > lcm(const Integer &a, const Integer &b)
Least Common Multiple.
RCP< const Integer > binomial(const Integer &n, unsigned long k)
Binomial Coefficient.
bool multiplicative_order(const Ptr< RCP< const Integer >> &o, const RCP< const Integer > &a, const RCP< const Integer > &n)
Multiplicative order. Return false if order does not exist.
void quotient_mod_f(const Ptr< RCP< const Integer >> &q, const Ptr< RCP< const Integer >> &r, const Integer &n, const Integer &d)
std::pair< integer_class, integer_class > mp_perfect_power_decomposition(const integer_class &n, bool lowest_exponent)
Decompose a positive integer into perfect powers.
void primitive_root_list(std::vector< RCP< const Integer >> &roots, const Integer &n)
int factor_trial_division(const Ptr< RCP< const Integer >> &f, const Integer &n)
int factor_pollard_pm1_method(const Ptr< RCP< const Integer >> &f, const Integer &n, unsigned B, unsigned retries)
Factor using Pollard's p-1 method.
int probab_prime_p(const Integer &a, unsigned reps)
Probabilistic Prime.
RCP< const Integer > totient(const RCP< const Integer > &n)
Euler's totient function.
bool is_nth_residue(const Integer &a, const Integer &n, const Integer &mod)
Returns true if 'a' is a nth power residue of 'mod'.
int factor_pollard_rho_method(const Ptr< RCP< const Integer >> &f, const Integer &n, unsigned retries)
Factor using Pollard's rho methods.
bool crt(const Ptr< RCP< const Integer >> &R, const std::vector< RCP< const Integer >> &rem, const std::vector< RCP< const Integer >> &mod)
Chinese remainder function. Return true when a solution exists.
int factor(const Ptr< RCP< const Integer >> &f, const Integer &n, double B1)
RCP< const Integer > factorial(unsigned long n)
Factorial.
RCP< const Integer > carmichael(const RCP< const Integer > &n)
Carmichael function.
void gcd_ext(const Ptr< RCP< const Integer >> &g, const Ptr< RCP< const Integer >> &s, const Ptr< RCP< const Integer >> &t, const Integer &a, const Integer &b)
Extended GCD.
integer_class mp_principal_polygonal_root(const integer_class &s, const integer_class &x)
Numeric calculation of the principal s-gonal root of x.
void powermod_list(std::vector< RCP< const Integer >> &pows, const RCP< const Integer > &a, const RCP< const Number > &b, const RCP< const Integer > &m)
RCP< const Number > bernoulli(unsigned long n)
void quotient_mod(const Ptr< RCP< const Integer >> &q, const Ptr< RCP< const Integer >> &r, const Integer &n, const Integer &d)
int legendre(const Integer &a, const Integer &n)
Legendre Function.
RCP< const Number > harmonic(unsigned long n, long m)
Computes the sum of the inverses of the first perfect mth powers.
int factor_lehman_method(const Ptr< RCP< const Integer >> &f, const Integer &n)
Factor using lehman's methods.
void lucas2(const Ptr< RCP< const Integer >> &g, const Ptr< RCP< const Integer >> &s, unsigned long n)
Lucas number n and n-1.