7#ifndef SYMENGINE_NTHEORY_H
8#define SYMENGINE_NTHEORY_H
19RCP<const Integer>
nextprime(
const Integer &a);
23RCP<const Integer>
gcd(
const Integer &a,
const Integer &b);
25RCP<const Integer>
lcm(
const Integer &a,
const Integer &b);
27void gcd_ext(
const Ptr<RCP<const Integer>> &g,
const Ptr<RCP<const Integer>> &s,
28 const Ptr<RCP<const Integer>> &t,
const Integer &a,
31RCP<const Integer>
mod(
const Integer &n,
const Integer &d);
33RCP<const Integer>
quotient(
const Integer &n,
const Integer &d);
36 const Ptr<RCP<const Integer>> &r,
const Integer &a,
39RCP<const Integer>
mod_f(
const Integer &n,
const Integer &d);
41RCP<const Integer>
quotient_f(
const Integer &n,
const Integer &d);
44 const Ptr<RCP<const Integer>> &r,
const Integer &a,
47int mod_inverse(
const Ptr<RCP<const Integer>> &b,
const Integer &a,
51bool crt(
const Ptr<RCP<const Integer>> &R,
56RCP<const Integer>
fibonacci(
unsigned long n);
59void fibonacci2(
const Ptr<RCP<const Integer>> &g,
60 const Ptr<RCP<const Integer>> &s,
unsigned long n);
63RCP<const Integer>
lucas(
unsigned long n);
66void lucas2(
const Ptr<RCP<const Integer>> &g,
const Ptr<RCP<const Integer>> &s,
70RCP<const Integer>
binomial(
const Integer &n,
unsigned long k);
73RCP<const Integer>
factorial(
unsigned long n);
76bool divides(
const Integer &a,
const Integer &b);
80int 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);
105RCP<const Number>
bernoulli(
unsigned long n);
107RCP<const Number>
harmonic(
unsigned long n,
long m = 1);
110bool primitive_root(
const Ptr<RCP<const Integer>> &g,
const Integer &n);
116RCP<const Integer>
totient(
const RCP<const Integer> &n);
118RCP<const Integer>
carmichael(
const RCP<const Integer> &n);
121 const RCP<const Integer> &a,
122 const RCP<const Integer> &n);
124int legendre(
const Integer &a,
const Integer &n);
126int jacobi(
const Integer &a,
const Integer &n);
128int kronecker(
const Integer &a,
const Integer &n);
131 const RCP<const Integer> &a,
const RCP<const Integer> &n,
132 const RCP<const Integer> &m);
134bool 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);
139bool 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);
160int mobius(
const Integer &a);
163long 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)
RCP< const Integer > nextprime(const Integer &a)
int kronecker(const Integer &a, const Integer &n)
Kronecker Function.
void quotient_mod_f(const Ptr< RCP< const Integer > > &q, const Ptr< RCP< const Integer > > &r, const Integer &n, const Integer &d)
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.
RCP< const Integer > mod(const Integer &n, const Integer &d)
modulo round toward zero
int mobius(const Integer &a)
Mobius Function.
void lucas2(const Ptr< RCP< const Integer > > &g, const Ptr< RCP< const Integer > > &s, unsigned long n)
Lucas number n and n-1.
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.
RCP< const Integer > lucas(unsigned long n)
Lucas number.
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.
RCP< const Integer > quotient_f(const Integer &n, const Integer &d)
void prime_factors(std::vector< RCP< const Integer > > &prime_list, const Integer &n)
Find prime factors of n
RCP< const Integer > fibonacci(unsigned long n)
Fibonacci number.
bool primitive_root(const Ptr< RCP< const Integer > > &g, const Integer &n)
Computes a primitive root. Returns false if no primitive root exists.
bool is_quad_residue(const Integer &a, const Integer &p)
Returns true if 'a' is a quadratic residue of 'p'.
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.
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)
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.
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 > lcm(const Integer &a, const Integer &b)
Least Common Multiple.
RCP< const Integer > binomial(const Integer &n, unsigned long k)
Binomial Coefficient.
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.
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_lehman_method(const Ptr< RCP< const Integer > > &f, const Integer &n)
Factor using lehman's methods.
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.
std::pair< integer_class, integer_class > mp_perfect_power_decomposition(const integer_class &n, bool lowest_exponent)
Decompose a positive integer into perfect powers.
int factor(const Ptr< RCP< const Integer > > &f, const Integer &n, double B1)
int factor_trial_division(const Ptr< RCP< const Integer > > &f, const Integer &n)
void fibonacci2(const Ptr< RCP< const Integer > > &g, const Ptr< RCP< const Integer > > &s, unsigned long n)
Fibonacci n and n-1.
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.
RCP< const Integer > factorial(unsigned long n)
Factorial.
RCP< const Integer > carmichael(const RCP< const Integer > &n)
Carmichael function.
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 quotient_mod(const Ptr< RCP< const Integer > > &q, const Ptr< RCP< const Integer > > &r, const Integer &n, const Integer &d)
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)
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 mod_inverse(const Ptr< RCP< const Integer > > &b, const Integer &a, const Integer &m)
inverse modulo
void primitive_root_list(std::vector< RCP< const Integer > > &roots, const Integer &n)