Semantic Object Rational Number.
More...
#include <soq.h>
|
|
| SOQ () |
| | Ctor.
|
| |
|
| SOQ (const mpq_t p_q) |
| | Ctor.
|
| |
|
| SOQ (const __int128 p_num, const __int128 p_den) |
| | Ctor.
|
| |
|
| ~SOQ () |
| | Dtor.
|
| |
| SOQ * | dup () const override |
| | Creates a new instance as copy following the red book definition.
|
| |
| std::string | opequal () const override |
| | For operators '=', 'cvs' and 'stack'.
|
| |
| OTCode | ot () const override |
| | Returns an OTCode.
|
| |
| std::string | type () const override |
| | Returns a type name.
|
| |
| bool | equal (const SO *p_other) const override |
| | Equality.
|
| |
| bool | gt (const SO *p_other) const override |
| | Greater than.
|
| |
| bool | ge (const SO *p_other) const override |
| | Greater or equal.
|
| |
|
void | getRational (mpq_t p_q) const |
| | Set the parameter to our value.
|
| |
|
void | setRational (const mpq_t p_q) |
| | Replaces the rational by the parameter.
|
| |
|
void | getNumerator (mpz_t p_z) const |
| | Set the parameter to our numerator value.
|
| |
|
void | setNumerator (mpz_t p_z) |
| | Replaces numerator.
|
| |
| bool | getComponents (__int128 &p_num, __int128 &p_den) const |
| | Set the parameters to 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 the string for a presentation of a rational.
|
| |
|
void | abs () |
| | Inplace abs.
|
| |
|
void | neg () |
| | Inplace neg.
|
| |
|
void | reciprocal () |
| | Inplace reciprocal.
|
| |
| __float128 | flt128 () const |
| | A real representation of the rational.
|
| |
|
| SO (bool p_exec=false) |
| | Ctor.
|
| |
| virtual | ~SO ()=default |
| | Virtual dtor.
|
| |
|
bool | getExec () const |
| | Getter for exec_.
|
| |
|
void | setExec (bool p_exec) |
| | Setter for exec_.
|
| |
| virtual size_t | getSize () const |
| | Getter for the number of characters or number of objects.
|
| |
| virtual SO * | clone () const |
| | Creates a new instance as copy with deep cloning.
|
| |
| virtual std::string | opequalequal () const |
| | For operators '==' and 'pstack'.
|
| |
|
| Counter (Counter< SO > &&)=delete |
| |
|
Counter< SO > & | operator= (const Counter< SO > &)=delete |
| |
|
Counter< SO > & | operator= (Counter< SO > &&)=delete |
| |
|
| bool | invariant () const noexcept override |
| | Checks class invariants.
|
| |
|
| Counter () |
| | Ctor.
|
| |
|
| Counter (const Counter< SO > &) |
| | Copy ctor.
|
| |
|
| ~Counter () |
| | Dtor.
|
| |
|
|
size_t | str_length () const |
| | Size of the string representation in characters.
|
| |
|
|
mpq_t | q_ |
| | The rational number by GMP.
|
| |
|
|
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.
- Invariant
- denominator > 0
-
gcd of numerator and denominator == 1
◆ dup()
Creates a new instance as copy following the red book definition.
Implements SO.
◆ equal()
| bool SOQ::equal |
( |
const SO * |
| ) |
const |
|
inlineoverridevirtual |
Equality.
Equality means: SOL und SOM are always equal.
For SOD 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<>.
- Returns
- bool ... true if the SO's are of the same type and equal
- See also
- Will be used directly and unchanged as operator eq
Implements SO.
◆ flt128()
| __float128 SOQ::flt128 |
( |
| ) |
const |
A real representation of the rational.
- Returns
- __float128 ... the representation as R
◆ ge()
| bool SOQ::ge |
( |
const SO * |
| ) |
const |
|
inlineoverridevirtual |
Greater or equal.
Will be overwritten for SOI, SOR, SOQ and SOS. The redundancy between equal(), gt() and ge() ist a matter of performance.
Reimplemented from SO.
◆ getComponents()
| bool SOQ::getComponents |
( |
__int128 & |
p_num, |
|
|
__int128 & |
p_den |
|
) |
| const |
|
inline |
Set the parameters to numerator and denominator.
- Returns
- bool ... false if the components of the fraction do not fit into __int128
◆ gt()
| bool SOQ::gt |
( |
const SO * |
| ) |
const |
|
inlineoverridevirtual |
Greater than.
Will be overwritten for SOI, SOR, SOQ and SOS. The redundancy between equal(), gt() and ge() ist a matter of performance.
Reimplemented from SO.
◆ invariant()
| bool SOQ::invariant |
( |
| ) |
const |
|
inlineoverrideprotectedvirtualnoexcept |
Checks class invariants.
- Returns
- bool ... Indicates whether the class invariants are maintained.
Reimplemented from DbC.
◆ opequal()
| std::string SOQ::opequal |
( |
| ) |
const |
|
inlineoverridevirtual |
For operators '=', 'cvs' and 'stack'.
Implements SO.
◆ ot()
Returns an OTCode.
A "manual" implementation of polymorphism, where C++-polymorphisms fail
- Returns
- OTCode ... The OTCode of the instance.
Implements SO.
◆ parse()
| bool SOQ::parse |
( |
std::string |
p_str | ) |
|
|
inline |
Parses the string for a presentation of a rational.
Accepts two integers separated by a '/'. Accepts a single integer without '/' characters. Ignores whitespaces completely.
- Returns
- bool ... true if parsing succeeds
- Parameters
-
| [in] | p_str | the string to be parsed |
◆ type()
| std::string SOQ::type |
( |
| ) |
const |
|
inlineoverridevirtual |
Returns a type name.
- Returns
- std::string ... The type name of the instance.
Implements SO.
The documentation for this class was generated from the following files: