LAL: Linear Arrangement Library 23.01.00
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | Friends | List of all members
lal::numeric::rational Class Reference

Exact rational number. More...

#include <rational.hpp>

Public Member Functions

 rational () noexcept
 Empty constructor.
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
 rational (T n, uint64_t d=1) noexcept
 Constructor with numerator and denominator. More...
 
 rational (const integer &n, const integer &d=1) noexcept
 Constructor with numerator and denominator. More...
 
 rational (const std::string &s) noexcept
 Constructor with string. More...
 
 rational (const rational &r) noexcept
 Copy constructor. More...
 
 rational (integer &&i) noexcept
 Move constructor. More...
 
 rational (integer &&n, integer &&d) noexcept
 Move constructor with numerator and denominator. More...
 
 rational (rational &&r) noexcept
 Move constructor. More...
 
 ~rational () noexcept
 Destructor.
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
void set_number (T n, uint64_t d=1) noexcept
 Overwrites the value of this rational with \(n/d\). More...
 
void set_str (const std::string &s) noexcept
 Overwrites the value in the string s. More...
 
void set_integer (const integer &n, const integer &d) noexcept
 Overwrites the value of this rational with the value \(n/d\). More...
 
void set_rational (const rational &r) noexcept
 Overwrites the value of this rational with the value \(n/d\). More...
 
void invert () noexcept
 Changes numerator and denominator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rationaloperator= (T i) noexcept
 Assignment operator. More...
 
rationaloperator= (const std::string &s) noexcept
 Assignment operator. More...
 
rationaloperator= (const integer &i) noexcept
 Assignment operator. More...
 
rationaloperator= (const rational &r) noexcept
 Assignment operator. More...
 
rationaloperator= (integer &&i) noexcept
 Move assignment operator. More...
 
rationaloperator= (rational &&r) noexcept
 Move assignment operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool operator== (T i) const noexcept
 Equality operator. More...
 
bool operator== (const integer &i) const noexcept
 Equality operator. More...
 
bool operator== (const rational &r) const noexcept
 Equality operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool operator!= (T i) const noexcept
 Non-equality operator. More...
 
bool operator!= (const integer &i) const noexcept
 Non-equality operator. More...
 
bool operator!= (const rational &r) const noexcept
 Non-equality operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool operator< (T i) const noexcept
 Less than operator. More...
 
bool operator< (const integer &i) const noexcept
 Less than operator. More...
 
bool operator< (const rational &r) const noexcept
 Less than operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool operator<= (T i) const noexcept
 Less than or equal to operator. More...
 
bool operator<= (const integer &i) const noexcept
 Less than or equal to operator. More...
 
bool operator<= (const rational &r) const noexcept
 Less than or equal to operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool operator> (T i) const noexcept
 Greater than operator. More...
 
bool operator> (const integer &i) const noexcept
 Greater than operator. More...
 
bool operator> (const rational &r) const noexcept
 Greater than operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool operator>= (T i) const noexcept
 Greater than or equal to operator. More...
 
bool operator>= (const integer &i) const noexcept
 Greater than or equal to operator. More...
 
bool operator>= (const rational &r) const noexcept
 Greater than or equal to operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational operator+ (T i) const noexcept
 Addition operator. More...
 
rational operator+ (const integer &i) const noexcept
 Addition operator. More...
 
rational operator+ (const rational &r) const noexcept
 Addition operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rationaloperator+= (T i) noexcept
 Addition operator. More...
 
rationaloperator+= (const integer &i) noexcept
 Addition operator. More...
 
rationaloperator+= (const rational &r) noexcept
 Addition operator. More...
 
rational operator- () const noexcept
 Substraction unary operator.
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational operator- (T i) const noexcept
 Substraction operator. More...
 
rational operator- (const integer &i) const noexcept
 Substraction operator. More...
 
rational operator- (const rational &r) const noexcept
 Substraction operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rationaloperator-= (T i) noexcept
 Substraction operator. More...
 
rationaloperator-= (const integer &i) noexcept
 Substraction operator. More...
 
rationaloperator-= (const rational &r) noexcept
 Substraction operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational operator* (T i) const noexcept
 Multiplication operator. More...
 
rational operator* (const integer &i) const noexcept
 Multiplication operator. More...
 
rational operator* (const rational &r) const noexcept
 Multiplication operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rationaloperator*= (T i) noexcept
 Multiplication operator. More...
 
rationaloperator*= (const integer &i) noexcept
 Multiplication operator. More...
 
rationaloperator*= (const rational &r) noexcept
 Multiplication operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational operator/ (T i) const noexcept
 Division operator. More...
 
rational operator/ (const integer &i) const noexcept
 Division operator. More...
 
rational operator/ (const rational &r) const noexcept
 Division operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rationaloperator/= (T i) noexcept
 Division operator. More...
 
rationaloperator/= (const integer &i) noexcept
 Division operator. More...
 
rationaloperator/= (const rational &r) noexcept
 Division operator. More...
 
rational power (uint64_t i) const noexcept
 Exponentiation operator. More...
 
rational power (const integer &i) const noexcept
 Exponentiation operator. More...
 
rationalpowt (uint64_t i) noexcept
 Exponentiation operator. More...
 
rationalpowt (const integer &i) noexcept
 Exponentiation operator. More...
 
bool is_initialized () const noexcept
 Returns whether this object is initialised 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. More...
 
void as_integer (integer &i) const noexcept
 Converts this rational to an integer value. More...
 
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. More...
 

Private Attributes

mpq_t m_val
 Structure from GMP storing the rational's value.
 
bool m_initialized = true
 Is this rational initialised?
 

Friends

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool operator== (T i, const rational &r) noexcept
 Equality operator. More...
 
bool operator== (const integer &i, const rational &r) noexcept
 Equality operator. More...
 
bool operator!= (int64_t i, const rational &r) noexcept
 Non-equality operator. More...
 
bool operator!= (const integer &i, const rational &r) noexcept
 Non-equality operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool operator< (T i, const rational &r) noexcept
 Less than operator. More...
 
bool operator< (const integer &i, const rational &r) noexcept
 Less than operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool operator<= (T i, const rational &r) noexcept
 Less than or equal to operator. More...
 
bool operator<= (const integer &i, const rational &r) noexcept
 Less than or equal to operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool operator> (T i, const rational &r) noexcept
 Greater than operator. More...
 
bool operator> (const integer &i, const rational &r) noexcept
 Greater than operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool operator>= (T i, const rational &r) noexcept
 Greater than or equal to operator. More...
 
bool operator>= (const integer &i, const rational &r) noexcept
 Greater than or equal to operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational operator+ (T i, const rational &r) noexcept
 Addition operator. More...
 
rational operator+ (const integer &i, const rational &r) noexcept
 Addition operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational operator- (T i, const rational &r) noexcept
 Substraction operator. More...
 
rational operator- (const integer &i, const rational &r) noexcept
 Substraction operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational operator* (T i, const rational &r) noexcept
 Multiplication operator. More...
 
rational operator* (const integer &i, const rational &r) noexcept
 Multiplication operator. More...
 
template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational operator/ (T i, const rational &r) noexcept
 Division operator. More...
 
void swap (rational &r1, rational &r2) noexcept
 Swaps two rationals. More...
 

Detailed Description

Exact rational number.

This class wraps the mpq_t data structure from GMP with operators for an easy usage.

Constructor & Destructor Documentation

◆ rational() [1/7]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
lal::numeric::rational::rational ( n,
uint64_t  d = 1 
)
inlinenoexcept

Constructor with numerator and denominator.

Parameters
nNumerator, signed integer (basic type).
dDenominator, unsigned integer (basic type).

◆ rational() [2/7]

lal::numeric::rational::rational ( const integer n,
const integer d = 1 
)
inlinenoexcept

Constructor with numerator and denominator.

Parameters
nNumerator, a lal::numeric::integer.
dDenominator, a lal::numeric::integer.

◆ rational() [3/7]

lal::numeric::rational::rational ( const std::string &  s)
inlinenoexcept

