2 #ifndef _BPAS_INTEGER_H_ 3 #define _BPAS_INTEGER_H_ 5 #include "BPASEuclideanDomain.hpp" 27 static RingProperties properties;
122 template <
class Ring>
125 inline mpz_class& get_mpz_ref() {
129 inline const mpz_class& get_mpz_ref()
const {
133 inline mpz_class get_mpz ()
const {
137 inline mpz_ptr get_mpz_t() {
138 return _m.get_mpz_t();
141 inline mpz_srcptr get_mpz_t()
const {
142 return _m.get_mpz_t();
146 inline double get_d()
const {
150 inline long int get_si()
const {
154 inline unsigned long int get_ui()
const {
274 mpz_neg(ret._m.get_mpz_t(), _m.get_mpz_t());
300 mpz_pow_ui(r._m.get_mpz_t(), _m.get_mpz_t(), (
unsigned long int) e);
318 return (mpz_cmp(_m.get_mpz_t(), i._m.get_mpz_t()) == 0);
327 return (mpz_cmp(_m.get_mpz_t(), i._m.get_mpz_t()) != 0);
330 inline bool operator< (
const Integer& r)
const {
334 inline bool operator<= (
const Integer& r)
const {
338 inline bool operator> (
const Integer& r)
const {
342 inline bool operator>= (
const Integer& r)
const {
370 if (mpz_divisible_p(_m.get_mpz_t(), i._m.get_mpz_t())) {
371 mpz_divexact(_m.get_mpz_t(), _m.get_mpz_t(), i._m.get_mpz_t());
373 std::cerr <<
"BPAS ERROR: Non-exact division in Integer: " << _m <<
" / " << i._m << std::endl;
394 mpz_gcd(c._m.get_mpz_t(), _m.get_mpz_t(), other._m.get_mpz_t());
401 std::vector<Integer> ret;
402 ret.push_back(*
this);
440 return Integer(mpz_class(a) + r._m);
444 return Integer(mpz_class(a) - r._m);
448 return Integer(mpz_class(a) * r._m);
452 return Integer(mpz_class(a) / r._m);
455 inline friend bool operator<(
int a,
const Integer& r) {
459 inline friend bool operator<=(
int a,
const Integer& r) {
463 inline friend bool operator>(
int a,
const Integer& r) {
467 inline friend bool operator>=(
int a,
const Integer& r) {
472 return Integer(mpz_class(a) + r._m);
476 return Integer(mpz_class(a) - r._m);
480 return Integer(mpz_class(a) * r._m);
484 return Integer(mpz_class(a) / r._m);
491 inline friend bool operator<(
long int a,
const Integer& r) {
495 inline friend bool operator<=(
long int a,
const Integer& r) {
499 inline friend bool operator>(
long int a,
const Integer& r) {
503 inline friend bool operator>=(
long int a,
const Integer& r) {
Integer operator-() const
Negation.
Definition: Integer.hpp:272
Integer & operator-=(const Integer &i)
Subtraction assignment.
Definition: Integer.hpp:264
Integer extendedEuclidean(const Integer &b, Integer *s=NULL, Integer *t=NULL) const
Perform the extended euclidean division on *this and b.
A univariate polynomial over an arbitrary BPASRing represented sparsely.
Definition: BigPrimeField.hpp:21
void negativeOne()
Assign to negative one.
Definition: Integer.hpp:208
Integer operator/(const Integer &i) const
Exact division.
Definition: Integer.hpp:359
Integer quotient(const Integer &b) const
Get the quotient of *this and b.
Integer()
Get a zero integer.
An arbitrary-precision complex rational number.
Definition: ComplexRationalNumber.hpp:23
Integer operator+(const Integer &i) const
Addition.
Definition: Integer.hpp:238
Integer & operator/=(const Integer &i)
Exact division assignment.
Definition: Integer.hpp:369
An ExpressionTree encompasses various forms of data that can be expressed generically as a binary tre...
Definition: ExpressionTree.hpp:17
Integer euclideanSize() const
Get the euclidean size of *this.
Definition: Integer.hpp:409
A finite field whose prime should be a generalized fermat number.
Definition: GeneralizedFermatPrimeField.hpp:36
Integer unitCanonical(Integer *u=NULL, Integer *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:449
A univariate polynomial with Integer coefficients using a dense representation.
Definition: uzpolynomial.h:13
bool operator!=(const Integer &i) const
Inequality test,.
Definition: Integer.hpp:326
Integer & operator*=(const Integer &i)
Multiplication assignment.
Definition: Integer.hpp:290
A univariate polynomial with RationalNumber coefficients represented densely.
Definition: urpolynomial.h:15
bool operator==(const Integer &i) const
Equality test,.
Definition: Integer.hpp:317
Integer remainder(const Integer &b) const
Get the remainder of *this and b.
A prime field whose prime can be arbitrarily large.
Definition: BigPrimeField.hpp:27
bool isNegativeOne() const
Is a -1.
Definition: Integer.hpp:199
int isConstant() const
Is a constant.
Definition: Integer.hpp:217
Integer gcd(const Integer &other) const
Get GCD of *this and other.
Definition: Integer.hpp:392
Integer & operator^=(long long int e)
Exponentiation assignment.
Definition: Integer.hpp:307
A simple data structure for encapsulating a collection of Factor elements.
Definition: Factors.hpp:95
ExpressionTree convertToExpressionTree() const
Convert this to an expression tree.
Definition: Integer.hpp:351
Integer & operator%=(const Integer &r)
Assign *this to be the remainder of *this and b.
Definition: Integer.hpp:384
An arbitrary-precision Integer.
Definition: Integer.hpp:22
Integer & operator=(const Integer &a)
Copy assignment.
Integer operator%(const Integer &r) const
Get the remainder of *this and b;.
Definition: Integer.hpp:379
Integer & operator+=(const Integer &i)
Addition assignment.
Definition: Integer.hpp:247
An abstract class defining the interface of a Euclidean domain.
Definition: BPASEuclideanDomain.hpp:12
An arbitrary-precision rational number.
Definition: RationalNumber.hpp:24
virtual mpz_class characteristic()
The characteristic of this ring class.
Definition: BPASRing.hpp:87
Factors< Integer > squareFree() const
Compute squarefree factorization of *this.
Definition: Integer.hpp:400
Integer operator^(long long int e) const
Exponentiation.
Definition: Integer.hpp:298
void zero()
Assign to zero.
Definition: Integer.hpp:172
Integer euclideanDivision(const Integer &b, Integer *q=NULL) const
Perform the eucldiean division of *this and b.
ExprTreeNode is a single node in the bianry tree of an ExpressionTree.
Definition: ExprTreeNode.hpp:76
bool isZero() const
Is a zero.
Definition: Integer.hpp:163
Integer operator*(const Integer &i) const
Multiplication.
Definition: Integer.hpp:281
bool isOne() const
Is a 1.
Definition: Integer.hpp:181
void one()
Assign to one.
Definition: Integer.hpp:190