#include <Rational.h>
Public Member Functions | |
| Rational () | |
| Rational (param_type n) | |
| Rational (param_type n, param_type d) | |
| Rational (const Rational &other) | |
| Rational & | operator= (const Rational &other) |
| Rational & | operator= (param_type n) |
| Rational & | assign (param_type n, param_type d) |
| const IntType & | numerator () const |
| const IntType & | denominator () const |
| Rational & | operator+= (const Rational &r) |
| Rational & | operator-= (const Rational &r) |
| Rational & | operator *= (const Rational &r) |
| Rational & | operator/= (const Rational &r) |
| Rational | operator+ (const Rational &r) const |
| Rational | operator- (const Rational &r) const |
| Rational | operator * (const Rational &r) const |
| Rational | operator/ (const Rational &r) const |
| Rational & | operator+= (param_type i) |
| Rational & | operator-= (param_type i) |
| Rational & | operator *= (param_type i) |
| Rational & | operator/= (param_type i) |
| const Rational & | operator++ () |
| const Rational & | operator-- () |
| bool | operator! () const |
| bool | operator< (const Rational &r) const |
| bool | operator== (const Rational &r) const |
| bool | operator> (const Rational &r) const |
| bool | operator!= (const Rational &r) const |
| bool | operator< (param_type i) const |
| bool | operator> (param_type i) const |
| bool | operator== (param_type i) const |
| void | load (std::istream &is) |
| void | save (std::ostream &os) const |
| std::string | toString (bool decimalFormat=false, int precision=3) const |
| void | display (std::ostream &os=std::cout) const |
Definition at line 121 of file Rational.h.
Default constructor.
Definition at line 133 of file Rational.h.
Constructor from an int_type
Definition at line 140 of file Rational.h.
Constructor
| n | The value of the numerator | |
| d | The value of the denominator |
Definition at line 150 of file Rational.h.
| Rational< IntType >::Rational | ( | const Rational< IntType > & | other | ) | [inline] |
Copy constructor
| other | The other rational number to copy. |
Definition at line 158 of file Rational.h.
| Rational& Rational< IntType >::operator= | ( | const Rational< IntType > & | other | ) | [inline] |
Assignment operator
| other | The other rational number to copy. |
Definition at line 166 of file Rational.h.
References Rational< IntType >::den_, and Rational< IntType >::num_.
Assignment operator
| n | an integral value |
Definition at line 181 of file Rational.h.
References Rational< IntType >::assign().
Here is the call graph for this function:

| Rational< IntType > & Rational< IntType >::assign | ( | param_type | n, | |
| param_type | d | |||
| ) | [inline] |
In place assignment
| n | The new value of the numerator. | |
| d | The new value of the denominator. |
Definition at line 491 of file Rational.h.
Referenced by Rational< IntType >::operator=().
Here is the caller graph for this function:

| const IntType& Rational< IntType >::numerator | ( | ) | const [inline] |
Return the numerator
Definition at line 193 of file Rational.h.
Referenced by AlgebraicTraits< Rational< IntType > >::abs(), AlgebraicTraits< Rational< IntType > >::equals(), AlgebraicTraits< Rational< IntType > >::is_zero(), AlgebraicTraits< Rational< IntType > >::norm(), AlgebraicTraits< Rational< IntType > >::one(), and AlgebraicTraits< Rational< IntType > >::zero().
Here is the caller graph for this function:

| const IntType& Rational< IntType >::denominator | ( | ) | const [inline] |
Return the denominator
Definition at line 201 of file Rational.h.
Referenced by AlgebraicTraits< Rational< IntType > >::abs(), AlgebraicTraits< Rational< IntType > >::equals(), and AlgebraicTraits< Rational< IntType > >::norm().
Here is the caller graph for this function:

| Rational< IntType > & Rational< IntType >::operator+= | ( | const Rational< IntType > & | r | ) |
Addition assignment operator
| r | Right hand side operator. |
Definition at line 522 of file Rational.h.
References Rational< IntType >::den_, and Rational< IntType >::num_.
Referenced by Rational< IntType >::operator+=().
Here is the caller graph for this function:

| Rational< IntType > & Rational< IntType >::operator-= | ( | const Rational< IntType > & | r | ) |
Subtraction assignment operator
| r | Right hand side operator. |
Definition at line 561 of file Rational.h.
References Rational< IntType >::den_, and Rational< IntType >::num_.
Referenced by Rational< IntType >::operator-=().
Here is the caller graph for this function:

| Rational< IntType > & Rational< IntType >::operator *= | ( | const Rational< IntType > & | r | ) |
Multiplication assignment operator
| r | Right hand side operator. |
Definition at line 584 of file Rational.h.
References Rational< IntType >::den_, and Rational< IntType >::num_.
Referenced by Rational< IntType >::operator *=().
Here is the caller graph for this function:

