Polymake Template Library (PTL)
4.2
|
Rational number with unlimited precision. More...
Inherits __mpq_struct.
Public Types | |
typedef RationalParticle< true > | num_proxy |
Separate access to numerator and denominator. | |
Public Member Functions | |
Rational (const Rational &b) | |
Constructors. | |
Rational (const mpq_t &b) | |
Copy the value from a third party. | |
Rational (mpq_t &&b) noexcept | |
Rational (const Integer &b) | |
Create a Rational from an integral number. | |
Rational (const mpz_t &b) | |
Copy the numerator value from a third party. | |
Rational (mpz_t &&b) | |
Rational (const Integer &num, const Integer &den) | |
Create a Rational as the quotient of two integrals, represented as Integer, long, or int. | |
Rational (const mpz_t &num, const mpz_t &den) | |
Copy or steal numerator and denominator values from a third party. | |
Rational (const char *s) | |
Parse a string "num/den", "num", or "±inf". | |
Rational & | operator= (const Rational &b) |
Assignment. | |
Rational & | copy_from (mpq_srcptr src) |
Assign a copy of data obtained from a third party. | |
Rational & | set (const Integer &num, const Integer &den) |
Assign numerator and denominator from separate sources. | |
void | swap (Rational &b) |
Exchange the values. | |
operator double () const | |
Cast to simpler types. | |
Rational & | operator++ () |
Increment. | |
Rational & | negate () |
In-place negation. | |
Rational & | operator+= (const Rational &b) |
Addition. | |
Rational & | operator-= (const Rational &b) |
Subtraction. | |
Rational & | operator*= (const Rational &b) |
Multiplication. | |
Rational & | operator/= (const Rational &b) |
Division. | |
Rational & | operator<<= (long k) |
Multiply with or divide through 2**k. | |
Rational & | operator>>= (long k) |
Divide through or multiply with 2**k. | |
Integer | floor () const |
The closest integral not greater than this. | |
Integer | ceil () const |
The closest integral not smaller than the given value. | |
Integer | trunc () const |
Truncation toward zero. | |
bool | is_zero () const noexcept |
fast comparison with 0 | |
bool | is_integral () const noexcept |
Int | compare (const Rational &b) const |
Int | compare (double b) const |
Comparison. | |
Static Public Member Functions | |
static Rational | infinity (Int sgn) |
Construct an infinite value. | |
static Rational | pow (const Rational &a, long k) |
Power. | |
static Rational | pow (const Integer &a, long k) |
Power. | |
Protected Member Functions | |
Rational (std::nullptr_t) | |
uninitialized object | |
|
inlineexplicitnoexcept |
Steal the value from a third party The source must be re-initialized if it's going to be used afterwards
|
inlineexplicit |
Steal the numerator value from a third party The source must be re-initialized if it's going to be used afterwards
|
inline |
Comparison. The magnitude of the return value is arbitrary, only its sign is relevant.
|
inlinenoexcept |
check whether the denominator equals 1 for infinite values, returns true as well