Scippy

SoPlex

Sequential object-oriented simPlex

Rational Class Reference

Wrapper for GMP type mpq_class.We wrap mpq_class so that we can replace it by a double type if GMP is not available. More...

#include <rational.h>

Classes

class  Private
 Defines the "Pimpl"-class Private. More...
 

Public Member Functions

GMP Only methods

Methods of the Rational class that are only available if SoPlex is compiled with "-DGMP=on"

Rationaloperator= (const mpq_t &q)
 assignment operator from mpq_t More...
 
Typecasts
 operator double () const
 typecasts Rational to double (allows only explicit typecast) More...
 
 operator long double () const
 typecasts Rational to long double (allows only explicit typecast) More...
 
 operator float () const
 typecasts Rational to float (allows only explicit typecast) More...
 
const mpq_t * getMpqPtr () const
 provides read-only access to underlying mpq_t More...
 
const mpq_t & getMpqRef () const
 provides read-only access to underlying mpq_t More...
 
mpq_t * getMpqPtr_w () const
 provides write access to underlying mpq_t; use with care More...
 
mpq_t & getMpqRef_w () const
 provides write access to underlying mpq_t; use with care More...
 
Arithmetic operators
Rational operator+ (const Rational &r) const
 addition operator More...
 
Rationaloperator+= (const Rational &r)
 addition assignment operator More...
 
Rational operator+ (const double &r) const
 addition operator for doubles More...
 
Rationaloperator+= (const double &r)
 addition assignment operator for doubles More...
 
Rational operator+ (const int &r) const
 addition operator for ints More...
 
Rationaloperator+= (const int &r)
 addition assignment operator for ints More...
 
Rational operator- (const Rational &r) const
 subtraction operator More...
 
Rationaloperator-= (const Rational &r)
 subtraction assignment operator More...
 
Rational operator- (const double &r) const
 subtraction operator for doubles More...
 
Rationaloperator-= (const double &r)
 subtraction assignment operator for doubles More...
 
Rational operator- (const int &r) const
 subtraction operator for ints More...
 
Rationaloperator-= (const int &r)
 subtraction assignment operator for ints More...
 
Rational operator* (const Rational &r) const
 multiplication operator More...
 
Rationaloperator*= (const Rational &r)
 multiplication assignment operator operator More...
 
Rational operator* (const double &r) const
 multiplication operator for doubles More...
 
Rationaloperator*= (const double &r)
 multiplication assignment operator for doubles More...
 
Rational operator* (const int &r) const
 multiplication operator for ints More...
 
Rationaloperator*= (const int &r)
 multiplication assignment operator for ints More...
 
Rational operator/ (const Rational &r) const
 division operator More...
 
Rationaloperator/= (const Rational &r)
 division assignment operator More...
 
Rational operator/ (const double &r) const
 division operator for doubles More...
 
Rationaloperator/= (const double &r)
 division assignment operator for doubles More...
 
Rational operator/ (const int &r) const
 division operator for ints More...
 
Rationaloperator/= (const int &r)
 division assignment operator for ints More...
 
RationaladdProduct (const Rational &r, const Rational &s)
 add product of two rationals More...
 
RationalsubProduct (const Rational &r, const Rational &s)
 subtract product of two rationals More...
 
RationaladdQuotient (const Rational &r, const Rational &s)
 add quotient of two rationals, r divided by s More...
 
RationalsubQuotient (const Rational &r, const Rational &s)
 subtract quotient of two rationals, r divided by s More...
 
Rationalinvert ()
 inversion More...
 
RationalpowRound ()
 round up to next power of two More...
 
Methods for checking exactness of doubles
bool isNextTo (const double &d)
 checks if d is the closest number that can be represented by double More...
 
bool isAdjacentTo (const double &d) const
 checks if d is exactly equal to the Rational and if not, if it is one of the two adjacent doubles More...
 
Methods for querying size
int sizeInBase (const int base=2) const
 Size in specified base (bit size for base 2) More...
 

Static Public Member Functions

Static methods
static int precision ()
 returns precision of Rational implementation, i.e., number of bits used to store Rational numbers (INT_MAX if exact) More...
 

Private Member Functions

 Rational (const int &i, const bool &dummy)
 special constructor only for initializing static rational variables; this is necessary since we need a constructor for Rational::{ZERO, POSONE, NEGONE} that does not use these numbers More...
 

Private Attributes

Privatedpointer
 

Static Private Attributes

static THREADLOCAL IdList< PrivateunusedPrivateList
 list of unused Private objects More...
 
static THREADLOCAL bool useListMem = true
 list of unused Private objects; note that this cannot be used if SOPLEX_WITH_GMP is not defined, since then the Private class has no member next() and prev() should list memory be used? More...
 
Static variables for special rational values
static const Rational ZERO
 rational zero (GMP only) More...
 
