The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::utils::Rational< T > Class Template Reference

Class to represent a Rational number. More...

#include <Rational.hpp>

Public Member Functions

 Rational (const T &numerator=0, const T &denominator=1)
 
 Rational (const Rational< T > &r)
 
getNumerator () const
 
getDenominator () const
 
 operator T () const
 
 operator double () const
 
Rational< T > & operator= (const Rational< T > &r)
 
 operator std::string () const
 
void print (std::ostream &os) const
 
void simplify ()
 
Rational< T > operator* (const Rational< T > &r) const
 
Rational< T > & operator*= (const Rational< T > &r)
 
Rational< T > operator/ (const Rational< T > &r) const
 
Rational< T > & operator/= (const Rational< T > &r)
 
Rational< T > operator+ (const Rational< T > &r) const
 
Rational< T > & operator+= (const Rational< T > &r)
 
Rational< T > operator- (const Rational< T > &r) const
 
Rational< T > & operator-= (const Rational< T > &r)
 
Rational< T > inv ()
 
bool operator== (const Rational< T > &r)
 

Detailed Description

template<class T>
class sparta::utils::Rational< T >

Class to represent a Rational number.

Definition at line 20 of file Rational.hpp.

Constructor & Destructor Documentation

◆ Rational() [1/2]

template<class T >
sparta::utils::Rational< T >::Rational ( const T &  numerator = 0,
const T &  denominator = 1 
)
inline

Definition at line 23 of file Rational.hpp.

◆ Rational() [2/2]

template<class T >
sparta::utils::Rational< T >::Rational ( const Rational< T > &  r)
inline

Definition at line 31 of file Rational.hpp.

Member Function Documentation

◆ getDenominator()

template<class T >
T sparta::utils::Rational< T >::getDenominator ( ) const
inline

Definition at line 40 of file Rational.hpp.

◆ getNumerator()

template<class T >
T sparta::utils::Rational< T >::getNumerator ( ) const
inline

Definition at line 35 of file Rational.hpp.

◆ inv()

template<class T >
Rational< T > sparta::utils::Rational< T >::inv ( )
inline

Definition at line 186 of file Rational.hpp.

◆ operator double()

template<class T >
sparta::utils::Rational< T >::operator double ( ) const
inlineexplicit

Definition at line 51 of file Rational.hpp.

◆ operator std::string()

template<class T >
sparta::utils::Rational< T >::operator std::string ( ) const
inlineexplicit

Definition at line 65 of file Rational.hpp.

◆ operator T()

template<class T >
sparta::utils::Rational< T >::operator T ( ) const
inlineexplicit

Definition at line 45 of file Rational.hpp.

◆ operator*()

template<class T >
Rational< T > sparta::utils::Rational< T >::operator* ( const Rational< T > &  r) const
inline

Definition at line 106 of file Rational.hpp.

◆ operator*=()

template<class T >
Rational< T > & sparta::utils::Rational< T >::operator*= ( const Rational< T > &  r)
inline

Definition at line 111 of file Rational.hpp.

◆ operator+()

template<class T >
Rational< T > sparta::utils::Rational< T >::operator+ ( const Rational< T > &  r) const
inline

Definition at line 138 of file Rational.hpp.

◆ operator+=()

template<class T >
Rational< T > & sparta::utils::Rational< T >::operator+= ( const Rational< T > &  r)
inline

Definition at line 148 of file Rational.hpp.

◆ operator-()

template<class T >
Rational< T > sparta::utils::Rational< T >::operator- ( const Rational< T > &  r) const
inline

Definition at line 162 of file Rational.hpp.

◆ operator-=()

template<class T >
Rational< T > & sparta::utils::Rational< T >::operator-= ( const Rational< T > &  r)
inline

Definition at line 172 of file Rational.hpp.

◆ operator/()

template<class T >
Rational< T > sparta::utils::Rational< T >::operator/ ( const Rational< T > &  r) const
inline

Definition at line 119 of file Rational.hpp.

◆ operator/=()

template<class T >
Rational< T > & sparta::utils::Rational< T >::operator/= ( const Rational< T > &  r)
inline

Definition at line 124 of file Rational.hpp.

◆ operator=()

template<class T >
Rational< T > & sparta::utils::Rational< T >::operator= ( const Rational< T > &  r)
inline

Definition at line 56 of file Rational.hpp.

◆ operator==()

template<class T >
bool sparta::utils::Rational< T >::operator== ( const Rational< T > &  r)
inline

Definition at line 191 of file Rational.hpp.

◆ print()

template<class T >
void sparta::utils::Rational< T >::print ( std::ostream &  os) const
inline

Definition at line 86 of file Rational.hpp.

◆ simplify()

template<class T >
void sparta::utils::Rational< T >::simplify ( )
inline

Definition at line 91 of file Rational.hpp.


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