|
|
| rational () noexcept |
| | Empty constructor.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| | rational (const T n, const uint64_t d=1) noexcept |
| | Constructor with numerator and denominator.
|
| |
| | rational (const integer &n, const integer &d=1) noexcept |
| | Constructor with numerator and denominator.
|
| |
| | rational (const std::string &s) noexcept |
| | Constructor with string.
|
| |
| | rational (const rational &r) noexcept |
| | Copy constructor.
|
| |
| | rational (integer &&i) noexcept |
| | Move constructor.
|
| |
| | rational (integer &&n, integer &&d) noexcept |
| | Move constructor with numerator and denominator.
|
| |
| | rational (rational &&r) noexcept |
| | Move constructor.
|
| |
|
| ~rational () noexcept |
| | Destructor.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| void | set_number (const T n, const uint64_t d=1) noexcept |
| | Overwrites the value of this rational with \(n/d\).
|
| |
| void | set_str (const std::string &s) noexcept |
| | Overwrites the value in the string s.
|
| |
| void | set_integer (const integer &n, const integer &d) noexcept |
| | Overwrites the value of this rational with the value \(n/d\).
|
| |
| void | set_rational (const rational &r) noexcept |
| | Overwrites the value of this rational with the value \(n/d\).
|
| |
| void | invert () noexcept |
| | Changes numerator and denominator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| rational & | operator= (const T i) noexcept |
| | Assignment operator.
|
| |
| rational & | operator= (const std::string &s) noexcept |
| | Assignment operator.
|
| |
| rational & | operator= (const integer &i) noexcept |
| | Assignment operator.
|
| |
| rational & | operator= (const rational &r) noexcept |
| | Assignment operator.
|
| |
| rational & | operator= (integer &&i) noexcept |
| | Move assignment operator.
|
| |
| rational & | operator= (rational &&r) noexcept |
| | Move assignment operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| bool | operator== (const T i) const noexcept |
| | Equality operator.
|
| |
| bool | operator== (const integer &i) const noexcept |
| | Equality operator.
|
| |
| bool | operator== (const rational &r) const noexcept |
| | Equality operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| bool | operator!= (const T i) const noexcept |
| | Non-equality operator.
|
| |
| bool | operator!= (const integer &i) const noexcept |
| | Non-equality operator.
|
| |
| bool | operator!= (const rational &r) const noexcept |
| | Non-equality operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| bool | operator< (const T i) const noexcept |
| | Less than operator.
|
| |
| bool | operator< (const integer &i) const noexcept |
| | Less than operator.
|
| |
| bool | operator< (const rational &r) const noexcept |
| | Less than operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| bool | operator<= (const T i) const noexcept |
| | Less than or equal to operator.
|
| |
| bool | operator<= (const integer &i) const noexcept |
| | Less than or equal to operator.
|
| |
| bool | operator<= (const rational &r) const noexcept |
| | Less than or equal to operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| bool | operator> (const T i) const noexcept |
| | Greater than operator.
|
| |
| bool | operator> (const integer &i) const noexcept |
| | Greater than operator.
|
| |
| bool | operator> (const rational &r) const noexcept |
| | Greater than operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| bool | operator>= (const T i) const noexcept |
| | Greater than or equal to operator.
|
| |
| bool | operator>= (const integer &i) const noexcept |
| | Greater than or equal to operator.
|
| |
| bool | operator>= (const rational &r) const noexcept |
| | Greater than or equal to operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| rational | operator+ (const T i) const noexcept |
| | Addition operator.
|
| |
| rational | operator+ (const integer &i) const noexcept |
| | Addition operator.
|
| |
| rational | operator+ (const rational &r) const noexcept |
| | Addition operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| rational & | operator+= (const T i) noexcept |
| | Addition operator.
|
| |
| rational & | operator+= (const integer &i) noexcept |
| | Addition operator.
|
| |
| rational & | operator+= (const rational &r) noexcept |
| | Addition operator.
|
| |
|
rational | operator- () const noexcept |
| | Substraction unary operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| rational | operator- (const T i) const noexcept |
| | Substraction operator.
|
| |
| rational | operator- (const integer &i) const noexcept |
| | Substraction operator.
|
| |
| rational | operator- (const rational &r) const noexcept |
| | Substraction operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| rational & | operator-= (const T i) noexcept |
| | Substraction operator.
|
| |
| rational & | operator-= (const integer &i) noexcept |
| | Substraction operator.
|
| |
| rational & | operator-= (const rational &r) noexcept |
| | Substraction operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| rational | operator* (const T i) const noexcept |
| | Multiplication operator.
|
| |
| rational | operator* (const integer &i) const noexcept |
| | Multiplication operator.
|
| |
| rational | operator* (const rational &r) const noexcept |
| | Multiplication operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| rational & | operator*= (const T i) noexcept |
| | Multiplication operator.
|
| |
| rational & | operator*= (const integer &i) noexcept |
| | Multiplication operator.
|
| |
| rational & | operator*= (const rational &r) noexcept |
| | Multiplication operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| rational | operator/ (const T i) const noexcept |
| | Division operator.
|
| |
| rational | operator/ (const integer &i) const noexcept |
| | Division operator.
|
| |
| rational | operator/ (const rational &r) const noexcept |
| | Division operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| rational & | operator/= (const T i) noexcept |
| | Division operator.
|
| |
| rational & | operator/= (const integer &i) noexcept |
| | Division operator.
|
| |
| rational & | operator/= (const rational &r) noexcept |
| | Division operator.
|
| |
| rational | power (const uint64_t i) const noexcept |
| | Exponentiation operator.
|
| |
| rational | power (const integer &i) const noexcept |
| | Exponentiation operator.
|
| |
| rational & | powt (const uint64_t i) noexcept |
| | Exponentiation operator.
|
| |
| rational & | powt (const integer &i) noexcept |
| | Exponentiation operator.
|
| |
|
bool | is_initialized () const noexcept |
| | Returns whether this object is initialized or not.
|
| |
|
int64_t | get_sign () const noexcept |
| | Returns the sign of this rational.
|
| |
|
std::size_t | bytes () const noexcept |
| | Returns the amount of bytes this integer occupies.
|
| |
| integer | to_integer () const noexcept |
| | Converts this rational to an integer value.
|
| |
| void | as_integer (integer &i) const noexcept |
| | Converts this rational to an integer value.
|
| |
|
double | to_double () const noexcept |
| | Converts this rational to a double-precision floating-point value.
|
| |
|
void | as_double (double &d) const noexcept |
| | Converts this rational to a double-precision floating-point value.
|
| |
|
std::string | to_string () const noexcept |
| | Converts this integer to a string.
|
| |
|
void | as_string (std::string &s) const noexcept |
| | Converts this integer to a string.
|
| |
|
integer | get_numerator () const noexcept |
| | Returns the numerator of this rational number.
|
| |
|
integer | get_denominator () const noexcept |
| | Returns the denominator of this rational number.
|
| |
| void | swap (rational &r) noexcept |
| | Swaps the value of this rational with rational r's value.
|
| |
|
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| bool | operator== (const T i, const rational &r) noexcept |
| | Equality operator.
|
| |
| bool | operator== (const integer &i, const rational &r) noexcept |
| | Equality operator.
|
| |
| bool | operator!= (int64_t i, const rational &r) noexcept |
| | Non-equality operator.
|
| |
| bool | operator!= (const integer &i, const rational &r) noexcept |
| | Non-equality operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| bool | operator< (const T i, const rational &r) noexcept |
| | Less than operator.
|
| |
| bool | operator< (const integer &i, const rational &r) noexcept |
| | Less than operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| bool | operator<= (const T i, const rational &r) noexcept |
| | Less than or equal to operator.
|
| |
| bool | operator<= (const integer &i, const rational &r) noexcept |
| | Less than or equal to operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| bool | operator> (const T i, const rational &r) noexcept |
| | Greater than operator.
|
| |
| bool | operator> (const integer &i, const rational &r) noexcept |
| | Greater than operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| bool | operator>= (const T i, const rational &r) noexcept |
| | Greater than or equal to operator.
|
| |
| bool | operator>= (const integer &i, const rational &r) noexcept |
| | Greater than or equal to operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| rational | operator+ (const T i, const rational &r) noexcept |
| | Addition operator.
|
| |
| rational | operator+ (const integer &i, const rational &r) noexcept |
| | Addition operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| rational | operator- (const T i, const rational &r) noexcept |
| | Substraction operator.
|
| |
| rational | operator- (const integer &i, const rational &r) noexcept |
| | Substraction operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| rational | operator* (const T i, const rational &r) noexcept |
| | Multiplication operator.
|
| |
| rational | operator* (const integer &i, const rational &r) noexcept |
| | Multiplication operator.
|
| |
| template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true> |
| rational | operator/ (const T i, const rational &r) noexcept |
| | Division operator.
|
| |
| void | swap (rational &r1, rational &r2) noexcept |
| | Swaps two rationals.
|
| |
Exact rational number.
This class wraps the mpq_t data structure from GMP with operators for an easy usage.