static const Rational POSONE
 rational plus one (GMP only) More...
 
static const Rational NEGONE
 rational minus one (GMP only) More...
 

Friends

Friends
int compareRational (const Rational &r, const Rational &s)
 comparison operator returning a positive value if r > s, zero if r = s, and a negative value if r < s More...
 
bool operator!= (const Rational &r, const Rational &s)
 inequality operator More...
 
bool operator== (const Rational &r, const Rational &s)
 equality operator More...
 
bool operator< (const Rational &r, const Rational &s)
 less than operator More...
 
bool operator<= (const Rational &r, const Rational &s)
 less than or equal to operator More...
 
bool operator> (const Rational &r, const Rational &s)
 greater than operator More...
 
bool operator>= (const Rational &r, const Rational &s)
 greater than or equal to operator More...
 
bool operator!= (const Rational &r, const double &s)
 inequality operator for Rational and double More...
 
bool operator== (const Rational &r, const double &s)
 equality operator for Rational and double More...
 
bool operator< (const Rational &r, const double &s)
 less than operator for Rational and double More...
 
bool operator<= (const Rational &r, const double &s)
 less than or equal to operator for Rational and double More...
 
bool operator> (const Rational &r, const double &s)
 greater than operator for Rational and double More...
 
bool operator>= (const Rational &r, const double &s)
 greater than or equal to operator for Rational and double More...
 
bool operator!= (const double &r, const Rational &s)
 inequality operator double and Rational More...
 
bool operator== (const double &r, const Rational &s)
 equality operator for double and Rational More...
 
bool operator< (const double &r, const Rational &s)
 less than operator double and Rational More...
 
bool operator<= (const double &r, const Rational &s)
 less than or equal to operator double and Rational More...
 
bool operator> (const double &r, const Rational &s)
 greater than operator double and Rational More...
 
bool operator>= (const double &r, const Rational &s)
 greater than or equal to operator double and Rational More...
 
bool operator!= (const Rational &r, const long double &s)
 inequality operator for Rational and long double More...
 
bool operator== (const Rational &r, const long double &s)
 equality operator for Rational and long double More...
 
bool operator< (const Rational &r, const long double &s)
 less than operator for Rational and long double More...
 
bool operator<= (const Rational &r, const long double &s)
 less than or equal to operator for Rational and long double More...
 
bool operator> (const Rational &r, const long double &s)
 greater than operator for Rational and long double More...
 
bool operator>= (const Rational &r, const long double &s)
 greater than or equal to operator for Rational and long double More...
 
bool operator!= (const long double &r, const Rational &s)
 inequality operator for long double and Rational More...
 
bool operator== (const long double &r, const Rational &s)
 equality operator for long double and Rational More...
 
bool operator< (const long double &r, const Rational &s)
 less than operator for long double and Rational More...
 
bool operator<= (const long double &r, const Rational &s)
 less than or equal to operator for long double and Rational More...
 
bool operator> (const long double &r, const Rational &s)
 greater than operator for long double and Rational More...
 
bool operator>= (const long double &r, const Rational &s)
 greater than or equal to operator for long double and Rational More...
 
bool operator!= (const Rational &r, const float &s)
 inequality operator for Rational and float More...
 
bool operator== (const Rational &r, const float &s)
 equality operator for Rational and float More...
 
bool operator< (const Rational &r, const float &s)
 less than operator for Rational and float More...
 
bool operator<= (const Rational &r, const float &s)
 less than or equal to operator for Rational and float More...
 
bool operator> (const Rational &r, const float &s)
 greater than operator for Rational and float More...
 
bool operator>= (const Rational &r, const float &s)
 greater than or equal to operator for Rational and float More...
 
bool operator!= (const float &r, const Rational &s)
 inequality operator for float and Rational More...
 
bool operator== (const float &r, const Rational &s)
 equality operator for float and Rational More...
 
bool operator< (const float &r, const Rational &s)
 less than operator for float and Rational More...
 
bool operator<= (const float &r, const Rational &s)
 less than or equal to operator for float and Rational More...
 
bool operator> (const float &r, const Rational &s)
 greater than operator for float and Rational More...
 
bool operator>= (const float &r, const Rational &s)
 greater than or equal to operator for float and Rational More...
 
Rational operator+ (const double &d, const Rational &r)
 addition operator for double and Rational More...
 
Rational operator- (const double &d, const Rational &r)
 subtraction operator for double and Rational More...
 
Rational operator* (const double &d, const Rational &r)
 multiplication operator for double and Rational More...
 
Rational operator/ (const double &d, const Rational &r)
 division operator for double and Rational More...
 
bool operator!= (const Rational &r, const int &s)
 inequality operator for Rational and int More...
 
