Scippy

SoPlex

Sequential object-oriented simPlex

rational.cpp File Reference

Wrapper for GMP types. More...

#include <cmath>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <limits.h>
#include "rational.h"
#include "spxalloc.h"
#include "spxdefines.h"

Go to the source code of this file.

Classes

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

Namespaces

namespace  soplex
 Everything should be within this namespace.
 

Macros

#define SOPLEX_PERFALT_1
 use mpq_sgn instead of mpq_equal to compare rationals with zero
 
#define SOPLEX_PERFALT_2a
 turn on checking rationals for zero in arithmetic plus and minus operators
 
#define SOPLEX_PERFALT_2b
 turn on checking rationals for zero, posone, negone in arithmetic multiplication and division operators
 
#define SOPLEX_PERFALT_3
 turn on checking rationals for zero, posone, negone before conversion to double and long double
 
#define SOPLEX_PERFALT_4
 turn on checking for equality before assigning in operator=()
 
#define SOPLEX_PERFALT_5a
 turn on checking whether assignment in assignment operators is redundant for 0
 
#define SOPLEX_PERFALT_5b
 turn on checking whether assignment in assignment operators is redundant for +1 and -1
 

Functions

Rational operator- (const double &d, const Rational &r)
 subtraction operator for double and Rational
 
Rational operator* (const double &d, const Rational &r)
 multiplication operator for double and Rational
 
Rational operator/ (const double &d, const Rational &r)
 division operator for double and Rational
 
Rational operator- (const int &d, const Rational &r)
 subtraction operator for int and Rational
 
Rational operator* (const int &d, const Rational &r)
 multiplication operator for int and Rational
 
Rational operator/ (const int &d, const Rational &r)
 division operator for int and Rational
 
std::string rationalToString (const Rational &r, const int precision)
 convert rational number to string
 
bool readStringRational (const char *s, Rational &value)
 read Rational from string
 
std::ostream & operator<< (std::ostream &os, const Rational &r)
 print Rational
 
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
 
bool operator== (const Rational &r, const Rational &s)
 equality operator
 
bool operator!= (const Rational &r, const Rational &s)
 inequality operator
 
bool operator< (const Rational &r, const Rational &s)
 less than operator
 
bool operator<= (const Rational &r, const Rational &s)
 less than or equal to operator
 
bool operator> (const Rational &r, const Rational &s)
 greater than operator
 
bool operator>= (const Rational &r, const Rational &s)
 greater than or equal to operator
 
bool operator== (const Rational &r, const double &s)
 equality operator for Rational and double
 
bool operator!= (const Rational &r, const double &s)
 inequality operator for Rational and double
 
bool operator< (const Rational &r, const double &s)
 less than operator for Rational and double
 
bool operator<= (const Rational &r, const double &s)
 less than or equal to operator for Rational and double
 
bool operator> (const Rational &r, const double &s)
 greater than operator for Rational and double
 
bool operator>= (const Rational &r, const double &s)
 greater than or equal to operator for Rational and double
 
bool operator== (const double &r, const Rational &s)
 equality operator for double and Rational
 
bool operator!= (const double &r, const Rational &s)
 inequality operator double and Rational
 
bool operator< (const double &r, const Rational &s)
 less than operator double and Rational
 
bool operator<= (const double &r, const Rational &s)
 less than or equal to operator double and Rational
 
bool operator> (const double &r, const Rational &s)
 greater than operator double and Rational
 
bool operator>= (const double &r, const Rational &s)
 greater than or equal to operator double and Rational
 
bool operator== (const Rational &r, const long double &s)
 equality operator for Rational and long double
 
bool operator!= (const Rational &r, const long double &s)
 inequality operator for Rational and long double
 
bool operator< (const Rational &r, const long double &s)
 less than operator for Rational and long double
 
bool operator<= (const Rational &r, const long double &s)
 less than or equal to operator for Rational and long double
 
bool operator> (const Rational &r, const long double &s)
 greater than operator for Rational and long double
 
bool operator>= (const Rational &r, const long double &s)
 greater than or equal to operator for Rational and long double
 
bool operator== (const long double &r, const Rational &s)
 equality operator for long double and Rational
 
bool operator!= (const long double &r, const Rational &s)
 inequality operator long double and Rational
 
bool operator< (const long double &r, const Rational &s)
 less than operator long double and Rational
 
bool operator<= (const long double &r, const Rational &s)
 less than or equal to operator long double and Rational
 
bool operator> (const long double &r, const Rational &s)
 greater than operator long double and Rational
 
bool operator>= (const long double &r, const Rational &s)
 greater than or equal to operator long double and Rational
 
bool operator== (const Rational &r, const int &s)
 equality operator for Rational and int
 
bool operator!= (const Rational &r, const int &s)
 inequality operator for Rational and int
 
bool operator< (const Rational &r, const int &s)
 less than operator for Rational and int
 
bool operator<= (const Rational &r, const int &s)
 less than or equal to operator for Rational and int
 
bool operator> (const Rational &r, const int &s)
 greater than operator for Rational and int
 
bool operator>= (const Rational &r, const int &s)
 greater than or equal to operator for Rational and int
 
bool operator== (const int &r, const Rational &s)
 equality operator for int and Rational
 
bool operator!= (const int &r, const Rational &s)
 inequality operator for int and Rational
 
bool operator< (const int &r, const Rational &s)
 less than operator for int and Rational
 
bool operator<= (const int &r, const Rational &s)
 less than or equal to operator for int and Rational
 
bool operator> (const int &r, const Rational &s)
 greater than operator for int and Rational
 
bool operator>= (const int &r, const Rational &s)
 greater than or equal to operator for int and Rational
 
Rational operator+ (const double &d, const Rational &r)
 addition operator for double and Rational
 
Rational operator+ (const int &d, const Rational &r)
 addition operator for int and Rational
 
Rational spxAbs (const Rational &r)
 Absolute.
 
int sign (const Rational &r)
 Sign function; returns 1 if r > 0, 0 if r = 0, and -1 if r < 0.
 
Rational operator- (const Rational &r)
 Negation.
 
int totalSizeRational (const Rational *vector, const int length, const int base)
 Total size of rational vector.
 
int dlcmSizeRational (const Rational *vector, const int length, const int base)
 Size of least common multiple of denominators in rational vector.
 
int dmaxSizeRational (const Rational *vector, const int length, const int base)
 Size of largest denominator in rational vector.
 

Detailed Description

Wrapper for GMP types.

Definition in file rational.cpp.

Macro Definition Documentation

#define SOPLEX_PERFALT_1

use mpq_sgn instead of mpq_equal to compare rationals with zero

Definition at line 40 of file rational.cpp.

#define SOPLEX_PERFALT_2a

turn on checking rationals for zero in arithmetic plus and minus operators

Definition at line 43 of file rational.cpp.

#define SOPLEX_PERFALT_2b

turn on checking rationals for zero, posone, negone in arithmetic multiplication and division operators

Definition at line 46 of file rational.cpp.

#define SOPLEX_PERFALT_3

turn on checking rationals for zero, posone, negone before conversion to double and long double

Definition at line 49 of file rational.cpp.

#define SOPLEX_PERFALT_4

turn on checking for equality before assigning in operator=()

Definition at line 52 of file rational.cpp.

#define SOPLEX_PERFALT_5a

turn on checking whether assignment in assignment operators is redundant for 0

Definition at line 55 of file rational.cpp.

#define SOPLEX_PERFALT_5b

turn on checking whether assignment in assignment operators is redundant for +1 and -1

Definition at line 58 of file rational.cpp.