29 #ifndef BIG_INTEGER_GMP_HEADER_GUARD
30 #define BIG_INTEGER_GMP_HEADER_GUARD
43 #pragma warning(disable: 4127)//disable "warning C4127: conditional expression is constant"
44 #pragma warning(disable: 4146)//disable "warning C4146: unary minus operator applied to unsigned type, result still unsigned"
46 #pragma warning(pop)//restore warnings
50 #elif defined(LIB_MPIR)
53 #pragma warning(disable: 4127)//disable "warning C4127: conditional expression is constant"
54 #include "mpir/mpir.h"
55 #pragma warning(pop)//restore warnings
70 #define MILLER_RABIN_PRIMALITY_TEST_COUNT 10
73 class RandomProviderGmp;
222 #endif//BIG_INTEGER_GMP_HEADER_GUARD
static void Modulo(BigIntegerBase< BigIntegerGmp > &output, const BigIntegerBase< BigIntegerGmp > &input, const BigIntegerBase< BigIntegerGmp > &n)
Computes input mod n.
static void Lcm(BigIntegerBase< BigIntegerGmp > &output, const BigIntegerBase< BigIntegerGmp > &lhs, const BigIntegerBase< BigIntegerGmp > &rhs)
Computes the least common multiple of lhs and rhs.
static void LeftShift(BigIntegerBase< BigIntegerGmp > &output, const BigIntegerBase< BigIntegerGmp > &input, const unsigned long numberOfBits)
Bitwise left shift input by numberOfBits.
Wrapper for the required GMP library random number specific functions.
static void Gcd(BigIntegerBase< BigIntegerGmp > &output, const BigIntegerBase< BigIntegerGmp > &lhs, const BigIntegerBase< BigIntegerGmp > &rhs)
Computes the greatest common divisor of lhs and rhs.
static void Swap(BigIntegerBase< BigIntegerGmp > &lhs, BigIntegerBase< BigIntegerGmp > &rhs)
Swaps lhs with rhs efficiently.
Definition of class BigIntegerBase.
RandomProviderGmp RandomGeneratorImpl
Generic alias required by BigIntegerBase to grant the GMP random provider wrapper access to its priva...
static void InvertModN(BigIntegerBase< BigIntegerGmp > &output, const BigIntegerBase< BigIntegerGmp > &input, const BigIntegerBase< BigIntegerGmp > &n)
Inverts input modulo n.
static void Destroy(BigIntegerBase< BigIntegerGmp > &input)
Destroys the underlying data from input.
static int GetBit(const BigIntegerBase< BigIntegerGmp > &input, const size_t index)
Returns the bit specified by index.
static void Subtract(BigIntegerBase< BigIntegerGmp > &output, const BigIntegerBase< BigIntegerGmp > &lhs, const BigIntegerBase< BigIntegerGmp > &rhs)
Subtracts rhs from lhs.
static void Pow(BigIntegerBase< BigIntegerGmp > &output, const BigIntegerBase< BigIntegerGmp > &input, const BigIntegerBase< BigIntegerGmp > &power)
Raises input to the specified power.
static void Initialize(BigIntegerBase< BigIntegerGmp > &input)
Initializes the underlying data from input.
static void BitwiseXor(BigIntegerBase< BigIntegerGmp > &output, const BigIntegerBase< BigIntegerGmp > &lhs, const BigIntegerBase< BigIntegerGmp > &rhs)
Computes lhs bitwise exclusive OR rhs.
static void BitwiseOr(BigIntegerBase< BigIntegerGmp > &output, const BigIntegerBase< BigIntegerGmp > &lhs, const BigIntegerBase< BigIntegerGmp > &rhs)
Computes lhs bitwise inclusive OR rhs.
static void InvertSign(BigIntegerBase< BigIntegerGmp > &output, const BigIntegerBase< BigIntegerGmp > &input)
Inverts the sign of input.
static void RightShift(BigIntegerBase< BigIntegerGmp > &output, const BigIntegerBase< BigIntegerGmp > &input, const unsigned long numberOfBits)
Bitwise right shift input by numberOfBits.
static void Abs(BigIntegerBase< BigIntegerGmp > &output, const BigIntegerBase< BigIntegerGmp > &input)
Computes the absolute value of input.
static size_t GetSize(const BigIntegerBase< BigIntegerGmp > &input, const unsigned int base=2)
Gets the length of the integer in the specified base.
static bool IsPrime(const BigIntegerBase< BigIntegerGmp > &input)
Tests if input is a prime number.
static void InvertBits(BigIntegerBase< BigIntegerGmp > &output, const BigIntegerBase< BigIntegerGmp > &input)
Computes one's complement of input.
static void Add(BigIntegerBase< BigIntegerGmp > &output, const BigIntegerBase< BigIntegerGmp > &lhs, const BigIntegerBase< BigIntegerGmp > &rhs)
Adds lhs and rhs.
static std::string ToString(const BigIntegerBase< BigIntegerGmp > &input, const unsigned int base=2)
Convert input to std::string in the specified base.
static void PowModN(BigIntegerBase< BigIntegerGmp > &output, const BigIntegerBase< BigIntegerGmp > &input, const BigIntegerBase< BigIntegerGmp > &power, const BigIntegerBase< BigIntegerGmp > &n)
Raises input to the specified power modulo n.
static void Multiply(BigIntegerBase< BigIntegerGmp > &output, const BigIntegerBase< BigIntegerGmp > &lhs, const BigIntegerBase< BigIntegerGmp > &rhs)
Multiplies lhs with rhs.
static void Divide(BigIntegerBase< BigIntegerGmp > &output, const BigIntegerBase< BigIntegerGmp > &lhs, const BigIntegerBase< BigIntegerGmp > &rhs)
Divides lhs by rhs.
mpz_t BigIntegerType
Generic alias required by BigIntegerBase to define the underlying data member.
static void Set(BigIntegerBase< BigIntegerGmp > &input, const BigIntegerBase< BigIntegerGmp > &value)
Sets input to the specified BigInteger value.
static void GetNextPrime(BigIntegerBase< BigIntegerGmp > &output, const BigIntegerBase< BigIntegerGmp > &input)
Computes the first prime greater than the current instance.
static void BitwiseAnd(BigIntegerBase< BigIntegerGmp > &output, const BigIntegerBase< BigIntegerGmp > &lhs, const BigIntegerBase< BigIntegerGmp > &rhs)
Computes lhs bitwise AND rhs.
Wrapper class for the most common functions related to the mpz_t datatype of the GMP library...
Template class which adds syntactic sugar to big integer operations.
static unsigned long ToUnsignedLong(const BigIntegerBase< BigIntegerGmp > &input)
Convert input to unsigned long.
static int Compare(const BigIntegerBase< BigIntegerGmp > &lhs, const BigIntegerBase< BigIntegerGmp > &rhs)
Compares lhs to rhs.
static void SetBit(BigIntegerBase< BigIntegerGmp > &input, const size_t index)
Sets a bit in input at the specified index.