Template classes with Number theory algorithms implementations.
compile all tests by mkdir build; make
run make clean
to clean build dir
run make clean_tests
to clean tests executables
integer factorization by trial division
factorize.h
- template classes
factorize_tests.cpp
- tests and usage examples, compile by make factorize_tests
PrimesArray
- holds array of primes
Factorizer
- integer factorization by trial division
PrimeChecker
- check whether number is a prime, uses Factorizer which uses trial division
DivisorsCounter
- calculate count of divisors of given number
SumOfTwoSquaresChecker
- check whether number is sum of two squares (including summand 0) by theorem about sum of two squares
canonical representation of integer
canonic_factors.h
- template classes
canonic_factors_tests.cpp
- tests and usage examples, compile by make canonic_factors_tests
CanonicFactorsTemplate
- surrounding template with typedefs
CanonicFactorsTemplate::PrimePow
- power of prime: stores prime and it's exponent
CanonicFactorsTemplate::CanonicFactorizer
- uses Factorizer
CanonicFactorsTemplate::CanonicFactors
- main class, canonical representation of integer
CanonicFactors
, =
, assign
(empty, PrimePow
or other object) - constructors and assign operators
CanonicFactors
, =
, assign
(basic integer) - constructors and assign operators which factorize given number using CanonicFactorizer
value
- compute value as product of powers of primes
*
, *=
- multiplication with basic integer or other object
mul_pow
, mul_pow_assign
- multiplication with PrimePow
mul_static
- multiplication of two objects
lcm
- calculate least common multiple of two objects
eulers_phi
- calculate Euler's phi function
carmichael
- calculate Carmichael function
mul_mod.h
- utility template class MulMod
for multiplication by modulo
mul_mod
- modular multiplication
square_mod
- modular squaring
pow_mod
- fast modular exponentiation by squaring
multiplicative group modulo n
mul_group_mod.h
- template class MulGroupMod
for finding element order or primitive root
mul_group_mod_tests.cpp
- tests and usage examples, compile by make mul_group_mod_tests
MulGroupMod
- construct object from modulo n
element_order
- calculate order of element of multiplicative group modulo n
is_primitive_root
- check whether element is a primitive root modulo n
primitive root modulo n checker, maybe slightly more efficient then MulGroupMod
primitive_roots.h
template class PrimitiveRoots
for primitive root checking
primitive_roots_tests.cpp
- tests and usage examples, compile by make primitive_roots_tests
PrimitiveRoots
- construct object from modulo n
is_primitive_root
- check whether element is a primitive root modulo n
quadratic congruences modulo n
square_root_mod.h
- template class SquareRootMod
for solving quadratic congruences
square_root_mod_tests.cpp
- tests and usage examples, compile by make square_root_mod_tests
SquareRootMod
- construct object from modulo n for storing and using already calculated data
legendre_symbol
- calculate Legendre symbol by Euler's criterion (not the most efficient)
least_nonresidue
- find Least quadratic non-residue modulo n
tonelli_shanks_algo
- Tonelli-Shanks algorithm implementation, optimized by storing and using already calculated data
square_root_mod
- wrapper for tonelli_shanks_algo