2 #ifndef _BIG_PRIME_FIELD_H_ 3 #define _BIG_PRIME_FIELD_H_ 5 #include "BPASFiniteField.hpp" 31 static mpz_class prime;
36 static mpz_class characteristic;
80 static void setPrime(mpz_class p){
86 return characteristic;
90 mpz_class Prime()
const;
92 mpz_class number()
const;
94 void whichprimefield();
97 return BigPrimeField::findPrimitiveRootofUnity(mpz_class(n));
102 if ( ((prime - 1) % n != 0)){
103 cout <<
"ERROR: n does not divide prime - 1." << endl;
107 mpz_class q = (prime - 1) / n;
111 mpz_class test = q * n / 2;
115 if ((c^test) == p1) {
122 cout <<
"No primitive root found!"<< endl;
153 inline bool isNegativeOne()
const {
154 return (a == (prime - 1));
157 inline void negativeOne() {
161 inline int isConstant()
const {
173 inline bool operator== (
const mpz_class& k)
const {
201 inline bool operator!= (
const mpz_class& k)
const {
344 mpz_class b(std::to_string(c), 10);
410 std::cout <<
"BPAS: error, dividend is zero from SmallPrimeField."<< std::endl;
470 std::vector<BigPrimeField> ret;
471 ret.push_back(*
this);
508 if (!mpz_invert(temp, a.get_mpz_t(), prime.get_mpz_t()))
510 mpz_class temp_class(temp);
ExpressionTree convertToExpressionTree() const
Convert this to an expression tree.
Definition: BigPrimeField.hpp:387
BigPrimeField quotient(const BigPrimeField &b) const
Get the quotient of *this and b.
BigPrimeField remainder(const BigPrimeField &b) const
Get the remainder of *this and b.
BigPrimeField & operator^=(long long int c)
Exponentiation assignment.
Definition: BigPrimeField.hpp:377
A sparsely represented univariate polynomial over an arbitrary ring.
Definition: BigPrimeField.hpp:21
bool isZero() const
Determine if *this ring element is zero, that is the additive identity.
Definition: BigPrimeField.hpp:137
An arbitrary-precision complex rational number.
Definition: ComplexRationalNumber.hpp:23
void one()
Make *this ring element one.
Definition: BigPrimeField.hpp:149
BigPrimeField operator*(const BigPrimeField &c) const
Multiplication.
Definition: BigPrimeField.hpp:304
BigPrimeField & operator+=(const BigPrimeField &c)
Addition assignment.
Definition: BigPrimeField.hpp:240
An ExpressionTree encompasses various forms of data that can be expressed generically as a binary tre...
Definition: ExpressionTree.hpp:17
mpz_class getCharacteristic() const override
The characteristic of this ring class.
Definition: BigPrimeField.hpp:85
BigPrimeField gcd(const BigPrimeField &other) const
Get GCD of *this and other.
Definition: BigPrimeField.hpp:437
A finite field whose prime should be a generalized fermat number.
Definition: GeneralizedFermatPrimeField.hpp:36
BigPrimeField & operator/=(const BigPrimeField &c)
Exact division assignment.
Definition: BigPrimeField.hpp:408
BigPrimeField unitCanonical(BigPrimeField *u=NULL, BigPrimeField *v=NULL) const
Obtain the unit normal (a.k.a canonical associate) of an element.
A prime field whose prime is 32 bits or less.
Definition: SmallPrimeField.hpp:450
BigPrimeField extendedEuclidean(const BigPrimeField &b, BigPrimeField *s=NULL, BigPrimeField *t=NULL) const
Perform the extended euclidean division on *this and b.
A univariate polynomial with Integer coefficients using a dense representation.
Definition: uzpolynomial.h:14
bool operator!=(const BigPrimeField &c) const
Inequality test,.
Definition: BigPrimeField.hpp:195
BigPrimeField operator^(long long int c) const
Exponentiation.
Definition: BigPrimeField.hpp:342
BigPrimeField & operator*=(const BigPrimeField &c)
Multiplication assignment.
Definition: BigPrimeField.hpp:319
bool operator==(const BigPrimeField &c) const
Equality test,.
Definition: BigPrimeField.hpp:167
A univariate polynomial with RationalNumber coefficients represented densely.
Definition: urpolynomial.h:16
A prime field whose prime can be arbitrarily large.
Definition: BigPrimeField.hpp:27
BigPrimeField operator%(const BigPrimeField &c) const
Get the remainder of *this and b;.
Definition: BigPrimeField.hpp:428
BigPrimeField operator-() const
Negation.
Definition: BigPrimeField.hpp:298
BigPrimeField & operator-=(const BigPrimeField &c)
Subtraction assignment.
Definition: BigPrimeField.hpp:276
A simple data structure for encapsulating a collection of Factor elements.
Definition: Factors.hpp:95
BigPrimeField & operator%=(const BigPrimeField &c)
Assign *this to be the remainder of *this and b.
Definition: BigPrimeField.hpp:432
An arbitrary-precision Integer.
Definition: Integer.hpp:22
Integer euclideanSize() const
Get the euclidean size of *this.
Definition: BigPrimeField.hpp:478
bool isOne() const
Determine if *this ring element is one, that is the multiplication identity.
Definition: BigPrimeField.hpp:145
void zero()
Make *this ring element zero.
Definition: BigPrimeField.hpp:141
BigPrimeField operator/(const BigPrimeField &c) const
Exact division.
Definition: BigPrimeField.hpp:391
An arbitrary-precision rational number.
Definition: RationalNumber.hpp:24
BigPrimeField operator+(const BigPrimeField &c) const
Addition.
Definition: BigPrimeField.hpp:223
Factors< BigPrimeField > squareFree() const
Compute squarefree factorization of *this.
Definition: BigPrimeField.hpp:469
BigPrimeField euclideanDivision(const BigPrimeField &b, BigPrimeField *q=NULL) const
Perform the eucldiean division of *this and b.
BigPrimeField & operator=(const BigPrimeField &c)
Copy assignment.
BigPrimeField inverse() const
Get the inverse of *this.
Definition: BigPrimeField.hpp:504
ExprTreeNode is a single node in the bianry tree of an ExpressionTree.
Definition: ExprTreeNode.hpp:76
An abstract class defining the interface of a prime field.
Definition: BPASFiniteField.hpp:12