|
Leonardus
|
Semantic Object Rational Number. More...
#include <soq.h>
Inheritance diagram for SOQ:
Collaboration diagram for SOQ:Public Member Functions | |
| SOQ () | |
| Ctor. | |
| SOQ (std::string &p_s) | |
| Ctor from a string representation. | |
| SOQ (const mpq_t p_q) | |
| Ctor from a mpq_t. | |
| SOQ (const __int128 p_num, const __int128 p_den) | |
| Ctor from a numerator and a denominator. | |
| ~SOQ () override | |
| Dtor. | |
| SOQ (const SOQ &)=delete | |
| SOQ (SOQ &&)=delete | |
| SOQ & | operator= (const SOQ &)=delete |
| SOQ & | operator= (SOQ &&)=delete |
| SOQ * | dup () const override |
| Creates a new instance as copy following the red book definition. | |
| std::string | opequal () const override |
| String representation of object for operators '=', 'cvs' and 'stack'. | |
| OTCode | ot () const override |
| Returns an OTCode. | |
| std::string_view | type () const override |
| Returns a type name. | |
| bool | equal (const SO *p_other) const override |
| Checks if this SO is equal to another SO. | |
| bool | gt (OpError &p_ec, const SO *p_other) const override |
| Greater than. | |
| bool | ge (OpError &p_ec, const SO *p_other) const override |
| Greater or equal. | |
| void | getRational (mpq_t p_q) const |
| Getter for q_. | |
| void | setRational (const mpq_t p_q) |
| Setter for the rational number. | |
| void | getNumerator (mpz_t p_z) const |
| Getter for the numerator of q_. | |
| void | setNumerator (mpz_t p_z) |
| Setter for the numerator of q_. | |
| bool | getComponents (__int128 &p_num, __int128 &p_den) const |
| Getter for numerator and denominator. | |
| bool | isunitfraction () const |
| Checks numerator == 1. | |
| bool | isinteger () const |
| Checks denominator == 1. | |
| void | divqr (mpq_t p_q, mpq_t p_r) const |
| Calculates quotient and remainder. | |
| bool | parse (std::string &p_str) |
| Parses a string representation of a rational number. | |
| void | abs__1 () |
| In place abs. | |
| void | neg__1 () |
| In place neg. | |
| void | sqr__1 () |
| In place sqr. | |
| void | half__1 () |
| In place half value. | |
| void | reciprocal__1 (OpError &p_ec) |
| In place reciprocal. | |
| __float128 | float128 (OpError &p_ec) const |
| Converts the rational number to a real number. | |
Public Member Functions inherited from SO | |
| SO () | |
| Ctor. | |
| SO (bool p_exec) | |
| Ctor. | |
| SO (const SO &p_other) | |
| Copy ctor. | |
| virtual | ~SO ()=default |
| Virtual dtor. | |
| SO (SO &&)=delete | |
| SO & | operator= (const SO &)=delete |
| SO & | operator= (SO &&)=delete |
| bool | getExec () const |
| Getter for exec_. | |
| void | setExec (bool p_exec) |
| Setter for exec_. | |
| virtual size_t | getSize () const |
| Returns the size of the SO. | |
| virtual SO * | clone () const |
| Creates a new instance as copy with deep cloning. | |
| virtual std::string | opequalequal () const |
| String representation for operators '==' and 'pstack'. | |
Public Member Functions inherited from Counter< SO > | |
| Counter (Counter< SO > &&)=delete | |
| Counter< SO > & | operator= (const Counter< SO > &)=delete |
| Counter< SO > & | operator= (Counter< SO > &&)=delete |
Protected Member Functions | |
| bool | invariant () const noexcept override |
| Checks class invariants. | |
Protected Member Functions inherited from Counter< SO > | |
| Counter () | |
| Ctor. | |
| Counter (const Counter< SO > &) | |
| Copy ctor. | |
| ~Counter () | |
| Dtor. | |
Protected Member Functions inherited from DbC | |
| ~DbC ()=default | |
| Protected dtor. | |
Private Member Functions | |
| size_t | str_length () const |
| Calculates an upper limit of the maximum length of the string representation of q_. | |
| bool | parse_work (std::string &p_str) |
| Parses a string representation of a rational number. | |
Private Attributes | |
| mpq_t | q_ {} |
| The rational number by GMP. | |
Additional Inherited Members | |
Static Public Member Functions inherited from Counter< SO > | |
| static size_t | getTotalCounter () |
| Static getter for totaly created objects. | |
| static size_t | getAliveCounter () |
| Static getter for objects alive. | |
| static size_t | getWatermarkCounter () |
| Static getter for the object counter watermark. | |
Semantic Object Rational Number.
A multiple precicion rational number.
|
inlineexplicit |
Ctor from a string representation.
| [in] | p_s | The string to parse as rational number. |
|
inlineexplicit |
Ctor from a mpq_t.
| [in] | p_q | The value to be used. |
|
inline |
Ctor from a numerator and a denominator.
| [in] | p_num | The numerator of the rational number. |
| [in] | p_den | The denominator of the rational number. |
|
inline |
Calculates quotient and remainder.
| [out] | p_q | The quotient as rational number with denominator 1. |
| [out] | p_r | The remainder as rational number 0<=Q<1 thus a proper fraction. |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Checks if this SO is equal to another SO.
Equality means:
SOL und SOM are always equal.
For SOD, SOF and SOK, share_ptr<> points to the same object.
For SOA, share_ptr<> points to the same object, but empty arrays are equal nonetheless.
For SOO and SOo the function pointer must be the same.
Otherwise the value must be the same, even for SOS with shared_ptr<>.
| [in] | p_other | The object to compare with. |
Implements SO.
| __float128 SOQ::float128 | ( | OpError & | p_ec | ) | const |
Converts the rational number to a real number.
| [out] | p_ec | OpError::success or an error code of the conversion. |
|
inline |
Getter for numerator and denominator.
| [out] | p_num | Gets the the numerator of q_ converted into __int128. |
| [out] | p_den | Gets the the denominator of q_ converted into __int128. |
|
inline |
Getter for the numerator of q_.
| [out] | p_z | Gets the the numerator of q_ |
|
inline |
Getter for q_.
| [out] | p_q | Gets the value of q_ |
|
inlineoverrideprotectedvirtualnoexcept |
Checks class invariants.
Reimplemented from DbC.
|
inline |
Checks denominator == 1.
|
inline |
Checks numerator == 1.
|
overridevirtual |
String representation of object for operators '=', 'cvs' and 'stack'.
Implements SO.
|
inlineoverridevirtual |
Returns an OTCode.
A "manual" implementation of polymorphism, where C++-polymorphisms fail
Implements SO.
|
inline |
Parses a string representation of a rational number.
Accepts two integers separated by a ':' or a '/'.
Accepts a single integer without delimiting characters.
Ignores whitespaces completely.
| [in] | p_str | The string to parse. |
|
private |
Parses a string representation of a rational number.
Accepts two integers separated by a ':' or a '/'.
Accepts a single integer without delimiting characters.
Ignores whitespaces completely.
This function is separated from parse() to allow a call from the ctor.
| [in] | p_str | The string to parse. |
|
inline |
In place reciprocal.
| [out] | p_ec | Success or error code. |
|
inline |
Setter for the rational number.
|
inlineprivate |
Calculates an upper limit of the maximum length of the string representation of q_.
|
inlineoverridevirtual |
|
private |
The rational number by GMP.
The initialization is a dead store.