Arkulib
|
This class can be used to express big rationals. More...
#include <ERational.hpp>
Public Member Functions | |
constexpr | ERational () |
Default constructor : instantiate an object without parameters. More... | |
template<typename IntType = int> | |
constexpr | ERational (IntType numerator, IntType denominator, bool willBeReduce=false, bool willDenominatorBeVerified=true) |
Classic constructor : create an experimental rational from a numerator and a denominator (set default at 1) More... | |
template<typename FloatingType > | |
constexpr | ERational (const FloatingType &nonRational) |
Create an experimental rational from a floating number. More... | |
constexpr | ERational (const ERational< FloatType > &reference)=default |
Copy constructor. More... | |
template<typename IntType > | |
constexpr | ERational (const Rational< IntType > &reference) |
Copy constructor from a Rational. More... | |
constexpr | ERational (FloatType numMultiplier, short int numExponent, FloatType denMultiplier, short int denExponent) |
Explicit constructor. More... | |
constexpr | ERational (std::pair< FloatType, short int > numerator, std::pair< FloatType, short int > denominator) |
Explicit constructor with std::pair. More... | |
~ERational ()=default | |
Default Destructor. More... | |
constexpr std::pair< FloatType, short int > | getNumerator () const noexcept |
constexpr FloatType | getNumMultiplier () const noexcept |
constexpr short int | getNumExponent () const noexcept |
constexpr std::pair< FloatType, short int > | getDenominator () const noexcept |
constexpr FloatType | getDenMultiplier () const noexcept |
constexpr short int | getDenExponent () const noexcept |
constexpr void | setNumerator (std::pair< FloatType, short int > numerator) noexcept |
constexpr void | setNumerator (FloatType newMultiplier, short int newExponent) noexcept |
constexpr void | setNumMultiplier (FloatType newNumMultiplier) noexcept |
constexpr void | setNumExponent (short int newNumExponent) noexcept |
constexpr void | setDenominator (std::pair< FloatType, short int > denominator) noexcept |
constexpr void | setDenominator (FloatType newMultiplier, short int newExponent) noexcept |
constexpr void | setDenMultiplier (FloatType newDenMultiplier) noexcept |
constexpr void | setDenExponent (short int newDenExponent) noexcept |
constexpr ERational< FloatType > | operator+ (const ERational< FloatType > &anotherERational) const |
Sum operation between 2 experimental rationals. More... | |
constexpr ERational< FloatType > | operator- (const ERational< FloatType > &anotherERational) const |
Subtraction operation between 2 experimental rationals. More... | |
constexpr ERational< FloatType > | operator* (const ERational< FloatType > &anotherERational) const |
Multiplication operation between 2 experimental rationals. More... | |
constexpr ERational< FloatType > | operator/ (const ERational< FloatType > &anotherERational) const |
Division operation between 2 experimental rationals. More... | |
constexpr bool | operator== (const ERational< FloatType > &anotherERational) const |
Comparison between 2 ERationals. More... | |
constexpr bool | operator!= (const ERational< FloatType > &anotherERational) const |
Different comparison between 2 erationals. More... | |
bool | isNegative () const noexcept |
bool | isInteger () const noexcept |
bool | isZero () const noexcept |
constexpr ERational< FloatType > | abs () const |
Apply absolute value on the ERational. More... | |
constexpr ERational< FloatType > | inverse () const |
Get the inverse of an ERational. More... | |
constexpr ERational< FloatType > | simplify () noexcept |
Simplify the Rational with GCD. More... | |
template<typename AnotherFloatType = double> | |
constexpr AnotherFloatType | toRealNumber () const noexcept |
Get an approximation floating point number of the experimental ratio. More... | |
std::string | toString () const noexcept |
Return ( numerator / denominator ) as a string. More... | |
template<typename AnotherFloatType > | |
constexpr | ERational (const AnotherFloatType &nonRational) |
template<typename IntType > | |
constexpr std::pair< FloatType, short > | transformOperandToPair (IntType operand) |
Private Member Functions | |
template<typename IntType = int> | |
constexpr void | transformToExperimental (IntType numerator, IntType denominator) |
Set the parameters from a normal numerator and denominator. More... | |
constexpr void | verifyDenominator (bool checkIfDenominatorIsNull=true) |
Verify if the denominator is null or negative. More... | |
constexpr void | verifyTemplateType () const |
Verify if the template is correct. Throw an exception if the template is an integral. More... | |
constexpr void | setAtSameNumeratorExponent (ERational< FloatType > &firstERational, ERational< FloatType > &secondERational) const |
Set firstERational and secondERational with the same numerator exponent. More... | |
constexpr void | setAtSameDenominator (ERational< FloatType > &firstERational, ERational< FloatType > &secondERational) const |
Set firstERational and secondERational with the same denominator exponent. More... | |
Static Private Member Functions | |
template<typename IntType = int> | |
static constexpr std::pair< FloatType, short int > | transformOperandToPair (IntType operand) |
Transform a numerator/denominator into a pair. More... | |
Private Attributes | |
std::pair< FloatType, short int > | m_numerator |
std::pair< FloatType, short int > | m_denominator |
This class can be used to express big rationals.
FloatType |
Definition at line 21 of file ERational.hpp.
|
explicitconstexpr |
Default constructor : instantiate an object without parameters.
Definition at line 346 of file ERational.hpp.
|
explicitconstexpr |
Classic constructor : create an experimental rational from a numerator and a denominator (set default at 1)
numerator | |
denominator | |
willBeReduce | |
willDenominatorBeVerified |
Definition at line 353 of file ERational.hpp.
|
explicitconstexpr |
Create an experimental rational from a floating number.
FloatingType |
nonRational |
|
inlineconstexprdefault |
Copy constructor.
IntType |
reference |
|
inlineexplicitconstexpr |
|
constexpr |
Explicit constructor.
numMultiplier | |
numExponent | |
denMultiplier | |
denExponent |
Definition at line 385 of file ERational.hpp.
|
constexpr |
Explicit constructor with std::pair.
numerator | |
denominator |
Definition at line 397 of file ERational.hpp.
|
inlinedefault |
Default Destructor.
|
constexpr |
Definition at line 375 of file ERational.hpp.
|
inlineconstexprnoexcept |
Definition at line 104 of file ERational.hpp.
|
inlineconstexprnoexcept |
Definition at line 105 of file ERational.hpp.
|
inlineconstexprnoexcept |
Definition at line 106 of file ERational.hpp.
|
inlineconstexprnoexcept |
Definition at line 108 of file ERational.hpp.
|
inlineconstexprnoexcept |
Definition at line 109 of file ERational.hpp.
|
inlineconstexprnoexcept |
Definition at line 110 of file ERational.hpp.
|
inlineconstexprnoexcept |
Definition at line 116 of file ERational.hpp.
|
inlineconstexprnoexcept |
Definition at line 117 of file ERational.hpp.
|
inlineconstexprnoexcept |
Definition at line 118 of file ERational.hpp.
|
inlineconstexprnoexcept |
Definition at line 119 of file ERational.hpp.
|
inlineconstexprnoexcept |
Definition at line 121 of file ERational.hpp.
|
inlineconstexprnoexcept |
Definition at line 122 of file ERational.hpp.
|
inlineconstexprnoexcept |
Definition at line 123 of file ERational.hpp.
|
inlineconstexprnoexcept |
Definition at line 124 of file ERational.hpp.
|
constexpr |
Sum operation between 2 experimental rationals.
anotherERational |
Definition at line 410 of file ERational.hpp.
|
constexpr |
Subtraction operation between 2 experimental rationals.
anotherERational |
Definition at line 431 of file ERational.hpp.
|
constexpr |
Multiplication operation between 2 experimental rationals.
anotherERational |
Definition at line 452 of file ERational.hpp.
|
constexpr |
Division operation between 2 experimental rationals.
anotherERational |
Definition at line 466 of file ERational.hpp.
|
inlineconstexpr |
Comparison between 2 ERationals.
anotherERational |
Definition at line 480 of file ERational.hpp.
|
inlineconstexpr |
Different comparison between 2 erationals.
anotherERational |
Definition at line 498 of file ERational.hpp.
|
inlinenoexcept |
Definition at line 199 of file ERational.hpp.
|
inlinenoexcept |
Definition at line 207 of file ERational.hpp.
|
inlinenoexcept |
Definition at line 212 of file ERational.hpp.
|
inlineconstexpr |
Apply absolute value on the ERational.
Definition at line 222 of file ERational.hpp.
|
inlineconstexpr |
Get the inverse of an ERational.
Definition at line 233 of file ERational.hpp.
|
constexprnoexcept |
Simplify the Rational with GCD.
Definition at line 507 of file ERational.hpp.
|
inlineconstexprnoexcept |
Get an approximation floating point number of the experimental ratio.
AnotherFloatType |
Definition at line 252 of file ERational.hpp.
|
inlinenoexcept |
Return ( numerator / denominator ) as a string.
Definition at line 262 of file ERational.hpp.
|
constexprprivate |
Set the parameters from a normal numerator and denominator.
numerator | |
denominator |
Definition at line 530 of file ERational.hpp.
|
staticconstexprprivate |
Transform a numerator/denominator into a pair.
IntType |
operand |
|
constexprprivate |
Verify if the denominator is null or negative.
checkIfDenominatorIsNull |
Definition at line 546 of file ERational.hpp.
|
inlineconstexprprivate |
Verify if the template is correct. Throw an exception if the template is an integral.
Definition at line 298 of file ERational.hpp.
|
constexprprivate |
Set firstERational and secondERational with the same numerator exponent.
firstERational | |
secondERational |
Definition at line 557 of file ERational.hpp.
|
constexprprivate |
Set firstERational and secondERational with the same denominator exponent.
firstERational | |
secondERational |
Definition at line 570 of file ERational.hpp.
|
constexpr |
Definition at line 537 of file ERational.hpp.
|
private |
Definition at line 326 of file ERational.hpp.
|
private |
Definition at line 328 of file ERational.hpp.