#include <rational.h>
Public Member Functions | |
Construction and destruction | |
| void | rationalErrorMessage () const |
| 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 Integer &num, const Integer &den) | |
| constructor from Integer fraction pair More... | |
| Rational (const mpq_t &q) | |
| constructor from mpq_t (GMP only) More... | |
| ~Rational () | |
| destructor More... | |
| Rational & | operator= (const Rational &) |
| copy assignment More... | |
| Rational & | operator= (const long double &r) |
| assignment from long double More... | |
| Rational & | operator= (const double &r) |
| assignment from double More... | |
| Rational & | operator= (const int &i) |
| assignment from int More... | |
| Rational & | operator= (const mpq_t &q) |
| assignment from mpq_t (GMP only) More... | |
| void | assign (const Rational &) |
| void | assign (const long double &r) |
| void | assign (const double &r) |
| void | assign (const int &i) |
Typecasts | |
| operator double () const | |
| operator long double () const | |
| operator float () const | |
Arithmetic operators | |
| 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... | |
Methods for checking exactness of doubles | |
| 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... | |
Friends | |
Friends | |
| int | compareRational (const Rational &r, const Rational &s) |
| bool | operator!= (const Rational &r, const Rational &s) |
| bool | operator== (const Rational &r, const Rational &s) |
| bool | operator< (const Rational &r, const Rational &s) |
| bool | operator<= (const Rational &r, const Rational &s) |
| bool | operator> (const Rational &r, const Rational &s) |
| bool | operator>= (const Rational &r, const Rational &s) |
| bool | operator!= (const Rational &r, const double &s) |
| bool | operator== (const Rational &r, const double &s) |
| bool | operator< (const Rational &r, const double &s) |
| bool | operator<= (const Rational &r, const double &s) |
| bool | operator> (const Rational &r, const double &s) |
| bool | operator>= (const Rational &r, const double &s) |
| bool | operator!= (const double &r, const Rational &s) |
| bool | operator== (const double &r, const Rational &s) |
| bool | operator< (const double &r, const Rational &s) |
| bool | operator<= (const double &r, const Rational &s) |
| bool | operator> (const double &r, const Rational &s) |
| bool | operator>= (const double &r, const Rational &s) |
| bool | operator!= (const Rational &r, const long double &s) |
| bool | operator== (const Rational &r, const long double &s) |
| bool | operator< (const Rational &r, const long double &s) |
| bool | operator<= (const Rational &r, const long double &s) |
| bool | operator> (const Rational &r, const long double &s) |
| bool | operator>= (const Rational &r, const long double &s) |
| bool | operator!= (const long double &r, const Rational &s) |
| bool | operator== (const long double &r, const Rational &s) |
| bool | operator< (const long double &r, const Rational &s) |
| bool | operator<= (const long double &r, const Rational &s) |
| bool | operator> (const long double &r, const Rational &s) |
| bool | operator>= (const long double &r, const Rational &s) |
| bool | operator!= (const Rational &r, const float &s) |
| bool | operator== (const Rational &r, const float &s) |
| bool | operator< (const Rational &r, const float &s) |
| bool | operator<= (const Rational &r, const float &s) |
| bool | operator> (const Rational &r, const float &s) |
| bool | operator>= (const Rational &r, const float &s) |
| bool | operator!= (const float &r, const Rational &s) |
| bool | operator== (const float &r, const Rational &s) |
| bool | operator< (const float &r, const Rational &s) |
| bool | operator<= (const float &r, const Rational &s) |
| bool | operator> (const float &r, const Rational &s) |
| bool | operator>= (const float &r, const Rational &s) |
| Rational | operator+ (const double &d, const Rational &r) |
| Rational | operator- (const double &d, const Rational &r) |
| Rational | operator* (const double &d, const Rational &r) |
| Rational | operator/ (const double &d, const Rational &r) |
| bool | operator!= (const Rational &r, const int &s) |
| bool | operator== (const Rational &r, const int &s) |
| bool | operator< (const Rational &r, const int &s) |
| bool | operator<= (const Rational &r, const int &s) |
| bool | operator> (const Rational &r, const int &s) |
| bool | operator>= (const Rational &r, const int &s) |
| bool | operator!= (const int &r, const Rational &s) |
| bool | operator== (const int &r, const Rational &s) |
| bool | operator< (const int &r, const Rational &s) |
| bool | operator<= (const int &r, const Rational &s) |
| bool | operator> (const int &r, const Rational &s) |
| bool | operator>= (const int &r, const Rational &s) |
| Rational | operator+ (const int &d, const Rational &r) |
| Rational | operator- (const int &d, const Rational &r) |
| Rational | operator* (const int &d, const Rational &r) |
| Rational | operator/ (const int &d, const Rational &r) |
| Rational | spxAbs (const Rational &r) |
| int | sign (const Rational &r) |
| Rational | operator- (const Rational &q) |
Conversion from and to String | |
| std::string | str () const |
| std::ostream & | operator<< (std::ostream &os, const Rational &r) |
Definition at line 254 of file rational.h.
| Rational | ( | ) |
default constructor
Definition at line 269 of file rational.h.
copy constructor
Definition at line 273 of file rational.h.
| Rational | ( | const long double & | r | ) |
constructor from long double
Definition at line 277 of file rational.h.
| Rational | ( | const double & | r | ) |
constructor from double
Definition at line 281 of file rational.h.
| Rational | ( | const int & | i | ) |
constructor from int
Definition at line 285 of file rational.h.
constructor from Integer fraction pair
Definition at line 289 of file rational.h.
| Rational | ( | const mpq_t & | q | ) |
constructor from mpq_t (GMP only)
Definition at line 294 of file rational.h.
| ~Rational | ( | ) |
destructor
Definition at line 307 of file rational.h.
add product of two rationals
Definition at line 546 of file rational.h.
References rationalErrorMessage().
add quotient of two rationals, r divided by s
Definition at line 560 of file rational.h.
References rationalErrorMessage().
| void assign | ( | const double & | r | ) |
Definition at line 347 of file rational.h.
References rationalErrorMessage().
| void assign | ( | const int & | i | ) |
Definition at line 351 of file rational.h.
References rationalErrorMessage().
| void assign | ( | const long double & | r | ) |
Definition at line 343 of file rational.h.
References rationalErrorMessage().
| void assign | ( | const Rational & | ) |
Definition at line 339 of file rational.h.
References rationalErrorMessage().
| 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
Definition at line 580 of file rational.h.
References rationalErrorMessage().
| operator double | ( | ) | const |
Definition at line 359 of file rational.h.
| operator float | ( | ) | const |
Definition at line 367 of file rational.h.
| operator long double | ( | ) | const |
Definition at line 363 of file rational.h.
| Rational operator* | ( | const double & | r | ) | const |
multiplication operator for doubles
Definition at line 486 of file rational.h.
References rationalErrorMessage().
| Rational operator* | ( | const int & | r | ) | const |
multiplication operator for ints
Definition at line 498 of file rational.h.
References rationalErrorMessage().
multiplication operator
Definition at line 474 of file rational.h.
References rationalErrorMessage().
| Rational operator*= | ( | const double & | r | ) |
multiplication assignment operator for doubles
Definition at line 492 of file rational.h.
References rationalErrorMessage().
| Rational operator*= | ( | const int & | r | ) |
multiplication assignment operator for ints
Definition at line 504 of file rational.h.
References rationalErrorMessage().
multiplication assignment operator operator
Definition at line 480 of file rational.h.
References rationalErrorMessage().
| Rational operator+ | ( | const double & | r | ) | const |
addition operator for doubles
Definition at line 414 of file rational.h.
References rationalErrorMessage().
| Rational operator+ | ( | const int & | r | ) | const |
addition operator for ints
Definition at line 426 of file rational.h.
References rationalErrorMessage().
| Rational operator+= | ( | const double & | r | ) |
addition assignment operator for doubles
Definition at line 420 of file rational.h.
References rationalErrorMessage().
| Rational operator+= | ( | const int & | r | ) |
addition assignment operator for ints
Definition at line 432 of file rational.h.
References rationalErrorMessage().
addition assignment operator
Definition at line 408 of file rational.h.
References rationalErrorMessage().
| Rational operator- | ( | const double & | r | ) | const |
subtraction operator for doubles
Definition at line 450 of file rational.h.
References rationalErrorMessage().
| Rational operator- | ( | const int & | r | ) | const |
subtraction operator for ints
Definition at line 462 of file rational.h.
References rationalErrorMessage().
| Rational operator-= | ( | const double & | r | ) |
subtraction assignment operator for doubles
Definition at line 456 of file rational.h.
References rationalErrorMessage().
| Rational operator-= | ( | const int & | r | ) |
subtraction assignment operator for ints
Definition at line 468 of file rational.h.
References rationalErrorMessage().
subtraction assignment operator
Definition at line 444 of file rational.h.
References rationalErrorMessage().
| Rational operator/ | ( | const double & | r | ) | const |
division operator for doubles
Definition at line 522 of file rational.h.
References rationalErrorMessage().
| Rational operator/ | ( | const int & | r | ) | const |
division operator for ints
Definition at line 534 of file rational.h.
References rationalErrorMessage().
| Rational operator/= | ( | const double & | r | ) |
division assignment operator for doubles
Definition at line 528 of file rational.h.
References rationalErrorMessage().
| Rational operator/= | ( | const int & | r | ) |
division assignment operator for ints
Definition at line 540 of file rational.h.
References rationalErrorMessage().
division assignment operator
Definition at line 516 of file rational.h.
References rationalErrorMessage().
| Rational & operator= | ( | const double & | r | ) |
assignment from double
Definition at line 322 of file rational.h.
| Rational & operator= | ( | const int & | i | ) |
assignment from int
Definition at line 327 of file rational.h.
| Rational & operator= | ( | const long double & | r | ) |
assignment from long double
Definition at line 317 of file rational.h.
| Rational & operator= | ( | const mpq_t & | q | ) |
assignment from mpq_t (GMP only)
Definition at line 333 of file rational.h.
copy assignment
Definition at line 312 of file rational.h.
| void rationalErrorMessage | ( | ) | const |
Definition at line 262 of file rational.h.
References SPX_MSG_ERROR.
Referenced by addProduct(), addQuotient(), assign(), denominator(), invert(), isAdjacentTo(), numerator(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), orderOfMagnitude(), powRound(), sizeInBase(), str(), subProduct(), and subQuotient().
| int sizeInBase | ( | const int | base = 2 | ) | const |
Size in specified base (bit size for base 2)
Definition at line 593 of file rational.h.
References rationalErrorMessage().
| std::string str | ( | ) | const |
Definition at line 609 of file rational.h.
References rationalErrorMessage().
subtract product of two rationals
Definition at line 553 of file rational.h.
References rationalErrorMessage().
subtract quotient of two rationals, r divided by s
Definition at line 567 of file rational.h.
References rationalErrorMessage().
Definition at line 619 of file rational.h.
|
friend |
Definition at line 686 of file rational.h.
|
friend |
Definition at line 810 of file rational.h.
|
friend |
Definition at line 893 of file rational.h.
|
friend |
Definition at line 748 of file rational.h.
|
friend |
Definition at line 655 of file rational.h.
|
friend |
Definition at line 779 of file rational.h.
|
friend |
Definition at line 862 of file rational.h.
|
friend |
Definition at line 717 of file rational.h.
Definition at line 624 of file rational.h.
Definition at line 851 of file rational.h.
Definition at line 934 of file rational.h.
Definition at line 841 of file rational.h.
Definition at line 924 of file rational.h.
Definition at line 846 of file rational.h.
Definition at line 929 of file rational.h.
Definition at line 955 of file rational.h.
Definition at line 856 of file rational.h.
Definition at line 939 of file rational.h.
|
friend |
Definition at line 696 of file rational.h.
|
friend |
Definition at line 820 of file rational.h.
|
friend |
Definition at line 903 of file rational.h.
|
friend |
Definition at line 758 of file rational.h.
|
friend |
Definition at line 665 of file rational.h.
|
friend |
Definition at line 789 of file rational.h.
|
friend |
Definition at line 872 of file rational.h.
|
friend |
Definition at line 727 of file rational.h.
Definition at line 634 of file rational.h.
|
friend |
Definition at line 604 of file rational.h.
|
friend |
Definition at line 701 of file rational.h.
|
friend |
Definition at line 825 of file rational.h.
|
friend |
Definition at line 908 of file rational.h.
|
friend |
Definition at line 763 of file rational.h.
|
friend |
Definition at line 670 of file rational.h.
|
friend |
Definition at line 794 of file rational.h.
|
friend |
Definition at line 877 of file rational.h.
|
friend |
Definition at line 732 of file rational.h.
Definition at line 639 of file rational.h.
|
friend |
Definition at line 691 of file rational.h.
|
friend |
Definition at line 815 of file rational.h.
|
friend |
Definition at line 898 of file rational.h.
|
friend |
Definition at line 753 of file rational.h.
|
friend |
Definition at line 660 of file rational.h.
|
friend |
Definition at line 784 of file rational.h.
|
friend |
Definition at line 867 of file rational.h.
|
friend |
Definition at line 722 of file rational.h.
Definition at line 629 of file rational.h.
|
friend |
Definition at line 706 of file rational.h.
|
friend |
Definition at line 830 of file rational.h.
|
friend |
Definition at line 913 of file rational.h.
|
friend |
Definition at line 768 of file rational.h.
|
friend |
Definition at line 675 of file rational.h.
|
friend |
Definition at line 799 of file rational.h.
|
friend |
Definition at line 882 of file rational.h.
|
friend |
Definition at line 737 of file rational.h.
Definition at line 644 of file rational.h.
|
friend |
Definition at line 711 of file rational.h.
|
friend |
Definition at line 835 of file rational.h.
|
friend |
Definition at line 918 of file rational.h.
|
friend |
Definition at line 773 of file rational.h.
|
friend |
Definition at line 680 of file rational.h.
|
friend |
Definition at line 804 of file rational.h.
|
friend |
Definition at line 887 of file rational.h.
|
friend |
Definition at line 742 of file rational.h.
Definition at line 649 of file rational.h.
|
friend |
Definition at line 950 of file rational.h.
Definition at line 945 of file rational.h.