Constructor with string.

Parameters
sA string.

◆ rational() [4/7]

lal::numeric::rational::rational ( const rational r)
inlinenoexcept

Copy constructor.

Parameters
rA lal::numeric::rational.

◆ rational() [5/7]

lal::numeric::rational::rational ( integer &&  i)
inlinenoexcept

Move constructor.

Parameters
iA lal::numeric::integer

◆ rational() [6/7]

lal::numeric::rational::rational ( integer &&  n,
integer &&  d 
)
inlinenoexcept

Move constructor with numerator and denominator.

Parameters
nNumerator, a lal::numeric::integer.
dDenominator, a lal::numeric::integer.
Postcondition
Objects n and d are not initialized.

◆ rational() [7/7]

lal::numeric::rational::rational ( rational &&  r)
inlinenoexcept

Move constructor.

Parameters
rA lal::numeric::rational.
Postcondition
Object r is not initialized.

Member Function Documentation

◆ as_integer()

void lal::numeric::rational::as_integer ( integer i) const
noexcept

Converts this rational to an integer value.

This function returns \(\left\lfloor n/d \right\rfloor\) where \(n,d\) are, respectively, the numerator and denominator.

Parameters
[out]iInteger representation of this rational.

◆ invert()

void lal::numeric::rational::invert ( )
inlinenoexcept

Changes numerator and denominator.

If this rational value was \(n/d\) then after calling this method it will be \(d/n\).

◆ operator!=() [1/3]

bool lal::numeric::rational::operator!= ( const integer i) const
inlinenoexcept

Non-equality operator.

Parameters
iA lal::numeric::integer.

◆ operator!=() [2/3]

bool lal::numeric::rational::operator!= ( const rational r) const
inlinenoexcept

Non-equality operator.

Parameters
rA lal::numeric::rational.

◆ operator!=() [3/3]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool lal::numeric::rational::operator!= ( i) const
inlinenoexcept

Non-equality operator.

Parameters
iAn integer (basic type) number.

◆ operator*() [1/3]

rational lal::numeric::rational::operator* ( const integer i) const
inlinenoexcept

Multiplication operator.

Parameters
iA lal::numeric::integer.

◆ operator*() [2/3]

rational lal::numeric::rational::operator* ( const rational r) const
inlinenoexcept

Multiplication operator.

Parameters
rA lal::numeric::rational.

◆ operator*() [3/3]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational lal::numeric::rational::operator* ( i) const
inlinenoexcept

Multiplication operator.

Parameters
iAn integer (basic type) number.

◆ operator*=() [1/3]

rational & lal::numeric::rational::operator*= ( const integer i)
inlinenoexcept

Multiplication operator.

Parameters
iA lal::numeric::integer.

◆ operator*=() [2/3]

rational & lal::numeric::rational::operator*= ( const rational r)
inlinenoexcept

Multiplication operator.

Parameters
rA lal::numeric::rational.

◆ operator*=() [3/3]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational & lal::numeric::rational::operator*= ( i)
inlinenoexcept

Multiplication operator.

Parameters
iAn integer (basic type) number.

◆ operator+() [1/3]

rational lal::numeric::rational::operator+ ( const integer i) const
inlinenoexcept

Addition operator.

Parameters
iA lal::numeric::integer.

◆ operator+() [2/3]

rational lal::numeric::rational::operator+ ( const rational r) const
inlinenoexcept

Addition operator.

Parameters
rA lal::numeric::rational.

◆ operator+() [3/3]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational lal::numeric::rational::operator+ ( i) const
inlinenoexcept

Addition operator.

Parameters
iAn integer (basic type) number.

◆ operator+=() [1/3]

rational & lal::numeric::rational::operator+= ( const integer i)
inlinenoexcept

Addition operator.

Parameters
iA lal::numeric::integer.

◆ operator+=() [2/3]

rational & lal::numeric::rational::operator+= ( const rational r)
inlinenoexcept

Addition operator.

Parameters
rA lal::numeric::rational.

◆ operator+=() [3/3]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational & lal::numeric::rational::operator+= ( i)
inlinenoexcept

Addition operator.

Parameters
iAn integer (basic type) number.

◆ operator-() [1/3]

rational lal::numeric::rational::operator- ( const integer i) const
inlinenoexcept

Substraction operator.

Parameters
iA lal::numeric::integer.

◆ operator-() [2/3]

rational lal::numeric::rational::operator- ( const rational r) const
inlinenoexcept

Substraction operator.

Parameters
rA lal::numeric::rational.

◆ operator-() [3/3]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational lal::numeric::rational::operator- ( i) const
inlinenoexcept

Substraction operator.

Parameters
iAn integer (basic type) number.

◆ operator-=() [1/3]

rational & lal::numeric::rational::operator-= ( const integer i)
inlinenoexcept

Substraction operator.

Parameters
iA lal::numeric::integer.

◆ operator-=() [2/3]

rational & lal::numeric::rational::operator-= ( const rational r)
inlinenoexcept

Substraction operator.

Parameters
rA lal::numeric::rational.

◆ operator-=() [3/3]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational & lal::numeric::rational::operator-= ( i)
inlinenoexcept

Substraction operator.

Parameters
iAn integer (basic type) number.

◆ operator/() [1/3]

rational lal::numeric::rational::operator/ ( const integer i) const
inlinenoexcept

Division operator.

Parameters
iA lal::numeric::integer.

◆ operator/() [2/3]

rational lal::numeric::rational::operator/ ( const rational r) const
inlinenoexcept

Division operator.

Parameters
rA lal::numeric::rational.

◆ operator/() [3/3]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational lal::numeric::rational::operator/ ( i) const
inlinenoexcept

Division operator.

Parameters
iAn integer (basic type) number.

◆ operator/=() [1/3]

rational & lal::numeric::rational::operator/= ( const integer i)
noexcept

Division operator.

Parameters
iA lal::numeric::integer.

◆ operator/=() [2/3]

rational & lal::numeric::rational::operator/= ( const rational r)
noexcept

Division operator.

Parameters
rA lal::numeric::rational.

◆ operator/=() [3/3]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational & lal::numeric::rational::operator/= ( i)
inlinenoexcept

Division operator.

Parameters
iAn integer (basic type) number.

◆ operator<() [1/3]

bool lal::numeric::rational::operator< ( const integer i) const
inlinenoexcept

Less than operator.

Parameters
iA lal::numeric::integer.

◆ operator<() [2/3]

bool lal::numeric::rational::operator< ( const rational r) const
inlinenoexcept

Less than operator.

Parameters
rA lal::numeric::rational.

◆ operator<() [3/3]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool lal::numeric::rational::operator< ( i) const
inlinenoexcept

Less than operator.

Parameters
iAn integer (basic type) number.

◆ operator<=() [1/3]

bool lal::numeric::rational::operator<= ( const integer i) const
inlinenoexcept

Less than or equal to operator.

Parameters
iA lal::numeric::integer.

◆ operator<=() [2/3]

bool lal::numeric::rational::operator<= ( const rational r) const
inlinenoexcept

Less than or equal to operator.

Parameters
rA lal::numeric::rational.

◆ operator<=() [3/3]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool lal::numeric::rational::operator<= ( i) const
inlinenoexcept

Less than or equal to operator.

Parameters
iAn integer (basic type) number.

◆ operator=() [1/6]

rational & lal::numeric::rational::operator= ( const integer i)
inlinenoexcept

Assignment operator.

Parameters
iA lal::numeric::integer.

◆ operator=() [2/6]

rational & lal::numeric::rational::operator= ( const rational r)
inlinenoexcept

Assignment operator.

Parameters
rA lal::numeric::rational.

◆ operator=() [3/6]

rational & lal::numeric::rational::operator= ( const std::string &  s)
inlinenoexcept

Assignment operator.

Parameters
sA string.

◆ operator=() [4/6]

rational & lal::numeric::rational::operator= ( integer &&  i)
inlinenoexcept

Move assignment operator.

Parameters
iA lal::numeric::integer.
Postcondition
Object i is not initialized.

◆ operator=() [5/6]

rational & lal::numeric::rational::operator= ( rational &&  r)
inlinenoexcept

Move assignment operator.

Parameters
rA lal::numeric::rational.
Postcondition
Object i is not initialized.

◆ operator=() [6/6]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational & lal::numeric::rational::operator= ( i)
inlinenoexcept

Assignment operator.

Parameters
iAn integer (basic type) number.

◆ operator==() [1/3]

bool lal::numeric::rational::operator== ( const integer i) const
inlinenoexcept

Equality operator.

Parameters
iA lal::numeric::integer.

◆ operator==() [2/3]

bool lal::numeric::rational::operator== ( const rational r) const
inlinenoexcept

Equality operator.

Parameters
rA lal::numeric::rational.

◆ operator==() [3/3]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool lal::numeric::rational::operator== ( i) const
inlinenoexcept

Equality operator.

Parameters
iAn integer (basic type) number.

◆ operator>() [1/3]

bool lal::numeric::rational::operator> ( const integer i) const
inlinenoexcept

Greater than operator.

Parameters
iA lal::numeric::integer.

◆ operator>() [2/3]

bool lal::numeric::rational::operator> ( const rational r) const
inlinenoexcept

Greater than operator.

Parameters
rA lal::numeric::rational.

◆ operator>() [3/3]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool lal::numeric::rational::operator> ( i) const
inlinenoexcept

Greater than operator.

Parameters
iAn integer (basic type) number.

◆ operator>=() [1/3]

bool lal::numeric::rational::operator>= ( const integer i) const
inlinenoexcept

Greater than or equal to operator.

Parameters
iA lal::numeric::integer.

◆ operator>=() [2/3]

bool lal::numeric::rational::operator>= ( const rational r) const
inlinenoexcept

Greater than or equal to operator.

Parameters
rA lal::numeric::rational.

◆ operator>=() [3/3]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool lal::numeric::rational::operator>= ( i) const
inlinenoexcept

Greater than or equal to operator.

Parameters
iAn integer (basic type) number.

◆ power() [1/2]

rational lal::numeric::rational::power ( const integer i) const
noexcept

Exponentiation operator.

Parameters
iA lal::numeric::integer.

◆ power() [2/2]

rational lal::numeric::rational::power ( uint64_t  i) const
noexcept

Exponentiation operator.

Parameters
iAn unsigned integer (basic type).

◆ powt() [1/2]

rational & lal::numeric::rational::powt ( const integer i)
noexcept

Exponentiation operator.

Parameters
iA lal::numeric::integer.

◆ powt() [2/2]

rational & lal::numeric::rational::powt ( uint64_t  i)
noexcept

Exponentiation operator.

Parameters
iAn unsigned integer (basic type).

◆ set_integer()

void lal::numeric::rational::set_integer ( const integer n,
const integer d 
)
inlinenoexcept

Overwrites the value of this rational with the value \(n/d\).

Parameters
nNumerator, a lal::numeric::integer.
dDenominator, a lal::numeric::integer.

◆ set_number()

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
void lal::numeric::rational::set_number ( n,
uint64_t  d = 1 
)
inlinenoexcept

Overwrites the value of this rational with \(n/d\).

Parameters
nNumerator, signed integer (basic type).
dDenominator, unsigned integer (basic type).

◆ set_rational()

void lal::numeric::rational::set_rational ( const rational r)
inlinenoexcept

Overwrites the value of this rational with the value \(n/d\).

Parameters
rA lal::numeric::rational.

◆ set_str()

void lal::numeric::rational::set_str ( const std::string &  s)
inlinenoexcept

Overwrites the value in the string s.

Parameters
sA string.

◆ swap()

void lal::numeric::rational::swap ( rational r)
inlinenoexcept

Swaps the value of this rational with rational r's value.

  • If none of the rationals is initialised, it does nothing.
  • If only one of the rationals is initialised, moves the contents of the initialised rational to the other. At the end, one of the two rationals is left uninitiliased.
  • If both rationals are initialised, swaps the values they contain.

◆ to_integer()

integer lal::numeric::rational::to_integer ( ) const
inlinenoexcept

Converts this rational to an integer value.

This function returns \(\left\lfloor n/d \right\rfloor\) where \(n,d\) are, respectively, the numerator and denominator.

Returns
The floor of this rational.

Friends And Related Function Documentation

◆ operator!= [1/2]

bool operator!= ( const integer i,
const rational r 
)
friend

Non-equality operator.

Parameters
iA lal::numeric::integer.
rA lal::numeric::rational.

◆ operator!= [2/2]

bool operator!= ( int64_t  i,
const rational r 
)
friend

Non-equality operator.

Parameters
iAn integer (basic type) number.
rA lal::numeric::rational.

◆ operator* [1/2]

rational operator* ( const integer i,
const rational r 
)
friend

Multiplication operator.

Parameters
iA lal::numeric::integer.
rA lal::numeric::rational.

◆ operator* [2/2]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational operator* ( i,
const rational r 
)
friend

Multiplication operator.

Parameters
iAn integer (basic type) number.
rA lal::numeric::rational.

◆ operator+ [1/2]

rational operator+ ( const integer i,
const rational r 
)
friend

Addition operator.

Parameters
iA lal::numeric::integer.
rA lal::numeric::rational.

◆ operator+ [2/2]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational operator+ ( i,
const rational r 
)
friend

Addition operator.

Parameters
iAn integer (basic type) number.
rA lal::numeric::rational.

◆ operator- [1/2]

rational operator- ( const integer i,
const rational r 
)
friend

Substraction operator.

Parameters
iA lal::numeric::integer.
rA lal::numeric::rational.

◆ operator- [2/2]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational operator- ( i,
const rational r 
)
friend

Substraction operator.

Parameters
iAn integer (basic type) number.
rA lal::numeric::rational.

◆ operator/

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
rational operator/ ( i,
const rational r 
)
friend

Division operator.

Parameters
iAn integer (basic type) number.
rRational value.

◆ operator< [1/2]

bool operator< ( const integer i,
const rational r 
)
friend

Less than operator.

Parameters
iA lal::numeric::integer.
rA lal::numeric::rational.

◆ operator< [2/2]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool operator< ( i,
const rational r 
)
friend

Less than operator.

Parameters
iAn integer (basic type) number.
rA lal::numeric::rational.

◆ operator<= [1/2]

bool operator<= ( const integer i,
const rational r 
)
friend

Less than or equal to operator.

Parameters
iA lal::numeric::integer.
rA lal::numeric::rational.

◆ operator<= [2/2]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool operator<= ( i,
const rational r 
)
friend

Less than or equal to operator.

Parameters
iAn integer (basic type) number.
rA lal::numeric::rational.

◆ operator== [1/2]

bool operator== ( const integer i,
const rational r 
)
friend

Equality operator.

Parameters
iA lal::numeric::integer.
rA lal::numeric::rational.

◆ operator== [2/2]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool operator== ( i,
const rational r 
)
friend

Equality operator.

Parameters
iAn integer (basic type) number.
rA lal::numeric::rational.

◆ operator> [1/2]

bool operator> ( const integer i,
const rational r 
)
friend

Greater than operator.

Parameters
iA lal::numeric::integer.
rA lal::numeric::rational.

◆ operator> [2/2]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool operator> ( i,
const rational r 
)
friend

Greater than operator.

Parameters
iAn integer (basic type) number.
rA lal::numeric::rational.

◆ operator>= [1/2]

bool operator>= ( const integer i,
const rational r 
)
friend

Greater than or equal to operator.

Parameters
iA lal::numeric::integer.
rA lal::numeric::rational.

◆ operator>= [2/2]

template<typename T , std::enable_if_t< std::is_integral_v< T >, bool > = true>
bool operator>= ( i,
const rational r 
)
friend

Greater than or equal to operator.

Parameters
iAn integer (basic type) number.
rA lal::numeric::rational.

◆ swap

void swap ( rational r1,
rational r2 
)
friend

Swaps two rationals.

Parameters
r1Input rational.
r2Input rational.

The documentation for this class was generated from the following file: