2 #ifndef _BPAS_RATIONAL_NUMBER_H_ 3 #define _BPAS_RATIONAL_NUMBER_H_ 5 #include "BPASField.hpp" 30 static RingProperties properties;
46 RationalNumber (
const mpz_class& a,
const mpz_class& b = mpz_class(1));
85 inline mpq_class get_mpq()
const {
89 inline mpq_class& get_mpq_ref() {
93 inline const mpq_class& get_mpq_ref()
const {
97 inline mpq_ptr get_mpq_t() {
98 return _m.get_mpq_t();
101 inline mpq_srcptr get_mpq_t()
const {
102 return _m.get_mpq_t();
105 inline Integer get_num()
const {
109 double get_d()
const {
113 inline Integer get_den()
const {
233 mpq_neg(ret._m.get_mpq_t(), (*this)._m.get_mpq_t());
328 std::vector<RationalNumber> ret;
329 ret.push_back(*
this);
337 std::cerr <<
"RationalNumber::euclideanSize NOT YET IMPLMENETED" << std::endl;
373 mpz_pow_ui(r._m.get_num_mpz_t(), _m.get_num_mpz_t(), (
unsigned long int) e);
374 mpz_pow_ui(r._m.get_den_mpz_t(), _m.get_den_mpz_t(), (
unsigned long int) e);
394 mpz_set(ret._m.get_den_mpz_t(), _m.get_num_mpz_t());
395 mpz_set(ret._m.get_num_mpz_t(), _m.get_den_mpz_t());
396 ret._m.canonicalize();
RationalNumber & operator+=(const RationalNumber &i)
Addition assignment.
Definition: RationalNumber.hpp:206
RationalNumber operator^(long long int e) const
Overload operator ^ replace xor operation by exponentiation.
Definition: RationalNumber.hpp:371
A univariate polynomial over an arbitrary BPASRing represented sparsely.
Definition: BigPrimeField.hpp:21
void negativeOne()
Assign to negative one.
Definition: RationalNumber.hpp:167
void zero()
Assign to zero.
Definition: RationalNumber.hpp:131
A multivariate polynomial with RationalNumber coefficients represented sparely.
Definition: mrpolynomial.h:70
An arbitrary-precision complex rational number.
Definition: ComplexRationalNumber.hpp:23
bool isZero() const
Is a zero.
Definition: RationalNumber.hpp:122
Factors< RationalNumber > squareFree() const
Compute squarefree factorization of *this.
Definition: RationalNumber.hpp:327
void one()
Assign to one.
Definition: RationalNumber.hpp:149
An ExpressionTree encompasses various forms of data that can be expressed generically as a binary tre...
Definition: ExpressionTree.hpp:17
A finite field whose prime should be a generalized fermat number.
Definition: GeneralizedFermatPrimeField.hpp:36
RationalNumber & operator-=(const RationalNumber &i)
Subtraction assignment.
Definition: RationalNumber.hpp:223
bool isOne() const
Is a 1.
Definition: RationalNumber.hpp:140
RationalNumber & operator^=(long long int e)
Exponentiation assignment.
Definition: RationalNumber.hpp:378
RationalNumber gcd(const RationalNumber &b) const
GCD(a, b)
Definition: RationalNumber.hpp:315
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
RationalNumber remainder(const RationalNumber &b) const
Get the remainder of *this and b.
RationalNumber operator*(const RationalNumber &i) const
Multiplication.
Definition: RationalNumber.hpp:240
RationalNumber & operator/=(const RationalNumber &i)
Exact division assignment.
Definition: RationalNumber.hpp:289
RationalNumber & operator*=(const RationalNumber &i)
Multiplication assignment.
Definition: RationalNumber.hpp:249
A univariate polynomial with RationalNumber coefficients represented densely.
Definition: urpolynomial.h:15
A prime field whose prime can be arbitrarily large.
Definition: BigPrimeField.hpp:27
A simple data structure for encapsulating a collection of Factor elements.
Definition: Factors.hpp:95
int isConstant() const
Is a constant.
Definition: RationalNumber.hpp:176
RationalNumber extendedEuclidean(const RationalNumber &b, RationalNumber *s=NULL, RationalNumber *t=NULL) const
Perform the extended euclidean division on *this and b.
An arbitrary-precision Integer.
Definition: Integer.hpp:22
bool operator==(const RationalNumber &i) const
Equality test,.
Definition: RationalNumber.hpp:259
RationalNumber unitCanonical(RationalNumber *u=NULL, RationalNumber *v=NULL) const
Obtain the unit normal (a.k.a canonical associate) of an element.
RationalNumber & operator=(const RationalNumber &a)
Copy assignment.
RationalNumber euclideanDivision(const RationalNumber &b, RationalNumber *q=NULL) const
Perform the eucldiean division of *this and b.
RationalNumber operator-() const
Negation.
Definition: RationalNumber.hpp:231
RationalNumber quotient(const RationalNumber &b) const
Get the quotient of *this and b.
An arbitrary-precision rational number.
Definition: RationalNumber.hpp:24
virtual mpz_class characteristic()
The characteristic of this ring class.
Definition: BPASRing.hpp:87
An abstract class defining the interface of a field.
Definition: BPASField.hpp:11
RationalNumber inverse() const
Get the inverse of *this.
Definition: RationalNumber.hpp:392
RationalNumber operator/(const RationalNumber &i) const
Exact division.
Definition: RationalNumber.hpp:279
RationalNumber & operator%=(const RationalNumber &r)
Assign *this to be the remainder of *this and b.
Definition: RationalNumber.hpp:387
ExprTreeNode is a single node in the bianry tree of an ExpressionTree.
Definition: ExprTreeNode.hpp:76
bool operator!=(const RationalNumber &i) const
Inequality test,.
Definition: RationalNumber.hpp:268
RationalNumber euclideanSize() const
Get the euclidean size of *this.
Definition: RationalNumber.hpp:336
RationalNumber operator%(const RationalNumber &r) const
Get the remainder of *this and b;.
Definition: RationalNumber.hpp:383
ExpressionTree convertToExpressionTree() const
Convert this to an expression tree.
Definition: RationalNumber.hpp:272
RationalNumber operator+(const RationalNumber &i) const
Addition.
Definition: RationalNumber.hpp:197
bool isNegativeOne() const
Is a -1.
Definition: RationalNumber.hpp:158