Basic Polynomial Algebra Subprograms (BPAS)  v. 1.791
Public Member Functions | Friends | List of all members
RationalNumber Class Reference

An arbitrary-precision rational number. More...

#include <RationalNumber.hpp>

Simplified semantic inheritance diagram for RationalNumber:
- Full inheritance diagram for RationalNumber:

Public Member Functions

 RationalNumber (int a, int b=1)
 RationalNumber (const std::string &digits, int base=10)
 RationalNumber (const mpq_t &q)
 RationalNumber (const mpq_class &a)
 RationalNumber (const mpz_class &a, const mpz_class &b=mpz_class(1))
 RationalNumber (const RationalNumber &a)
 RationalNumber (const Integer &a)
 RationalNumber (const ComplexRationalNumber &a)
 RationalNumber (const SmallPrimeField &a)
 RationalNumber (const BigPrimeField &a)
 RationalNumber (const GeneralizedFermatPrimeField &a)
 RationalNumber (const DenseUnivariateIntegerPolynomial &a)
 RationalNumber (const DenseUnivariateRationalPolynomial &a)
 RationalNumber (const SparseUnivariatePolynomial< Integer > &a)
 RationalNumber (const SparseUnivariatePolynomial< RationalNumber > &a)
 RationalNumber (const SparseUnivariatePolynomial< ComplexRationalNumber > &a)
 RationalNumber (const SparseMultivariateRationalPolynomial &a)
template<class Ring >
 RationalNumber (const SparseUnivariatePolynomial< Ring > &a)
RationalNumberRNpointer (RationalNumber *a)
RationalNumberRNpointer (SmallPrimeField *a)
RationalNumberRNpointer (BigPrimeField *a)
RationalNumberRNpointer (GeneralizedFermatPrimeField *a)
RationalNumberset (int a, int b)
mpq_class get_mpq () const
mpq_class & get_mpq_ref ()
const mpq_class & get_mpq_ref () const
mpq_ptr get_mpq_t ()
mpq_srcptr get_mpq_t () const
Integer get_num () const
double get_d () const
Integer get_den () const
bool isZero () const
 Is a zero. More...
void zero ()
 Assign to zero. More...
bool isOne () const
 Is a 1. More...
void one ()
 Assign to one. More...
bool isNegativeOne () const
 Is a -1. More...
void negativeOne ()
 Assign to negative one. More...
int isConstant () const
 Is a constant. More...
RationalNumber unitCanonical (RationalNumber *u=NULL, RationalNumber *v=NULL) const
 Obtain the unit normal (a.k.a canonical associate) of an element. More...
RationalNumberoperator= (const RationalNumber &a)
 Copy assignment.
RationalNumber operator+ (const RationalNumber &i) const
RationalNumberoperator+= (const RationalNumber &i)
 Addition assignment.
RationalNumber operator- (const RationalNumber &i) const
RationalNumberoperator-= (const RationalNumber &i)
 Subtraction assignment.
RationalNumber operator- () const
RationalNumber operator* (const RationalNumber &i) const
RationalNumberoperator*= (const RationalNumber &i)
 Multiplication assignment.
bool operator== (const RationalNumber &i) const
 Equality test,. More...
bool operator!= (const RationalNumber &i) const
 Inequality test,. More...
ExpressionTree convertToExpressionTree () const
 Convert this to an expression tree. More...
RationalNumber operator/ (const RationalNumber &i) const
 Exact division.
RationalNumberoperator/= (const RationalNumber &i)
 Exact division assignment.
bool operator< (const RationalNumber &r) const
bool operator<= (const RationalNumber &r) const
bool operator> (const RationalNumber &r) const
bool operator>= (const RationalNumber &r) const
RationalNumber gcd (const RationalNumber &b) const
 GCD(a, b) More...
Factors< RationalNumbersquareFree () const
 Compute squarefree factorization of *this.
Integer euclideanSize () const
 Get the euclidean size of *this.
RationalNumber euclideanDivision (const RationalNumber &b, RationalNumber *q=NULL) const
 Perform the eucldiean division of *this and b. More...
RationalNumber extendedEuclidean (const RationalNumber &b, RationalNumber *s=NULL, RationalNumber *t=NULL) const
 Perform the extended euclidean division on *this and b. More...
RationalNumber quotient (const RationalNumber &b) const
 Get the quotient of *this and b.
RationalNumber remainder (const RationalNumber &b) const
 Get the remainder of *this and b.
RationalNumber operator^ (long long int e) const
 Overload operator ^ replace xor operation by exponentiation. More...