bool operator== (const Rational &r, const int &s)
 equality operator for Rational and int More...
 
bool operator< (const Rational &r, const int &s)
 less than operator for Rational and int More...
 
bool operator<= (const Rational &r, const int &s)
 less than or equal to operator for Rational and int More...
 
bool operator> (const Rational &r, const int &s)
 greater than operator for Rational and int More...
 
bool operator>= (const Rational &r, const int &s)
 greater than or equal to operator for Rational and int More...
 
bool operator!= (const int &r, const Rational &s)
 inequality operator int and Rational More...
 
bool operator== (const int &r, const Rational &s)
 equality operator for int and Rational More...
 
bool operator< (const int &r, const Rational &s)
 less than operator int and Rational More...
 
bool operator<= (const int &r, const Rational &s)
 less than or equal to operator int and Rational More...
 
bool operator> (const int &r, const Rational &s)
 greater than operator int and Rational More...
 
bool operator>= (const int &r, const Rational &s)
 greater than or equal to operator int and Rational More...
 
Rational operator+ (const int &d, const Rational &r)
 addition operator for int and Rational More...
 
Rational operator- (const int &d, const Rational &r)
 subtraction operator for int and Rational More...
 
Rational operator* (const int &d, const Rational &r)
 multiplication operator for int and Rational More...
 
Rational operator/ (const int &d, const Rational &r)
 division operator for int and Rational More...
 
Rational spxAbs (const Rational &r)
 Absolute. More...
 
int sign (const Rational &r)
 Sign function; returns 1 if r > 0, 0 if r = 0, and -1 if r < 0. More...
 
Rational operator- (const Rational &q)
 Negation. More...
 

Construction and destruction

 Rational ()
 default constructor More...
 
 Rational (const Rational &r)
 copy constructor More...
 
 Rational (const long double &r)
 constructor from long double More...
 
 Rational (const double &r)
 constructor from double More...
 
 Rational (const int &i)
 constructor from int More...
 
 Rational (const mpq_t &q)
 constructor from mpq_t (GMP only) More...
 
 ~Rational ()
 destructor More...
 
Rationaloperator= (const Rational &)
 assignment operator More...
 
Rationaloperator= (const long double &r)
 assignment operator from long double More...
 
Rationaloperator= (const double &r)
 assignment operator from double More...
 
Rationaloperator= (const int &i)
 assignment operator from int More...
 
static void enableListMem ()
 enables list memory More...
 
static void freeListMem ()
 frees the unused rational elements in the memory list More...
 
static void disableListMem ()
 disables list memory More...
 

Conversion from and to String

bool readString (const char *s)
 read Rational from string More...
 
std::string rationalToString (const Rational &r, const int precision)
 convert rational number to string More...
 
bool readStringRational (const char *s, Rational &value)
 read Rational from string More...
 
std::ostream & operator<< (std::ostream &os, const Rational &q)
 print Rational More...
 

Detailed Description

Wrapper for GMP type mpq_class.

We wrap mpq_class so that we can replace it by a double type if GMP is not available.

If compiled with GMP support, Rational is defined as mpq_class.

Definition at line 62 of file rational.h.

Constructor & Destructor Documentation

◆ Rational() [1/7]

Rational ( const int &  i,
const bool &  dummy 
)
private

special constructor only for initializing static rational variables; this is necessary since we need a constructor for Rational::{ZERO, POSONE, NEGONE} that does not use these numbers

Definition at line 95 of file rational.cpp.

References Rational::dpointer, Rational::Private::privatevalue, and soplex::spx_alloc().

◆ Rational() [2/7]

◆ Rational() [3/7]

Rational ( const Rational r)

copy constructor

Definition at line 140 of file rational.cpp.

References Rational::dpointer, soplex::spx_alloc(), and Rational::unusedPrivateList.

◆ Rational() [4/7]

Rational ( const long double &  r)

constructor from long double

Definition at line 173 of file rational.cpp.

References Rational::dpointer, soplex::spx_alloc(), and Rational::unusedPrivateList.

◆ Rational() [5/7]

Rational ( const double &  r)

constructor from double

Definition at line 206 of file rational.cpp.

References Rational::dpointer, soplex::spx_alloc(), and Rational::unusedPrivateList.

◆ Rational() [6/7]

Rational ( const int &  i)

constructor from int

Definition at line 239 of file rational.cpp.

References Rational::dpointer, soplex::spx_alloc(), and Rational::unusedPrivateList.

◆ Rational() [7/7]

Rational ( const mpq_t &  q)

constructor from mpq_t (GMP only)

constructor from mpq_t

Definition at line 272 of file rational.cpp.

References Rational::dpointer, soplex::spx_alloc(), and Rational::unusedPrivateList.

◆ ~Rational()

Member Function Documentation

◆ addProduct()

Rational & addProduct ( const Rational r,
const Rational s 
)

add product of two rationals

Definition at line 1389 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

Referenced by soplex::dmaxSizeRational(), and VectorBase< Rational >::operator*().

◆ addQuotient()

Rational & addQuotient ( const Rational r,
const Rational s 
)

add quotient of two rationals, r divided by s

Definition at line 1493 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

Referenced by soplex::dmaxSizeRational().

◆ disableListMem()

void disableListMem ( )
static

disables list memory

Definition at line 351 of file rational.cpp.

References Rational::freeListMem().

Referenced by soplex::dmaxSizeRational(), and main().

◆ enableListMem()

void enableListMem ( )
static

enables list memory

Definition at line 328 of file rational.cpp.

References Rational::unusedPrivateList.

Referenced by soplex::dmaxSizeRational().

◆ freeListMem()

void freeListMem ( )
static

frees the unused rational elements in the memory list

frees the unused rational elements in the memory list frees the unused rational elements in the memory list

this can be useful when you want to save memory or needed when working with a GMP memory manager like the one in EGlib that frees GMP memory before the destructor of the static memory list is called; in most cases this method is optional; note that this does not free the Rational elements that are currently in use

Definition at line 342 of file rational.cpp.

References Rational::unusedPrivateList.

Referenced by Rational::disableListMem(), and soplex::dmaxSizeRational().

◆ getMpqPtr()

const mpq_t * getMpqPtr ( ) const

provides read-only access to underlying mpq_t

Definition at line 472 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

◆ getMpqPtr_w()

mpq_t * getMpqPtr_w ( ) const

provides write access to underlying mpq_t; use with care

Definition at line 488 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

◆ getMpqRef()

const mpq_t & getMpqRef ( ) const

provides read-only access to underlying mpq_t

Definition at line 480 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

Referenced by soplex::dlcmSizeRational(), soplex::dmaxSizeRational(), and soplex::Reconstruct().

◆ getMpqRef_w()

mpq_t & getMpqRef_w ( ) const

provides write access to underlying mpq_t; use with care

Definition at line 496 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

◆ invert()

◆ isAdjacentTo()

bool isAdjacentTo ( const double &  d) const

checks if d is exactly equal to the Rational and if not, if it is one of the two adjacent doubles

checks if d is exactly equal to the Rational and if not, if it is one of the two adjacent doubles

Definition at line 1636 of file rational.cpp.

References Rational::dpointer, soplex::infinity, Rational::Private::privatevalue, and soplex::spxNextafter().

Referenced by soplex::dmaxSizeRational().

◆ isNextTo()

bool isNextTo ( const double &  d)

checks if d is the closest number that can be represented by double

checks if d is the closest possible double

Definition at line 1609 of file rational.cpp.

References Rational::dpointer, soplex::infinity, Rational::Private::privatevalue, Rational::Rational(), Rational::spxAbs, and soplex::spxNextafter().

Referenced by soplex::dmaxSizeRational().

◆ operator double()

operator double ( ) const

typecasts Rational to double (allows only explicit typecast)

Definition at line 407 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

◆ operator float()

operator float ( ) const

typecasts Rational to float (allows only explicit typecast)

Definition at line 451 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

◆ operator long double()

operator long double ( ) const

typecasts Rational to long double (allows only explicit typecast)

Definition at line 430 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

◆ operator*() [1/3]

Rational operator* ( const Rational r) const

multiplication operator

Definition at line 868 of file rational.cpp.

References Rational::dpointer, Rational::Private::privatevalue, and Rational::ZERO.

Referenced by soplex::dmaxSizeRational().

◆ operator*() [2/3]

Rational operator* ( const double &  r) const

multiplication operator for doubles

Definition at line 947 of file rational.cpp.

References Rational::dpointer, Rational::Private::privatevalue, and Rational::ZERO.

◆ operator*() [3/3]

Rational operator* ( const int &  r) const

multiplication operator for ints

Definition at line 1034 of file rational.cpp.

References Rational::dpointer, Rational::Private::privatevalue, and Rational::ZERO.

◆ operator*=() [1/3]

Rational & operator*= ( const Rational r)

multiplication assignment operator operator

multiplication assignment operator

Definition at line 905 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

Referenced by soplex::dmaxSizeRational().

◆ operator*=() [2/3]

Rational & operator*= ( const double &  r)

multiplication assignment operator for doubles

Definition at line 989 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

◆ operator*=() [3/3]

Rational & operator*= ( const int &  r)

multiplication assignment operator for ints

Definition at line 1076 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

◆ operator+() [1/3]

Rational operator+ ( const Rational r) const

addition operator

Definition at line 504 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

Referenced by soplex::dmaxSizeRational().

◆ operator+() [2/3]

Rational operator+ ( const double &  r) const

addition operator for doubles

Definition at line 559 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

◆ operator+() [3/3]

Rational operator+ ( const int &  r) const

addition operator for ints

Definition at line 620 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

◆ operator+=() [1/3]

Rational & operator+= ( const Rational r)

addition assignment operator

Definition at line 532 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

Referenced by soplex::dmaxSizeRational().

◆ operator+=() [2/3]

Rational & operator+= ( const double &  r)

addition assignment operator for doubles

Definition at line 588 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

◆ operator+=() [3/3]

Rational & operator+= ( const int &  r)

addition assignment operator for ints

Definition at line 649 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

◆ operator-() [1/3]

Rational operator- ( const Rational r) const

subtraction operator

Definition at line 681 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

Referenced by soplex::dmaxSizeRational().

◆ operator-() [2/3]

Rational operator- ( const double &  r) const

subtraction operator for doubles

Definition at line 744 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

◆ operator-() [3/3]

Rational operator- ( const int &  r) const

subtraction operator for ints

Definition at line 806 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

◆ operator-=() [1/3]

Rational & operator-= ( const Rational r)

subtraction assignment operator

Definition at line 709 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

Referenced by soplex::dmaxSizeRational().

◆ operator-=() [2/3]

Rational & operator-= ( const double &  r)

subtraction assignment operator for doubles

Definition at line 773 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

◆ operator-=() [3/3]

Rational & operator-= ( const int &  r)

subtraction assignment operator for ints

Definition at line 835 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

◆ operator/() [1/3]

Rational operator/ ( const Rational r) const

division operator

Definition at line 1121 of file rational.cpp.

References Rational::dpointer, Rational::invert(), Rational::Private::privatevalue, and Rational::ZERO.

Referenced by soplex::dmaxSizeRational().

◆ operator/() [2/3]

Rational operator/ ( const double &  r) const

division operator for doubles

Definition at line 1205 of file rational.cpp.

References Rational::dpointer, Rational::invert(), Rational::Private::privatevalue, and Rational::ZERO.

◆ operator/() [3/3]

Rational operator/ ( const int &  r) const

division operator for ints

Definition at line 1297 of file rational.cpp.

References Rational::dpointer, Rational::invert(), Rational::Private::privatevalue, and Rational::ZERO.

◆ operator/=() [1/3]

Rational & operator/= ( const Rational r)

division assignment operator

Definition at line 1163 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

Referenced by soplex::dmaxSizeRational().

◆ operator/=() [2/3]

Rational & operator/= ( const double &  r)

division assignment operator for doubles

Definition at line 1250 of file rational.cpp.

References Rational::dpointer, Rational::invert(), and Rational::Private::privatevalue.

◆ operator/=() [3/3]

Rational & operator/= ( const int &  r)

division assignment operator for ints

Definition at line 1342 of file rational.cpp.

References Rational::dpointer, Rational::invert(), and Rational::Private::privatevalue.

◆ operator=() [1/5]

Rational & operator= ( const Rational r)

assignment operator

Definition at line 360 of file rational.cpp.

References Rational::dpointer.

Referenced by soplex::dmaxSizeRational(), Rational::Private::next(), and Rational::Private::operator=().

◆ operator=() [2/5]

Rational & operator= ( const long double &  r)

assignment operator from long double

Definition at line 369 of file rational.cpp.

References Rational::dpointer.

◆ operator=() [3/5]

Rational & operator= ( const double &  r)

assignment operator from double

Definition at line 378 of file rational.cpp.

References Rational::dpointer.

◆ operator=() [4/5]

Rational & operator= ( const int &  i)

assignment operator from int

Definition at line 389 of file rational.cpp.

References Rational::dpointer.

◆ operator=() [5/5]

Rational & operator= ( const mpq_t &  q)

assignment operator from mpq_t

Definition at line 398 of file rational.cpp.

References Rational::dpointer.

◆ powRound()

Rational & powRound ( )

round up to next power of two

Definition at line 1576 of file rational.cpp.

References Rational::dpointer, MSG_DEBUG, Rational::Private::privatevalue, and Rational::rationalToString.

Referenced by soplex::dmaxSizeRational().

◆ precision()

int precision ( )
static

returns precision of Rational implementation, i.e., number of bits used to store Rational numbers (INT_MAX if exact)

Definition at line 1680 of file rational.cpp.

Referenced by soplex::dmaxSizeRational().

◆ readString()

◆ sizeInBase()

int sizeInBase ( const int  base = 2) const

Size in specified base (bit size for base 2)

Definition at line 1671 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

Referenced by soplex::dmaxSizeRational(), and soplex::totalSizeRational().

◆ subProduct()

Rational & subProduct ( const Rational r,
const Rational s 
)

subtract product of two rationals

Definition at line 1440 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

Referenced by soplex::dmaxSizeRational().

◆ subQuotient()

Rational & subQuotient ( const Rational r,
const Rational s 
)

subtract quotient of two rationals, r divided by s

Definition at line 1530 of file rational.cpp.

References Rational::dpointer, and Rational::Private::privatevalue.

Referenced by soplex::dmaxSizeRational().

Friends And Related Function Documentation

◆ compareRational

int compareRational ( const Rational r,
const Rational s 
)
friend

comparison operator returning a positive value if r > s, zero if r = s, and a negative value if r < s

Definition at line 2076 of file rational.cpp.

Referenced by soplex::dmaxSizeRational().

◆ operator!= [1/9]

bool operator!= ( const Rational r,
const Rational s 
)
friend

inequality operator

Definition at line 2092 of file rational.cpp.

Referenced by soplex::dmaxSizeRational().

◆ operator!= [2/9]

bool operator!= ( const Rational r,
const double &  s 
)
friend

inequality operator for Rational and double

Definition at line 2152 of file rational.cpp.

◆ operator!= [3/9]

bool operator!= ( const double &  r,
const Rational s 
)
friend

inequality operator double and Rational

inequality operator for double and Rational

Definition at line 2260 of file rational.cpp.

◆ operator!= [4/9]

bool operator!= ( const Rational r,
const long double &  s 
)
friend

inequality operator for Rational and long double

Definition at line 2320 of file rational.cpp.

◆ operator!= [5/9]

bool operator!= ( const long double &  r,
const Rational s 
)
friend

inequality operator for long double and Rational

Definition at line 2428 of file rational.cpp.

◆ operator!= [6/9]

bool operator!= ( const Rational r,
const float &  s 
)
friend

inequality operator for Rational and float

Definition at line 2487 of file rational.cpp.

◆ operator!= [7/9]

bool operator!= ( const float &  r,
const Rational s 
)
friend

inequality operator for float and Rational

Definition at line 2595 of file rational.cpp.

◆ operator!= [8/9]

bool operator!= ( const Rational r,
const int &  s 
)
friend

inequality operator for Rational and int

Definition at line 2720 of file rational.cpp.

◆ operator!= [9/9]

bool operator!= ( const int &  r,
const Rational s 
)
friend

inequality operator int and Rational

inequality operator for int and Rational

Definition at line 2828 of file rational.cpp.

◆ operator* [1/2]

Rational operator* ( const double &  d,
const Rational r 
)
friend

multiplication operator for double and Rational

Definition at line 2653 of file rational.cpp.

◆ operator* [2/2]

Rational operator* ( const int &  d,
const Rational r 
)
friend

multiplication operator for int and Rational

Definition at line 2887 of file rational.cpp.

◆ operator+ [1/2]

Rational operator+ ( const double &  d,
const Rational r 
)
friend

addition operator for double and Rational

Definition at line 2635 of file rational.cpp.

◆ operator+ [2/2]

Rational operator+ ( const int &  d,
const Rational r 
)
friend

addition operator for int and Rational

Definition at line 2868 of file rational.cpp.

◆ operator- [1/3]

Rational operator- ( const double &  d,
const Rational r 
)
friend

subtraction operator for double and Rational

Definition at line 2642 of file rational.cpp.

◆ operator- [2/3]

Rational operator- ( const int &  d,
const Rational r 
)
friend

subtraction operator for int and Rational

Definition at line 2876 of file rational.cpp.

◆ operator- [3/3]

Rational operator- ( const Rational q)
friend

Negation.

Definition at line 2952 of file rational.cpp.

◆ operator/ [1/2]

Rational operator/ ( const double &  d,
const Rational r 
)
friend

division operator for double and Rational

Definition at line 2672 of file rational.cpp.

◆ operator/ [2/2]

Rational operator/ ( const int &  d,
const Rational r 
)
friend

division operator for int and Rational

Definition at line 2906 of file rational.cpp.

◆ operator< [1/9]

bool operator< ( const Rational r,
const Rational s 
)
friend

less than operator

Definition at line 2100 of file rational.cpp.

Referenced by soplex::dmaxSizeRational().

◆ operator< [2/9]

bool operator< ( const Rational r,
const double &  s 
)
friend

less than operator for Rational and double

Definition at line 2172 of file rational.cpp.

◆ operator< [3/9]

bool operator< ( const double &  r,
const Rational s 
)
friend

less than operator double and Rational

less than operator for double and Rational

Definition at line 2268 of file rational.cpp.

◆ operator< [4/9]

bool operator< ( const Rational r,
const long double &  s 
)
friend

less than operator for Rational and long double

Definition at line 2340 of file rational.cpp.

◆ operator< [5/9]

bool operator< ( const long double &  r,
const Rational s 
)
friend

less than operator for long double and Rational

Definition at line 2436 of file rational.cpp.

◆ operator< [6/9]

bool operator< ( const Rational r,
const float &  s 
)
friend

less than operator for Rational and float

Definition at line 2507 of file rational.cpp.

◆ operator< [7/9]

bool operator< ( const float &  r,
const Rational s 
)
friend

less than operator for float and Rational

Definition at line 2603 of file rational.cpp.

◆ operator< [8/9]

bool operator< ( const Rational r,
const int &  s 
)
friend

less than operator for Rational and int

Definition at line 2740 of file rational.cpp.

◆ operator< [9/9]

bool operator< ( const int &  r,
const Rational s 
)
friend

less than operator int and Rational

less than operator for int and Rational

Definition at line 2836 of file rational.cpp.

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Rational q 
)
friend

print Rational

Definition at line 2063 of file rational.cpp.

Referenced by soplex::dmaxSizeRational().

◆ operator<= [1/9]

bool operator<= ( const Rational r,
const Rational s 
)
friend

less than or equal to operator

Definition at line 2108 of file rational.cpp.

Referenced by soplex::dmaxSizeRational().

◆ operator<= [2/9]

bool operator<= ( const Rational r,
const double &  s 
)
friend

less than or equal to operator for Rational and double

Definition at line 2192 of file rational.cpp.

◆ operator<= [3/9]

bool operator<= ( const double &  r,
const Rational s 
)
friend

less than or equal to operator double and Rational

less than or equal to operator for double and Rational

Definition at line 2276 of file rational.cpp.

◆ operator<= [4/9]

bool operator<= ( const Rational r,
const long double &  s 
)
friend

less than or equal to operator for Rational and long double

Definition at line 2360 of file rational.cpp.

◆ operator<= [5/9]

bool operator<= ( const long double &  r,
const Rational s 
)
friend

less than or equal to operator for long double and Rational

Definition at line 2444 of file rational.cpp.

◆ operator<= [6/9]

bool operator<= ( const Rational r,
const float &  s 
)
friend

less than or equal to operator for Rational and float

Definition at line 2527 of file rational.cpp.

◆ operator<= [7/9]

bool operator<= ( const float &  r,
const Rational s 
)
friend

less than or equal to operator for float and Rational

Definition at line 2611 of file rational.cpp.

◆ operator<= [8/9]

bool operator<= ( const Rational r,
const int &  s 
)
friend

less than or equal to operator for Rational and int

Definition at line 2760 of file rational.cpp.

◆ operator<= [9/9]

bool operator<= ( const int &  r,
const Rational s 
)
friend

less than or equal to operator int and Rational

less than or equal to operator for int and Rational

Definition at line 2844 of file rational.cpp.

◆ operator== [1/9]

bool operator== ( const Rational r,
const Rational s 
)
friend

equality operator

Definition at line 2084 of file rational.cpp.

Referenced by soplex::dmaxSizeRational().

◆ operator== [2/9]

bool operator== ( const Rational r,
const double &  s 
)
friend

equality operator for Rational and double

Definition at line 2132 of file rational.cpp.

◆ operator== [3/9]

bool operator== ( const double &  r,
const Rational s 
)
friend

equality operator for double and Rational

Definition at line 2252 of file rational.cpp.

◆ operator== [4/9]

bool operator== ( const Rational r,
const long double &  s 
)
friend

equality operator for Rational and long double

Definition at line 2300 of file rational.cpp.

◆ operator== [5/9]

bool operator== ( const long double &  r,
const Rational s 
)
friend

equality operator for long double and Rational

Definition at line 2420 of file rational.cpp.

◆ operator== [6/9]

bool operator== ( const Rational r,
const float &  s 
)
friend

equality operator for Rational and float

Definition at line 2467 of file rational.cpp.

◆ operator== [7/9]

bool operator== ( const float &  r,
const Rational s 
)
friend

equality operator for float and Rational

Definition at line 2587 of file rational.cpp.

◆ operator== [8/9]

bool operator== ( const Rational r,
const int &  s 
)
friend

equality operator for Rational and int

Definition at line 2700 of file rational.cpp.

◆ operator== [9/9]

bool operator== ( const int &  r,
const Rational s 
)
friend

equality operator for int and Rational

Definition at line 2820 of file rational.cpp.

◆ operator> [1/9]

bool operator> ( const Rational r,
const Rational s 
)
friend

greater than operator

Definition at line 2116 of file rational.cpp.

Referenced by soplex::dmaxSizeRational().

◆ operator> [2/9]

bool operator> ( const Rational r,
const double &  s 
)
friend

greater than operator for Rational and double

Definition at line 2212 of file rational.cpp.

◆ operator> [3/9]

bool operator> ( const double &  r,
const Rational s 
)
friend

greater than operator double and Rational

greater than operator for double and Rational

Definition at line 2284 of file rational.cpp.

◆ operator> [4/9]

bool operator> ( const Rational r,
const long double &  s 
)
friend

greater than operator for Rational and long double

Definition at line 2380 of file rational.cpp.

◆ operator> [5/9]

bool operator> ( const long double &  r,
const Rational s 
)
friend

greater than operator for long double and Rational

Definition at line 2452 of file rational.cpp.

◆ operator> [6/9]

bool operator> ( const Rational r,
const float &  s 
)
friend

greater than operator for Rational and float

Definition at line 2547 of file rational.cpp.

◆ operator> [7/9]

bool operator> ( const float &  r,
const Rational s 
)
friend

greater than operator for float and Rational

Definition at line 2619 of file rational.cpp.

◆ operator> [8/9]

bool operator> ( const Rational r,
const int &  s 
)
friend

greater than operator for Rational and int

Definition at line 2780 of file rational.cpp.

◆ operator> [9/9]

bool operator> ( const int &  r,
const Rational s 
)
friend

greater than operator int and Rational

greater than operator for int and Rational

Definition at line 2852 of file rational.cpp.

◆ operator>= [1/9]

bool operator>= ( const Rational r,
const Rational s 
)
friend

greater than or equal to operator

Definition at line 2124 of file rational.cpp.

Referenced by soplex::dmaxSizeRational().

◆ operator>= [2/9]

bool operator>= ( const Rational r,
const double &  s 
)
friend

greater than or equal to operator for Rational and double

Definition at line 2232 of file rational.cpp.

◆ operator>= [3/9]

bool operator>= ( const double &  r,
const Rational s 
)
friend

greater than or equal to operator double and Rational

greater than or equal to operator for double and Rational

Definition at line 2292 of file rational.cpp.

◆ operator>= [4/9]

bool operator>= ( const Rational r,
const long double &  s 
)
friend

greater than or equal to operator for Rational and long double

Definition at line 2400 of file rational.cpp.

◆ operator>= [5/9]

bool operator>= ( const long double &  r,
const Rational s 
)
friend

greater than or equal to operator for long double and Rational

Definition at line 2460 of file rational.cpp.

◆ operator>= [6/9]

bool operator>= ( const Rational r,
const float &  s 
)
friend

greater than or equal to operator for Rational and float

Definition at line 2567 of file rational.cpp.

◆ operator>= [7/9]

bool operator>= ( const float &  r,
const Rational s 
)
friend

greater than or equal to operator for float and Rational

Definition at line 2627 of file rational.cpp.

◆ operator>= [8/9]

bool operator>= ( const Rational r,
const int &  s 
)
friend

greater than or equal to operator for Rational and int

Definition at line 2800 of file rational.cpp.

◆ operator>= [9/9]

bool operator>= ( const int &  r,
const Rational s 
)
friend

greater than or equal to operator int and Rational

greater than or equal to operator for int and Rational

Definition at line 2860 of file rational.cpp.

◆ rationalToString

std::string rationalToString ( const Rational r,
const int  precision 
)
friend

convert rational number to string

Definition at line 1858 of file rational.cpp.

Referenced by soplex::dmaxSizeRational(), and Rational::powRound().

◆ readStringRational

bool readStringRational ( const char *  s,
Rational value 
)
friend

read Rational from string

Definition at line 1897 of file rational.cpp.

Referenced by soplex::dmaxSizeRational().

◆ sign

int sign ( const Rational r)
friend

Sign function; returns 1 if r > 0, 0 if r = 0, and -1 if r < 0.

Definition at line 2944 of file rational.cpp.

Referenced by soplex::dmaxSizeRational().

◆ spxAbs

Rational spxAbs ( const Rational r)
friend

Absolute.

absolute function

Definition at line 2934 of file rational.cpp.

Referenced by soplex::dmaxSizeRational(), and Rational::isNextTo().

Member Data Documentation

◆ dpointer

◆ NEGONE

const Rational NEGONE
staticprivate

rational minus one (GMP only)

Definition at line 82 of file rational.h.

Referenced by Rational::Private::operator=(), and Rational::Private::Private().

◆ POSONE

const Rational POSONE
staticprivate

rational plus one (GMP only)

Definition at line 81 of file rational.h.

Referenced by Rational::Private::operator=(), and Rational::Private::Private().

◆ unusedPrivateList

THREADLOCAL IdList< Rational::Private > unusedPrivateList
staticprivate

◆ useListMem

THREADLOCAL bool useListMem = true
staticprivate

list of unused Private objects; note that this cannot be used if SOPLEX_WITH_GMP is not defined, since then the Private class has no member next() and prev() should list memory be used?

Definition at line 70 of file rational.h.

Referenced by Rational::Private::next().

◆ ZERO

const Rational ZERO
staticprivate