Geogram
Version 1.9.1-rc
A programming library of geometric algorithms
|
Expansion_nt (expansion Number Type) is used to compute the sign of polynoms exactly. More...
#include <geogram/numerics/expansion_nt.h>
Public Types | |
enum | Operation { SUM , DIFF , PRODUCT } |
This type is used by the constructor that takes two expansions. | |
Public Member Functions | |
expansion_nt () | |
Constructs an uninitialized expansion_nt. | |
expansion_nt (double x) | |
Constructs a new expansion_nt from a double. More... | |
expansion_nt (const expansion &rhs) | |
Constructs a new expansion_nt from an expansion. More... | |
expansion_nt (Operation op, const expansion &x, const expansion &y) | |
Constructs a new expansion_nt from two expansions. More... | |
expansion_nt (Operation op, const expansion &x, const expansion &y, const expansion &z) | |
Constructs a new expansion_nt from three expansions. More... | |
expansion_nt (Operation op, const expansion &x, const expansion &y, const expansion &z, const expansion &t) | |
Constructs a new expansion_nt from four expansions. More... | |
expansion_nt (Operation op, double x, double y) | |
Constructs a new expansion_nt from two doubles. More... | |
expansion_nt (const expansion_nt &rhs) | |
Copy-constructor. More... | |
expansion_nt (expansion_nt &&rhs) | |
Move-constructor. More... | |
expansion_nt & | operator= (const expansion_nt &rhs) |
Assignment operator. More... | |
expansion_nt & | operator= (expansion_nt &&rhs) |
Assignment operator with move semantics. More... | |
~expansion_nt () | |
Expansion_nt destructor. More... | |
void | optimize () |
Optimizes the internal representation without changing the represented value. More... | |
void | negate () |
Flips the sign of an expansion. | |
expansion_nt & | operator+= (const expansion_nt &rhs) |
Adds an expansion_nt to this expansion_nt. More... | |
expansion_nt & | operator-= (const expansion_nt &rhs) |
Subtracts an expansion_nt to this expansion_nt. More... | |
expansion_nt & | operator*= (const expansion_nt &rhs) |
Multiplies this expansion_nt by an expansion_nt. More... | |
expansion_nt & | operator+= (double rhs) |
Adds a double to this expansion_nt. More... | |
expansion_nt & | operator-= (double rhs) |
Subtracts a double from this expansion_nt. More... | |
expansion_nt & | operator*= (double rhs) |
Multiplies this expansion_nt by a double. More... | |
expansion_nt | operator+ (const expansion_nt &rhs) const |
Computes the sum of two expansion_nts. More... | |
expansion_nt | operator- (const expansion_nt &rhs) const |
Computes the difference between two expansion_nts. More... | |
expansion_nt | operator* (const expansion_nt &rhs) const |
Computes the product between two expansion_nts. More... | |
expansion_nt | operator+ (double rhs) const |
Computes the sum of an expansion_nt and a double. More... | |
expansion_nt | operator- (double rhs) const |
Computes the difference between an expansion_nt and a double. More... | |
expansion_nt | operator* (double rhs) const |
Computes the product between an expansion_nt and a double. More... | |
expansion_nt | operator- () const |
Computes the opposite of this expansion_nt. More... | |
Sign | compare (const expansion_nt &rhs) const |
Compares two expansion_nt. More... | |
Sign | compare (double rhs) const |
Compares an expansion_nt with a double. More... | |
bool | operator> (const expansion_nt &rhs) const |
Compares this expansion_nt with another one. More... | |
bool | operator>= (const expansion_nt &rhs) const |
Compares this expansion_nt with another one. More... | |
bool | operator< (const expansion_nt &rhs) const |
Compares this expansion_nt with another one. More... | |
bool | operator<= (const expansion_nt &rhs) const |
Compares this expansion_nt with another one. More... | |
bool | operator> (double rhs) const |
Compares this expansion_nt with another one. More... | |
bool | operator>= (double rhs) const |
Compares this expansion_nt with another one. More... | |
bool | operator< (double rhs) const |
Compares this expansion_nt with another one. More... | |
bool | operator<= (double rhs) const |
Compares this expansion_nt with another one. More... | |
double | estimate () const |
Computes an approximation of the stored value in this expansion. More... | |
Sign | sign () const |
Gets the sign of this expansion_nt. More... | |
index_t | length () const |
Gets the length of this expansion. More... | |
double | component (index_t i) const |
Gets the i-th component of this expansion. More... | |
expansion_nt (expansion *rep) | |
Constructs a new expansion_nt from an expansion. More... | |
expansion & | rep () |
Gets the internal expansion that represents this expansion_nt. More... | |
const expansion & | rep () const |
Gets the internal expansion that represents this expansion_nt. More... | |
std::string | to_string () const |
Gets a string representation of this expansion. More... | |
Protected Member Functions | |
void | copy (const expansion_nt &rhs) |
Copies an expansion into this one. More... | |
void | cleanup () |
Cleanups the memory associated with this expansion_nt. | |
Friends | |
expansion_nt | operator- (double a, const expansion_nt &b) |
expansion_nt | expansion_nt_sq_dist (const double *a, const double *b, coord_index_t dim) |
expansion_nt | expansion_nt_dot_at (const double *a, const double *b, const double *c, coord_index_t dim) |
Related Functions | |
(Note that these are not member functions.) | |
expansion_nt | operator+ (double a, const expansion_nt &b) |
Computes the sum of a double and an expansion_nt. More... | |
expansion_nt | operator- (double a, const expansion_nt &b) |
Computes the difference between a double and an expansion_nt. More... | |
expansion_nt | operator* (double a, const expansion_nt &b) |
Computes the product of a double and an expansion_nt. More... | |
bool | operator== (const expansion_nt &a, const expansion_nt &b) |
Tests equality between two expansion_nts. More... | |
bool | operator== (const expansion_nt &a, double b) |
Tests equality between an expansion_nt and a double. More... | |
bool | operator== (double a, const expansion_nt &b) |
Tests equality between a double and an expansion_nt. More... | |
bool | operator!= (const expansion_nt &a, const expansion_nt &b) |
Tests whether two expansion_nts differ. More... | |
bool | operator!= (const expansion_nt &a, double b) |
Tests whether an expansion_nt differs from a double. More... | |
bool | operator!= (double a, const expansion_nt &b) |
Tests whether a double differs from an expansion_nt. More... | |
expansion_nt | expansion_nt_sq_dist (const double *a, const double *b, coord_index_t dim) |
Computes an expansion that represents the square distance between two points. More... | |
expansion_nt | expansion_nt_dot_at (const double *a, const double *b, const double *c, coord_index_t dim) |
Computes an expansion that represents the dot product of two vectors determined by three points. More... | |
Expansion_nt (expansion Number Type) is used to compute the sign of polynoms exactly.
Expansion_nt can be used like float and double. It supports three arithmetic operations (+,-,*), comparisons (>,>=,<,<=,==,!=) and exact sign computation. expansion_nt is a wrapper around an expansion allocated on the heap. When performance is a concern, the lower-level expansion class may be used instead.
Definition at line 70 of file expansion_nt.h.
|
inlineexplicit |
Constructs a new expansion_nt from a double.
[in] | x | the value to initialize this expansion. |
Definition at line 91 of file expansion_nt.h.
|
inlineexplicit |
Constructs a new expansion_nt from an expansion.
A new expansion is created on the heap and its content is initialized from rhs
[in] | rhs | the expansion to be copied |
Definition at line 103 of file expansion_nt.h.
|
inlineexplicit |
Constructs a new expansion_nt from two expansions.
A new expansion is created on the heap and its content is initialized from x
op
y
. This function is used by code that combines the low-level API (expansion) with the high-level number type (expansion_nt). When returning the result of operations that combine expansion as an expansion_nt, it makes it possible to avoid copying the result of the last operation by directly assigning it to an expansion_nt.
[in] | x,y | the two operands |
[in] | op | one of expansion_nt::SUM, expansion_nt::DIFF, expansion_nt::PRODUCT |
Definition at line 121 of file expansion_nt.h.
|
inlineexplicit |
Constructs a new expansion_nt from three expansions.
A new expansion is created on the heap and its content is initialized from x
op
y
op
z
. This function is used by code that combines the low-level API (expansion) with the high-level number type (expansion_nt). When returning the result of operations that combine expansion as an expansion_nt, it makes it possible to avoid copying the result of the last operation by directly assigning it to an expansion_nt.
[in] | x,y,z | the three operands |
[in] | op | one of expansion_nt::SUM, expansion_nt::PRODUCT |
Definition at line 159 of file expansion_nt.h.
|
inlineexplicit |
Constructs a new expansion_nt from four expansions.
A new expansion is created on the heap and its content is initialized from x
op
y
op
z
op
t
. This function is used by code that combines the low-level API (expansion) with the high-level number type (expansion_nt). When returning the result of operations that combine expansion as an expansion_nt, it makes it possible to avoid copying the result of the last operation by directly assigning it to an expansion_nt.
[in] | x,y,z,t | the four operands |
[in] | op | one of expansion_nt::SUM, expansion_nt::PRODUCT |
Definition at line 195 of file expansion_nt.h.
|
inlineexplicit |
Constructs a new expansion_nt from two doubles.
A new expansion is created on the heap and its content is initialized from x
op
y
. This function is used by code that combines the low-level API (expansion) with the high-level number type (expansion_nt). When returning the result of operations that combine expansion as an expansion_nt, it makes it possible to avoid copying the result of the last operation by directly assigning it to an expansion_nt.
[in] | x,y | the two operands |
[in] | op | one of expansion_nt::SUM, expansion_nt::DIFF, expansion_nt::PRODUCT |
Definition at line 235 of file expansion_nt.h.
|
inline |
Copy-constructor.
[in] | rhs | the expansion to be copied |
Definition at line 262 of file expansion_nt.h.
|
inline |
Move-constructor.
Steals the expansion from rhs
[in] | rhs | the victim expansion_nt |
Definition at line 271 of file expansion_nt.h.
|
inline |
Expansion_nt destructor.
The stored expansion is deallocated whenever reference counting reaches 0.
Definition at line 307 of file expansion_nt.h.
|
inline |
Constructs a new expansion_nt from an expansion.
Used internally
[in] | rep | should be a reference-counted expansion, created by new_expansion_on_heap(). Its reference counter is incremented. |
Definition at line 585 of file expansion_nt.h.
|
inline |
Compares two expansion_nt.
Definition at line 434 of file expansion_nt.h.
|
inline |
Compares an expansion_nt with a double.
Definition at line 442 of file expansion_nt.h.
|
inline |
Gets the i-th component of this expansion.
i | index of the component |
Definition at line 572 of file expansion_nt.h.
|
inlineprotected |
Copies an expansion into this one.
current rep_ pointer is supposed to be uninitialized or freed before calling this function.
[in] | rhs | a const reference to the expansion to be copied |
Definition at line 632 of file expansion_nt.h.
|
inline |
Computes an approximation of the stored value in this expansion.
Definition at line 541 of file expansion_nt.h.
|
inline |
Gets the length of this expansion.
Definition at line 560 of file expansion_nt.h.
expansion_nt GEO::expansion_nt::operator* | ( | const expansion_nt & | rhs | ) | const |
Computes the product between two expansion_nts.
[in] | rhs | the expansion_nt to be multiplied by this expansion_nt |
rhs
expansion_nt GEO::expansion_nt::operator* | ( | double | rhs | ) | const |
Computes the product between an expansion_nt and a double.
[in] | rhs | the double to be multiplied by this expansion_nt |
rhs
expansion_nt& GEO::expansion_nt::operator*= | ( | const expansion_nt & | rhs | ) |
Multiplies this expansion_nt by an expansion_nt.
[in] | rhs | the expansion_nt to multiply this expansion_nt by |
expansion_nt& GEO::expansion_nt::operator*= | ( | double | rhs | ) |
Multiplies this expansion_nt 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 scale_fast() instead.
[in] | rhs | the double to multiply this expansion_nt with |
expansion_nt GEO::expansion_nt::operator+ | ( | const expansion_nt & | rhs | ) | const |
Computes the sum of two expansion_nts.
[in] | rhs | the expansion_nt to be added to this expansion_nt |
rhs
expansion_nt GEO::expansion_nt::operator+ | ( | double | rhs | ) | const |
Computes the sum of an expansion_nt and a double.
[in] | rhs | the double to be added to this expansion_nt |
rhs
expansion_nt& GEO::expansion_nt::operator+= | ( | const expansion_nt & | rhs | ) |
Adds an expansion_nt to this expansion_nt.
[in] | rhs | the expansion_nt to be added to this expansion_nt |
expansion_nt& GEO::expansion_nt::operator+= | ( | double | rhs | ) |
Adds a double to this expansion_nt.
[in] | rhs | the double to be added to this expansion_nt |
expansion_nt GEO::expansion_nt::operator- | ( | ) | const |
Computes the opposite of this expansion_nt.
expansion_nt GEO::expansion_nt::operator- | ( | const expansion_nt & | rhs | ) | const |
Computes the difference between two expansion_nts.
[in] | rhs | the expansion_nt to be subtracted from this expansion_nt |
rhs
expansion_nt GEO::expansion_nt::operator- | ( | double | rhs | ) | const |
Computes the difference between an expansion_nt and a double.
[in] | rhs | the double to be subtracted from this expansion_nt |
rhs
expansion_nt& GEO::expansion_nt::operator-= | ( | const expansion_nt & | rhs | ) |
Subtracts an expansion_nt to this expansion_nt.
[in] | rhs | the expansion_nt to be subtracted |
expansion_nt& GEO::expansion_nt::operator-= | ( | double | rhs | ) |
Subtracts a double from this expansion_nt.
[in] | rhs | the double to be subtracted from this expansion_nt |
|
inline |
Compares this expansion_nt with another one.
Internally computes the sign of the difference between this expansion_nt and rhs
.
rhs
, false otherwise Definition at line 475 of file expansion_nt.h.
|
inline |
Compares this expansion_nt with another one.
Internally computes the sign of the difference between this expansion_nt and rhs
.
rhs
, false otherwise Definition at line 519 of file expansion_nt.h.
|
inline |
Compares this expansion_nt with another one.
Internally computes the sign of the difference between this expansion_nt and rhs
.
rhs
, false otherwise Definition at line 486 of file expansion_nt.h.
|
inline |
Compares this expansion_nt with another one.
Internally computes the sign of the difference between this expansion_nt and rhs
.
rhs
, false otherwise Definition at line 530 of file expansion_nt.h.
|
inline |
Assignment operator.
[in] | rhs | the expansion to be copied |
Definition at line 281 of file expansion_nt.h.
|
inline |
Assignment operator with move semantics.
[in] | rhs | the expansion to be copied |
Definition at line 294 of file expansion_nt.h.
|
inline |
Compares this expansion_nt with another one.
Internally computes the sign of the difference between this expansion_nt and rhs
.
rhs
, false otherwise Definition at line 453 of file expansion_nt.h.
|
inline |
Compares this expansion_nt with another one.
Internally computes the sign of the difference between this expansion_nt and rhs
.
rhs
, false otherwise Definition at line 497 of file expansion_nt.h.
|
inline |
Compares this expansion_nt with another one.
Internally computes the sign of the difference between this expansion_nt and rhs
.
rhs
, false otherwise Definition at line 464 of file expansion_nt.h.
|
inline |
Compares this expansion_nt with another one.
Internally computes the sign of the difference between this expansion_nt and rhs
.
rhs
, false otherwise Definition at line 508 of file expansion_nt.h.
|
inline |
Optimizes the internal representation without changing the represented value.
this function can reduce the length of an expansion
Definition at line 316 of file expansion_nt.h.
|
inline |
Gets the internal expansion that represents this expansion_nt.
Definition at line 597 of file expansion_nt.h.
|
inline |
Gets the internal expansion that represents this expansion_nt.
Definition at line 609 of file expansion_nt.h.
|
inline |
Gets the sign of this expansion_nt.
Definition at line 549 of file expansion_nt.h.
|
inline |
Gets a string representation of this expansion.
Definition at line 618 of file expansion_nt.h.
|
related |
Computes an expansion that represents the dot product of two vectors determined by three points.
[in] | a | an array of dim doubles |
[in] | b | an array of dim doubles |
[in] | c | an array of dim doubles |
[in] | dim | the dimension of the points |
a
- c
).(b
- c
) Definition at line 807 of file expansion_nt.h.
|
related |
Computes an expansion that represents the square distance between two points.
[in] | a | an array of dim doubles |
[in] | b | an array of dim doubles |
[in] | dim | the dimension of the points |
a
and b
Definition at line 786 of file expansion_nt.h.
|
related |
Tests whether two expansion_nts 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 748 of file expansion_nt.h.
|
related |
Tests whether an expansion_nt 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 760 of file expansion_nt.h.
|
related |
Tests whether a double differs from an expansion_nt.
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 772 of file expansion_nt.h.
|
related |
Computes the product of a double and an expansion_nt.
[in] | a | the double |
[in] | b | the expansion_nt to be multiplied |
a
* b
Definition at line 700 of file expansion_nt.h.
|
related |
Computes the sum of a double and an expansion_nt.
[in] | a | the double to be added |
[in] | b | the expansion_nt to be added |
a
+ b
Definition at line 676 of file expansion_nt.h.
|
related |
Computes the difference between a double and an expansion_nt.
[in] | a | the double |
[in] | b | the expansion_nt to be subtracted |
a
- b
Definition at line 687 of file expansion_nt.h.
|
related |
Tests equality between two expansion_nts.
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 712 of file expansion_nt.h.
|
related |
Tests equality between an expansion_nt 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 724 of file expansion_nt.h.
|
related |
Tests equality between a double and an expansion_nt.
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 736 of file expansion_nt.h.