RationalNumberoperator^= (long long int e)
 Exponentiation assignment.
RationalNumber operator% (const RationalNumber &r) const
 Get the remainder of *this and b;. More...
RationalNumberoperator%= (const RationalNumber &r)
 Assign *this to be the remainder of *this and b. More...
RationalNumber inverse () const
 Get the inverse of *this. More...


RationalNumber operator+ (int a, const RationalNumber &r)
RationalNumber operator- (int a, const RationalNumber &r)
RationalNumber operator* (int a, const RationalNumber &r)
RationalNumber operator/ (int a, const RationalNumber &r)
RationalNumber operator+ (long int a, const RationalNumber &r)
RationalNumber operator- (long int a, const RationalNumber &r)
RationalNumber operator* (long int a, const RationalNumber &r)
RationalNumber operator/ (long int a, const RationalNumber &r)
RationalNumber abs (const RationalNumber &i)

Detailed Description

An arbitrary-precision rational number.

Member Function Documentation

◆ convertToExpressionTree()

ExpressionTree RationalNumber::convertToExpressionTree ( ) const

Convert this to an expression tree.

returns an expression tree describing *this.

Implements ExpressionTreeConvert.

◆ euclideanDivision()

RationalNumber RationalNumber::euclideanDivision ( const RationalNumber b,
RationalNumber q = NULL 
) const

Perform the eucldiean division of *this and b.

Returns the remainder. If q is not NULL, then returns the quotient in q.

Implements BPASEuclideanDomain< RationalNumber >.

◆ extendedEuclidean()

RationalNumber RationalNumber::extendedEuclidean ( const RationalNumber b,
RationalNumber s = NULL,
RationalNumber t = NULL 
) const

Perform the extended euclidean division on *this and b.

Returns the GCD. If s and t are not NULL, returns the bezout coefficients in them.

Implements BPASEuclideanDomain< RationalNumber >.

◆ gcd()

RationalNumber RationalNumber::gcd ( const RationalNumber b) const

GCD(a, b)

bThe other rational number

Implements BPASGCDDomain< RationalNumber >.

◆ inverse()

RationalNumber RationalNumber::inverse ( ) const

Get the inverse of *this.

the inverse

Implements BPASField< RationalNumber >.

◆ isConstant()

int RationalNumber::isConstant ( ) const

Is a constant.


◆ isNegativeOne()

bool RationalNumber::isNegativeOne ( ) const

Is a -1.


◆ isOne()

bool RationalNumber::isOne ( ) const

Is a 1.


Implements BPASRing< RationalNumber >.

◆ isZero()

bool RationalNumber::isZero ( ) const

Is a zero.


Implements BPASRing< RationalNumber >.

◆ negativeOne()

void RationalNumber::negativeOne ( )

Assign to negative one.


◆ one()

void RationalNumber::one ( )

Assign to one.


Implements BPASRing< RationalNumber >.

◆ operator!=()

bool RationalNumber::operator!= ( const RationalNumber i) const

Inequality test,.

returns true iff not equal.

Implements BPASRing< RationalNumber >.

◆ operator%()

RationalNumber RationalNumber::operator% ( const RationalNumber b) const

Get the remainder of *this and b;.

bthe divisor
the remainder

Implements BPASEuclideanDomain< RationalNumber >.

◆ operator%=()

RationalNumber& RationalNumber::operator%= ( const RationalNumber b)

Assign *this to be the remainder of *this and b.

bthe divisor
this after assignment.

Implements BPASEuclideanDomain< RationalNumber >.

◆ operator==()

bool RationalNumber::operator== ( const RationalNumber i) const

Equality test,.

returns true iff equal

Implements BPASRing< RationalNumber >.

◆ operator^()

RationalNumber RationalNumber::operator^ ( long long int  e) const

Overload operator ^ replace xor operation by exponentiation.

eThe exponentiation

Implements BPASRing< RationalNumber >.

◆ unitCanonical()

RationalNumber RationalNumber::unitCanonical ( RationalNumber u = NULL,
RationalNumber v = NULL 
) const

Obtain the unit normal (a.k.a canonical associate) of an element.

If either parameters u, v, are non-NULL then the units are returned such that b = ua, v = u^-1. Where b is the unit normal of a, and is the returned value.

Implements BPASRing< RationalNumber >.

◆ zero()

void RationalNumber::zero ( )

Assign to zero.


Implements BPASRing< RationalNumber >.

The documentation for this class was generated from the following file: