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 | |
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... | |
Rational | operator+ (const Rational &r) const |
addition operator More... | |
Rational & | operator+= (const Rational &r) |
addition assignment operator More... | |
Rational | operator+ (const double &r) const |
addition operator for doubles More... | |
Rational & | operator+= (const double &r) |
addition assignment operator for doubles More... | |
Rational | operator+ (const int &r) const |
addition operator for ints More... | |
Rational & | operator+= (const int &r) |
addition assignment operator for ints More... | |
Rational | operator- (const Rational &r) const |
subtraction operator More... | |
Rational & | operator-= (const Rational &r) |
subtraction assignment operator More... | |
Rational | operator- (const double &r) const |
subtraction operator for doubles More... | |
Rational & | operator-= (const double &r) |
subtraction assignment operator for doubles More... | |
Rational | operator- (const int &r) const |
subtraction operator for ints More... | |
Rational & | operator-= (const int &r) |
subtraction assignment operator for ints More... | |
Rational | operator* (const Rational &r) const |
multiplication operator More... | |
Rational & | operator*= (const Rational &r) |
multiplication assignment operator operator More... | |
Rational | operator* (const double &r) const |
multiplication operator for doubles More... | |
Rational & | operator*= (const double &r) |
multiplication assignment operator for doubles More... | |
Rational | operator* (const int &r) const |
multiplication operator for ints More... | |
Rational & | operator*= (const int &r) |
multiplication assignment operator for ints More... | |
Rational | operator/ (const Rational &r) const |
division operator More... | |
Rational & | operator/= (const Rational &r) |
division assignment operator More... | |
Rational | operator/ (const double &r) const |
division operator for doubles More... | |
Rational & | operator/= (const double &r) |
division assignment operator for doubles More... | |
Rational | operator/ (const int &r) const |
division operator for ints More... | |
Rational & | operator/= (const int &r) |
division assignment operator for ints More... | |
Rational & | addProduct (const Rational &r, const Rational &s) |
add product of two rationals More... | |
Rational & | subProduct (const Rational &r, const Rational &s) |
subtract product of two rationals More... | |
Rational & | addQuotient (const Rational &r, const Rational &s) |
add quotient of two rationals, r divided by s More... | |
Rational & | subQuotient (const Rational &r, const Rational &s) |
subtract quotient of two rationals, r divided by s More... | |
Rational & | invert () |
inversion More... | |
Rational & | powRound () |
round up to next power of two More... | |
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... | |
int | sizeInBase (const int base=2) const |
Size in specified base (bit size for base 2) More... | |
Static Public Member Functions | |
static int | precision () |
returns precision of Rational implementation, i.e., number of bits used to store Rational numbers (INT_MAX if exact) More... | |
Private Attributes | |
Private * | dpointer |
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 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 long double and Rational More... | |
bool | operator<= (const long double &r, const Rational &s) |
less than or equal to operator long double and Rational More... | |
bool | operator> (const long double &r, const Rational &s) |
greater than operator long double and Rational More... | |
bool | operator>= (const long double &r, const Rational &s) |
greater than or equal to operator long double 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 for 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 for int and Rational More... | |
bool | operator<= (const int &r, const Rational &s) |
less than or equal to operator for int and Rational More... | |
bool | operator> (const int &r, const Rational &s) |
greater than operator for int and Rational More... | |
bool | operator>= (const int &r, const Rational &s) |
greater than or equal to operator for 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... | |
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 () | |
destructor More... | |
Rational & | operator= (const Rational &) |
assignment operator More... | |
Rational & | operator= (const long double &r) |
assignment operator from long double More... | |
Rational & | operator= (const double &r) |
assignment operator from double More... | |
Rational & | operator= (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... | |
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... | |
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 44 of file rational.h.
Rational | ( | ) |
default constructor
Definition at line 3182 of file rational.cpp.
References Rational::dpointer, Rational::Private::Private(), and soplex::spx_alloc().
copy constructor
Definition at line 3192 of file rational.cpp.
References Rational::dpointer, Rational::Private::Private(), and soplex::spx_alloc().
Rational | ( | const long double & | r | ) |
constructor from long double
Definition at line 3202 of file rational.cpp.
References Rational::dpointer, Rational::Private::Private(), and soplex::spx_alloc().
Rational | ( | const double & | r | ) |
constructor from double
Definition at line 3212 of file rational.cpp.
References Rational::dpointer, Rational::Private::Private(), and soplex::spx_alloc().
Rational | ( | const int & | i | ) |
constructor from int
Definition at line 3222 of file rational.cpp.
References Rational::dpointer, Rational::Private::Private(), and soplex::spx_alloc().
~Rational | ( | ) |
destructor
Definition at line 3232 of file rational.cpp.
References Rational::dpointer, and soplex::spx_free().
add product of two rationals
Definition at line 3549 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Referenced by SoPlex::_computeInfeasBox(), and VectorBase< Real >::operator*().
add quotient of two rationals, r divided by s
Definition at line 3567 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
|
static |
|
static |
enables list memory
Definition at line 3240 of file rational.cpp.
|
static |
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 3252 of file rational.cpp.
Rational & invert | ( | ) |
inversion
Definition at line 3585 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Referenced by SoPlex::_performOptIRStable().
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 3611 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
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 3603 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
operator double | ( | ) | const |
typecasts Rational to double (allows only explicit typecast)
Definition at line 3304 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
operator long double | ( | ) | const |
typecasts Rational to long double (allows only explicit typecast)
Definition at line 3312 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
multiplication operator
Definition at line 3435 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Rational operator* | ( | const double & | r | ) | const |
multiplication operator for doubles
Definition at line 3454 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Rational operator* | ( | const int & | r | ) | const |
multiplication operator for ints
Definition at line 3473 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
multiplication assignment operator operator
multiplication assignment operator
Definition at line 3445 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Rational & operator*= | ( | const double & | r | ) |
multiplication assignment operator for doubles
Definition at line 3464 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Rational & operator*= | ( | const int & | r | ) |
multiplication assignment operator for ints
Definition at line 3483 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
addition operator
Definition at line 3321 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Rational operator+ | ( | const double & | r | ) | const |
addition operator for doubles
Definition at line 3340 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Rational operator+ | ( | const int & | r | ) | const |
addition operator for ints
Definition at line 3359 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
addition assignment operator
Definition at line 3331 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Rational & operator+= | ( | const double & | r | ) |
addition assignment operator for doubles
Definition at line 3350 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Rational & operator+= | ( | const int & | r | ) |
addition assignment operator for ints
Definition at line 3369 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
subtraction operator
Definition at line 3378 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Rational operator- | ( | const double & | r | ) | const |
subtraction operator for doubles
Definition at line 3397 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Rational operator- | ( | const int & | r | ) | const |
subtraction operator for ints
Definition at line 3416 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
subtraction assignment operator
Definition at line 3388 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Rational & operator-= | ( | const double & | r | ) |
subtraction assignment operator for doubles
Definition at line 3407 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Rational & operator-= | ( | const int & | r | ) |
subtraction assignment operator for ints
Definition at line 3426 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
division operator
Definition at line 3492 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Rational operator/ | ( | const double & | r | ) | const |
division operator for doubles
Definition at line 3511 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Rational operator/ | ( | const int & | r | ) | const |
division operator for ints
Definition at line 3530 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
division assignment operator
Definition at line 3502 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Rational & operator/= | ( | const double & | r | ) |
division assignment operator for doubles
Definition at line 3521 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Rational & operator/= | ( | const int & | r | ) |
division assignment operator for ints
Definition at line 3540 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Rational & operator= | ( | const long double & | r | ) |
assignment operator from long double
Definition at line 3277 of file rational.cpp.
References Rational::dpointer.
Rational & operator= | ( | const double & | r | ) |
assignment operator from double
Definition at line 3286 of file rational.cpp.
References Rational::dpointer.
Rational & operator= | ( | const int & | i | ) |
assignment operator from int
Definition at line 3295 of file rational.cpp.
References Rational::dpointer.
Rational & powRound | ( | ) |
round up to next power of two
Definition at line 3594 of file rational.cpp.
Referenced by SoPlex::_performOptIRStable().
|
static |
returns precision of Rational implementation, i.e., number of bits used to store Rational numbers (INT_MAX if exact)
Definition at line 3628 of file rational.cpp.
Referenced by Rational::sizeInBase().
bool readString | ( | const char * | s | ) |
read Rational from string
Definition at line 3636 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Referenced by soplex::LPFreadValue(), soplex::MPSreadBounds(), soplex::MPSreadCols(), soplex::MPSreadRanges(), and soplex::MPSreadRhs().
int sizeInBase | ( | const int | base = 2 | ) | const |
Size in specified base (bit size for base 2)
Definition at line 3619 of file rational.cpp.
References Rational::precision().
Referenced by soplex::totalSizeRational().
subtract product of two rationals
Definition at line 3558 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
Referenced by SoPlex::_computeInfeasBox().
subtract quotient of two rationals, r divided by s
Definition at line 3576 of file rational.cpp.
References Rational::dpointer, and Rational::Private::privatevalue.
comparison operator returning a positive value if r > s, zero if r = s, and a negative value if r < s
Definition at line 3672 of file rational.cpp.
inequality operator
Definition at line 3693 of file rational.cpp.
|
friend |
inequality operator for Rational and double
Definition at line 3742 of file rational.cpp.
|
friend |
inequality operator double and Rational
inequality operator for double and Rational
Definition at line 3792 of file rational.cpp.
|
friend |
inequality operator for Rational and long double
Definition at line 3843 of file rational.cpp.
|
friend |
inequality operator long double and Rational
inequality operator for long double and Rational
Definition at line 3893 of file rational.cpp.
|
friend |
inequality operator for Rational and int
Definition at line 3942 of file rational.cpp.
|
friend |
inequality operator for int and Rational
Definition at line 3990 of file rational.cpp.
multiplication operator for double and Rational
Definition at line 4050 of file rational.cpp.
multiplication operator for int and Rational
Definition at line 4086 of file rational.cpp.
addition operator for double and Rational
Definition at line 4030 of file rational.cpp.
addition operator for int and Rational
Definition at line 4070 of file rational.cpp.
subtraction operator for double and Rational
Definition at line 4040 of file rational.cpp.
subtraction operator for int and Rational
Definition at line 4078 of file rational.cpp.
Negation.
Definition at line 4123 of file rational.cpp.
division operator for double and Rational
Definition at line 4060 of file rational.cpp.
division operator for int and Rational
Definition at line 4094 of file rational.cpp.
less than operator
Definition at line 3701 of file rational.cpp.
|
friend |
less than operator for Rational and double
Definition at line 3751 of file rational.cpp.
|
friend |
less than operator double and Rational
less than operator for double and Rational
Definition at line 3801 of file rational.cpp.
|
friend |
less than operator for Rational and long double
Definition at line 3852 of file rational.cpp.
|
friend |
less than operator long double and Rational
less than operator for long double and Rational
Definition at line 3902 of file rational.cpp.
|
friend |
less than operator for Rational and int
Definition at line 3950 of file rational.cpp.
|
friend |
less than operator for int and Rational
Definition at line 3998 of file rational.cpp.
|
friend |
print Rational
Definition at line 3663 of file rational.cpp.
less than or equal to operator
Definition at line 3709 of file rational.cpp.
|
friend |
less than or equal to operator for Rational and double
Definition at line 3759 of file rational.cpp.
|
friend |
less than or equal to operator double and Rational
less than or equal to operator for double and Rational
Definition at line 3809 of file rational.cpp.
|
friend |
less than or equal to operator for Rational and long double
Definition at line 3860 of file rational.cpp.
|
friend |
less than or equal to operator long double and Rational
less than or equal to operator for long double and Rational
Definition at line 3910 of file rational.cpp.
|
friend |
less than or equal to operator for Rational and int
Definition at line 3958 of file rational.cpp.
|
friend |
less than or equal to operator for int and Rational
Definition at line 4006 of file rational.cpp.
equality operator
Definition at line 3685 of file rational.cpp.
|
friend |
equality operator for Rational and double
Definition at line 3733 of file rational.cpp.
|
friend |
equality operator for double and Rational
Definition at line 3783 of file rational.cpp.
|
friend |
equality operator for Rational and long double
Definition at line 3834 of file rational.cpp.
|
friend |
equality operator for long double and Rational
Definition at line 3884 of file rational.cpp.
|
friend |
equality operator for Rational and int
Definition at line 3934 of file rational.cpp.
|
friend |
equality operator for int and Rational
Definition at line 3982 of file rational.cpp.
greater than operator
Definition at line 3717 of file rational.cpp.
|
friend |
greater than operator for Rational and double
Definition at line 3767 of file rational.cpp.
|
friend |
greater than operator double and Rational
greater than operator for double and Rational
Definition at line 3817 of file rational.cpp.
|
friend |
greater than operator for Rational and long double
Definition at line 3868 of file rational.cpp.
|
friend |
greater than operator long double and Rational
greater than operator for long double and Rational
Definition at line 3918 of file rational.cpp.
|
friend |
greater than operator for Rational and int
Definition at line 3966 of file rational.cpp.
|
friend |
greater than operator for int and Rational
Definition at line 4014 of file rational.cpp.
greater than or equal to operator
Definition at line 3725 of file rational.cpp.
|
friend |
greater than or equal to operator for Rational and double
Definition at line 3775 of file rational.cpp.
|
friend |
greater than or equal to operator double and Rational
greater than or equal to operator for double and Rational
Definition at line 3825 of file rational.cpp.
|
friend |
greater than or equal to operator for Rational and long double
Definition at line 3876 of file rational.cpp.
|
friend |
greater than or equal to operator long double and Rational
greater than or equal to operator for long double and Rational
Definition at line 3926 of file rational.cpp.
|
friend |
greater than or equal to operator for Rational and int
Definition at line 3974 of file rational.cpp.
|
friend |
greater than or equal to operator for int and Rational
Definition at line 4022 of file rational.cpp.
|
friend |
convert rational number to string
Definition at line 3645 of file rational.cpp.
|
friend |
read Rational from string
Definition at line 3655 of file rational.cpp.
|
friend |
Sign function; returns 1 if r > 0, 0 if r = 0, and -1 if r < 0.
Definition at line 4115 of file rational.cpp.
|
private |
Definition at line 47 of file rational.h.
Referenced by Rational::addProduct(), Rational::addQuotient(), soplex::compareRational(), Rational::invert(), Rational::isAdjacentTo(), Rational::isNextTo(), Rational::operator double(), Rational::operator long double(), soplex::operator!=(), Rational::operator*(), soplex::operator*(), Rational::operator*=(), Rational::operator+(), soplex::operator+(), Rational::operator+=(), Rational::operator-(), soplex::operator-(), Rational::operator-=(), Rational::operator/(), soplex::operator/(), Rational::operator/=(), soplex::operator<(), soplex::operator<<(), soplex::operator<=(), Rational::operator=(), soplex::operator==(), soplex::operator>(), soplex::operator>=(), Rational::Rational(), Rational::readString(), soplex::readStringRational(), soplex::sign(), soplex::spxAbs(), Rational::subProduct(), Rational::subQuotient(), and Rational::~Rational().