|
Graphite Version 3
An experimental 3D geometry processing program
|
rationalg (generic rational) is used to compute the sign of rational fractions exactly. More...
#include <geogram/basic/rationalg.h>
Public Types | |
| typedef T | value_type |
Public Member Functions | |
| rationalg (double x) | |
| Constructs a new rationalg from a double. | |
| rationalg (const T &x) | |
| Constructs a new rationalg from an T. | |
| rationalg (T &&x) | |
| Constructs a new rationalg from an T with move semantics. | |
| rationalg (double num, double denom) | |
| Constructs a new rationalg from two doubles. | |
| rationalg (const T &num, const T &denom) | |
| Constructs a new rationalg from two T. | |
| rationalg (T &&num, T &&denom) | |
| Constructs a new rationalg from two T with move semantics. | |
| rationalg (const rationalg< T > &rhs)=default | |
| Copy-constructor. | |
| rationalg (rationalg< T > &&rhs)=default | |
| Move-constructor. | |
| rationalg< T > & | operator= (const rationalg< T > &rhs)=default |
| Assignment operator. | |
| rationalg< T > & | operator= (rationalg< T > &&rhs)=default |
| Assignment operator with move semantics. | |
| const T & | num () const |
| gets the numerator. | |
| const T & | denom () const |
| gets the denominator. | |
| T & | num () |
| gets the numerator. | |
| T & | denom () |
| gets the denominator. | |
| void | optimize () |
| Optimizes the internal representation without changing the represented value. | |
| rationalg< T > & | operator+= (const rationalg< T > &rhs) |
| Adds a rationalg to this rationalg. | |
| rationalg< T > & | operator-= (const rationalg< T > &rhs) |
| Subtracts a rationalg to this rationalg. | |
| rationalg< T > & | operator*= (const rationalg< T > &rhs) |
| Multiplies this rationalg by a rationalg. | |
| rationalg< T > & | operator/= (const rationalg< T > &rhs) |
| Divides this rationalg by a rationalg. | |
| rationalg< T > & | operator+= (double rhs) |
| Adds a double to this rationalg. | |
| rationalg< T > & | operator-= (double rhs) |
| Subtracts a double from this rationalg. | |
| rationalg< T > & | operator*= (double rhs) |
| Multiplies this rationalg by a double. | |
| rationalg< T > & | operator/= (double rhs) |
| Divides this rationalg by a double. | |
| rationalg< T > | operator+ (const rationalg< T > &rhs) const |
| Computes the sum of two rationalgs. | |
| rationalg< T > | operator- (const rationalg< T > &rhs) const |
| Computes the difference between two rationalgs. | |
| rationalg< T > | operator* (const rationalg< T > &rhs) const |
| Computes the product between two rationalgs. | |
| rationalg< T > | operator/ (const rationalg< T > &rhs) const |
| Computes the ratio between two rationalgs. | |
| rationalg< T > | operator+ (double rhs) const |
| Computes the sum of a rationalg and a double. | |
| rationalg< T > | operator- (double rhs) const |
| Computes the difference between a rationalg and a double. | |
| rationalg< T > | operator* (double rhs) const |
| Computes the product between a rationalg and a double. | |
| rationalg< T > | operator/ (double rhs) const |
| Computes the ratio between a rationalg and a double. | |
| rationalg< T > | operator- () const |
| Computes the opposite of this rationalg. | |
| Sign | sign () const |
| Gets the sign of a rationalg. | |
| Sign | compare (const rationalg< T > &rhs) const |
| Compares two rationalg. | |
| Sign | compare (double rhs) const |
| Compares a rationalg with a double. | |
| bool | operator> (const rationalg< T > &rhs) const |
| Compares this rationalg with another one. | |
| bool | operator>= (const rationalg< T > &rhs) const |
| Compares this rationalg with another one. | |
| bool | operator< (const rationalg< T > &rhs) const |
| Compares this rationalg with another one. | |
| bool | operator<= (const rationalg< T > &rhs) const |
| Compares this rationalg with another one. | |
| bool | operator> (double rhs) const |
| Compares this rationalg with another one. | |
| bool | operator>= (double rhs) const |
| Compares this rationalg with another one. | |
| bool | operator< (double rhs) const |
| Compares this rationalg with another one. | |
| bool | operator<= (double rhs) const |
| Compares this rationalg with another one. | |
| double | estimate () const |
| Computes an approximation of the stored value in this rational. | |
Protected Member Functions | |
| void | copy (const rationalg< T > &rhs) |
| Copies a rational into this one. | |
| bool | has_same_denom (const rationalg< T > &rhs) const |
| Tests whether a rationalg has trivially the same denominator this rationalg. | |
Related Symbols | |
(Note that these are not member symbols.) | |
| template<class T > | |
| rationalg< T > | operator+ (double a, const rationalg< T > &b) |
| Computes the sum of a double and a rationalg. | |
| template<class T > | |
| rationalg< T > | operator- (double a, const rationalg< T > &b) |
| Computes the difference between a double and a rationalg. | |
| template<class T > | |
| rationalg< T > | operator* (double a, const rationalg< T > &b) |
| Computes the product of a double and a rationalg. | |
| template<class T > | |
| rationalg< T > | operator/ (double a, const rationalg< T > &b) |
| Computes the ratio between a double and a rationalg. | |
| template<class T > | |
| bool | operator== (const rationalg< T > &a, const rationalg< T > &b) |
| Tests equality between two rationalgs. | |
| template<class T > | |
| bool | operator== (const rationalg< T > &a, double b) |
| Tests equality between a rationalg and a double. | |
| template<class T > | |
| bool | operator== (double a, const rationalg< T > &b) |
| Tests equality between a double and a rationalg. | |
| template<class T > | |
| bool | operator!= (const rationalg< T > &a, const rationalg< T > &b) |
| Tests whether two rationalgs differ. | |
| template<class T > | |
| bool | operator!= (const rationalg< T > &a, double b) |
| Tests whether a rationalg differs from a double. | |
| template<class T > | |
| bool | operator!= (double a, const rationalg< T > &b) |
| Tests whether a double differs from a rationalg. | |
rationalg (generic rational) is used to compute the sign of rational fractions exactly.
rationalg can be used like float and double. It supports four arithmetic operations (+,-,*,/), comparisons (>,>=,<,<=,==,!=) and exact sign computation.
Definition at line 60 of file rationalg.h.
| typedef T GEO::rationalg< T >::value_type |
Definition at line 62 of file rationalg.h.
|
inlineexplicit |
Constructs a new rationalg from a double.
| [in] | x | the value to initialize this rationalg. |
Definition at line 70 of file rationalg.h.
|
inlineexplicit |
Constructs a new rationalg from an T.
| [in] | x | the value to initialize this rationalg. |
Definition at line 77 of file rationalg.h.
|
inlineexplicit |
Constructs a new rationalg from an T with move semantics.
| [in] | x | the victim T |
Definition at line 85 of file rationalg.h.
|
inlineexplicit |
Constructs a new rationalg from two doubles.
| [in] | num | the numerator |
| [in] | denom | the denominator |
Definition at line 93 of file rationalg.h.
|
inlineexplicit |
Constructs a new rationalg from two T.
| [in] | num | the numerator |
| [in] | denom | the denominator |
Definition at line 102 of file rationalg.h.
|
inlineexplicit |
Constructs a new rationalg from two T with move semantics.
| [in] | num | the numerator |
| [in] | denom | the denominator |
Definition at line 112 of file rationalg.h.
|
default |
Copy-constructor.
| [in] | rhs | the rational to be copied |
|
default |
Move-constructor.
| [in] | rhs | the rational to be copied |
|
inline |
Compares two rationalg.
Definition at line 428 of file rationalg.h.
|
inline |
Compares a rationalg with a double.
Definition at line 445 of file rationalg.h.
|
inlineprotected |
Copies a rational into this one.
| [in] | rhs | a const reference to the rational to be copied |
Definition at line 555 of file rationalg.h.
|
inline |
gets the denominator.
Definition at line 171 of file rationalg.h.
|
inline |
gets the denominator.
Definition at line 155 of file rationalg.h.
|
inline |
Computes an approximation of the stored value in this rational.
Definition at line 546 of file rationalg.h.
|
inlineprotected |
Tests whether a rationalg has trivially the same denominator this rationalg.
This function is used to implement faster addition, subtraction and tests when it can be quickly determined that both operands have the same denominator.
| true | if it is trivial that rhs has the same denominator as this rationalg. |
| false | otherwise. |
Definition at line 570 of file rationalg.h.
|
inline |
gets the numerator.
Definition at line 163 of file rationalg.h.
|
inline |
gets the numerator.
Definition at line 147 of file rationalg.h.
|
inline |
Computes the product between two rationalgs.
| [in] | rhs | the rationalg to be multiplied by this rationalg |
rhs Definition at line 329 of file rationalg.h.
|
inline |
Computes the product between a rationalg and a double.
| [in] | rhs | the double to be multiplied by this rationalg |
rhs Definition at line 379 of file rationalg.h.
|
inline |
Multiplies this rationalg by a rationalg.
| [in] | rhs | the rationalg to multiply this rationalg by |
Definition at line 221 of file rationalg.h.
|
inline |
Multiplies this rationalg by a double.
If the double is a constant (possibly negative) power of two (e.g. 0.125, 0.5, 2.0, 4.0 ...), one may use num().scale_fast() / denom().scale_fast() instead.
| [in] | rhs | the double to multiply this rationalg with |
Definition at line 266 of file rationalg.h.
|
inline |
Computes the sum of two rationalgs.
| [in] | rhs | the rationalg to be added to this rationalg |
rhs Definition at line 291 of file rationalg.h.
|
inline |
Computes the sum of a rationalg and a double.
| [in] | rhs | the double to be added to this rationalg |
rhs Definition at line 355 of file rationalg.h.
|
inline |
Adds a rationalg to this rationalg.
| [in] | rhs | the rationalg to be added to this rationalg |
Definition at line 191 of file rationalg.h.
|
inline |
Adds a double to this rationalg.
| [in] | rhs | the double to be added to this rationalg |
Definition at line 243 of file rationalg.h.
|
inline |
Computes the opposite of this rationalg.
Definition at line 404 of file rationalg.h.
|
inline |
Computes the difference between two rationalgs.
| [in] | rhs | the rationalg to be subtracted from this rationalg |
rhs Definition at line 310 of file rationalg.h.
|
inline |
Computes the difference between a rationalg and a double.
| [in] | rhs | the double to be subtracted from this rationalg |
rhs Definition at line 367 of file rationalg.h.
|
inline |
Subtracts a rationalg to this rationalg.
| [in] | rhs | the rationalg to be subtracted |
Definition at line 206 of file rationalg.h.
|
inline |
Subtracts a double from this rationalg.
| [in] | rhs | the double to be subtracted from this rationalg |
Definition at line 253 of file rationalg.h.
|
inline |
Computes the ratio between two rationalgs.
| [in] | rhs | the rationalg to be multiplied by this rationalg |
rhs Definition at line 342 of file rationalg.h.
|
inline |
Computes the ratio between a rationalg and a double.
| [in] | rhs | the double to be multiplied by this rationalg |
rhs Definition at line 391 of file rationalg.h.
|
inline |
Divides this rationalg by a rationalg.
| [in] | rhs | the rationalg to divide this rationalg by |
Definition at line 232 of file rationalg.h.
|
inline |
Divides this rationalg by a double.
If the double is a constant (possibly negative) power of two (e.g. 0.125, 0.5, 2.0, 4.0 ...), one may use num().scale_fast() / denom().scale_fast() instead.
| [in] | rhs | the double to multiply this rationalg with |
Definition at line 279 of file rationalg.h.
|
inline |
Compares this rationalg with another one.
Internally computes the sign of the difference between this rationalg and rhs.
rhs, false otherwise Definition at line 480 of file rationalg.h.
|
inline |
Compares this rationalg with another one.
Internally computes the sign of the difference between this rationalg and rhs.
rhs, false otherwise Definition at line 524 of file rationalg.h.
|
inline |
Compares this rationalg with another one.
Internally computes the sign of the difference between this rationalg and rhs.
rhs, false otherwise Definition at line 491 of file rationalg.h.
|
inline |
Compares this rationalg with another one.
Internally computes the sign of the difference between this rationalg and rhs.
rhs, false otherwise Definition at line 535 of file rationalg.h.
|
default |
Assignment operator.
| [in] | rhs | the rational to be copied |
|
default |
Assignment operator with move semantics.
| [in] | rhs | the victim rationalg |
|
inline |
Compares this rationalg with another one.
Internally computes the sign of the difference between this rationalg and rhs.
rhs, false otherwise Definition at line 458 of file rationalg.h.
|
inline |
Compares this rationalg with another one.
Internally computes the sign of the difference between this rationalg and rhs.
rhs, false otherwise Definition at line 502 of file rationalg.h.
|
inline |
Compares this rationalg with another one.
Internally computes the sign of the difference between this rationalg and rhs.
rhs, false otherwise Definition at line 469 of file rationalg.h.
|
inline |
Compares this rationalg with another one.
Internally computes the sign of the difference between this rationalg and rhs.
rhs, false otherwise Definition at line 513 of file rationalg.h.
|
inline |
Optimizes the internal representation without changing the represented value.
Definition at line 179 of file rationalg.h.
|
inline |
Gets the sign of a rationalg.
Definition at line 417 of file rationalg.h.
Tests whether two rationalgs differ.
Implemented by testing whether the difference between a and b is different from 0.
a and b do not represent the same exact value, false otherwise Definition at line 682 of file rationalg.h.
Tests whether a rationalg differs from a double.
Implemented by testing whether the difference between a and b is different from 0.
a and b do not represent the same exact value, false otherwise Definition at line 695 of file rationalg.h.
Tests whether a double differs from a rationalg.
Implemented by testing whether the difference between a and b is different from 0.
a and b do not represent the same exact value, false otherwise Definition at line 708 of file rationalg.h.
Computes the product of a double and a rationalg.
| [in] | a | the double |
| [in] | b | the rationalg to be multiplied |
a * b Definition at line 615 of file rationalg.h.
Computes the sum of a double and a rationalg.
| [in] | a | the double to be added |
| [in] | b | the rationalg to be added |
a + b Definition at line 589 of file rationalg.h.
Computes the difference between a double and a rationalg.
| [in] | a | the double |
| [in] | b | the rationalg to be subtracted |
a - b Definition at line 601 of file rationalg.h.
Computes the ratio between a double and a rationalg.
| [in] | a | the double |
| [in] | b | the rationalg to be divided |
a / b Definition at line 627 of file rationalg.h.
Tests equality between two rationalgs.
Implemented by testing whether the difference between a and b is 0.
a and b represent exactly the same value, false otherwise Definition at line 643 of file rationalg.h.
Tests equality between a rationalg and a double.
Implemented by testing whether the difference between a and b is 0.
a and b represent exactly the same value, false otherwise Definition at line 656 of file rationalg.h.
Tests equality between a double and a rationalg.
Implemented by testing whether the difference between a and b is 0.
a and b represent exactly the same value, false otherwise Definition at line 669 of file rationalg.h.