| Rational< IntType > & Rational< IntType >::operator/= | ( | const Rational< IntType > & | r | ) |
Division assignment operator
| r | Right hand side operator. |
Definition at line 603 of file Rational.h.
References Rational< IntType >::den_, and Rational< IntType >::num_.
Referenced by Rational< IntType >::operator/=().
Here is the caller graph for this function:

| Rational Rational< IntType >::operator+ | ( | const Rational< IntType > & | r | ) | const [inline] |
Addition operator
| r | Right hand side operator |
Definition at line 216 of file Rational.h.
| Rational Rational< IntType >::operator- | ( | const Rational< IntType > & | r | ) | const [inline] |
Subtraction operator
| r | Right hand side operator |
Definition at line 226 of file Rational.h.
| Rational Rational< IntType >::operator * | ( | const Rational< IntType > & | r | ) | const [inline] |
Multiplication operator
| r | Right hand side operator |
Definition at line 236 of file Rational.h.
| Rational Rational< IntType >::operator/ | ( | const Rational< IntType > & | r | ) | const [inline] |
Division operator
| r | Right hand side operator |
Definition at line 246 of file Rational.h.
| Rational< IntType > & Rational< IntType >::operator+= | ( | param_type | i | ) | [inline] |
Addition assignment operator
| i | Right hand side operator. |
Definition at line 642 of file Rational.h.
References Rational< IntType >::operator+=().
Here is the call graph for this function:

| Rational< IntType > & Rational< IntType >::operator-= | ( | param_type | i | ) | [inline] |
Subtraction assignment operator
| i | Right hand side operator. |
Definition at line 653 of file Rational.h.
References Rational< IntType >::operator-=().
Here is the call graph for this function:

| Rational< IntType > & Rational< IntType >::operator *= | ( | param_type | i | ) | [inline] |
Multiplication assignment operator
| i | Right hand side operator. |
Definition at line 664 of file Rational.h.
References Rational< IntType >::operator *=().
Here is the call graph for this function:

| Rational< IntType > & Rational< IntType >::operator/= | ( | param_type | i | ) | [inline] |
Division assignment operator
| i | Right hand side operator. |
Definition at line 675 of file Rational.h.
References Rational< IntType >::operator/=().
Here is the call graph for this function:

Increment operator
Definition at line 684 of file Rational.h.
Decrement operator
Definition at line 694 of file Rational.h.
| bool Rational< IntType >::operator! | ( | ) | const [inline] |
Test if value is different from zero
Definition at line 266 of file Rational.h.
| bool Rational< IntType >::operator< | ( | const Rational< IntType > & | r | ) | const |
Comparison operator
| r | Right hand side operator |
Definition at line 709 of file Rational.h.
References Rational< IntType >::den_, and Rational< IntType >::num_.
Referenced by Rational< IntType >::operator>().
Here is the caller graph for this function:

| bool Rational< IntType >::operator== | ( | const Rational< IntType > & | r | ) | const [inline] |
Equality operator
| r | Right hand side operator |
Definition at line 776 of file Rational.h.
References Rational< IntType >::den_, and Rational< IntType >::num_.
| bool Rational< IntType >::operator!= | ( | const Rational< IntType > & | r | ) | const [inline] |
Inequality operator
| r | Rational number to compare this to. |
Definition at line 284 of file Rational.h.
| bool Rational< IntType >::operator< | ( | param_type | i | ) | const |
Comparison operator
| i | Right hand side operator |
Definition at line 733 of file Rational.h.
| bool Rational< IntType >::operator> | ( | param_type | i | ) | const |
Comparison, greater than operator
| i | Right hand side operator |
Definition at line 761 of file Rational.h.
References Rational< IntType >::operator<().
Here is the call graph for this function:

| bool Rational< IntType >::operator== | ( | param_type | i | ) | const [inline] |
Equality operator
| i | Right hand side operator |
Definition at line 786 of file Rational.h.
| void Rational< IntType >::load | ( | std::istream & | is | ) | [inline] |
Load this from a stream
| is | stream to load from |
Definition at line 387 of file Rational.h.
| void Rational< IntType >::save | ( | std::ostream & | os | ) | const [inline] |
| std::string Rational< IntType >::toString | ( | bool | decimalFormat = false, |
|
| int | precision = 3 | |||
| ) | const [inline] |
Convert this rational number to a string
| decimalFormat | This parameter must be true if one desires to display the rational number in decimal format | |
| precision | The maximum number of fractional digits. This parameter is used only if decimalFormat is true. |
Definition at line 412 of file Rational.h.
Referenced by Rational< IntType >::display().
Here is the caller graph for this function:

| void Rational< IntType >::display | ( | std::ostream & | os = std::cout |
) | const [inline] |
Display this number to a stream.
| os | Stream to display to. |
Definition at line 458 of file Rational.h.
References AlgebraicTraits< T >::one(), and Rational< IntType >::toString().
Here is the call graph for this function:
