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:
[legend]

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
 Addition.
 
RationalNumberoperator+= (const RationalNumber &i)
 Addition assignment.
 
RationalNumber operator- (const RationalNumber &i) const
 Subtraction.
 
RationalNumberoperator-= (const RationalNumber &i)
 Subtraction assignment.
 
RationalNumber operator- () const
 Negation.
 
RationalNumber operator* (const RationalNumber &i) const
 Multiplication.
 
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...
 

Friends

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
inlinevirtual

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
virtual

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
virtual

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
inlinevirtual

GCD(a, b)

Parameters
bThe other rational number

Implements BPASGCDDomain< RationalNumber >.

◆ inverse()

RationalNumber RationalNumber::inverse ( ) const
inlinevirtual

Get the inverse of *this.

Returns
the inverse

Implements BPASField< RationalNumber >.

◆ isConstant()

int RationalNumber::isConstant ( ) const
inline

Is a constant.

Parameters

◆ isNegativeOne()

bool RationalNumber::isNegativeOne ( ) const
inline

Is a -1.

Parameters

◆ isOne()

bool RationalNumber::isOne ( ) const
inlinevirtual

Is a 1.

Parameters

Implements BPASRing< RationalNumber >.

◆ isZero()

bool RationalNumber::isZero ( ) const
inlinevirtual

Is a zero.

Parameters

Implements BPASRing< RationalNumber >.

◆ negativeOne()

void RationalNumber::negativeOne ( )
inline

Assign to negative one.

Parameters

◆ one()

void RationalNumber::one ( )
inlinevirtual

Assign to one.

Parameters

Implements BPASRing< RationalNumber >.

◆ operator!=()

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

Inequality test,.

returns true iff not equal.

Implements BPASRing< RationalNumber >.

◆ operator%()

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

Get the remainder of *this and b;.

Parameters
bthe divisor
Returns
the remainder

Implements BPASEuclideanDomain< RationalNumber >.

◆ operator%=()

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

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

Parameters
bthe divisor
Returns
this after assignment.

Implements BPASEuclideanDomain< RationalNumber >.

◆ operator==()

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

Equality test,.

returns true iff equal

Implements BPASRing< RationalNumber >.

◆ operator^()

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

Overload operator ^ replace xor operation by exponentiation.

Parameters
eThe exponentiation

Implements BPASRing< RationalNumber >.

◆ unitCanonical()

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

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 ( )
inlinevirtual

Assign to zero.

Parameters

Implements BPASRing< RationalNumber >.


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