40#ifndef GEOGRAM_NUMERICS_EXPANSION_NT 
   41#define GEOGRAM_NUMERICS_EXPANSION_NT 
   92        rep_ = expansion::new_expansion_on_heap(1);
 
 
  104        rep_ = expansion::new_expansion_on_heap(rhs.
length());
 
 
  126            rep_ = expansion::new_expansion_on_heap(
 
  127                expansion::sum_capacity(x,y)
 
  129            rep_->assign_sum(x,y);
 
  132            rep_ = expansion::new_expansion_on_heap(
 
  133                expansion::diff_capacity(x,y)
 
  135            rep_->assign_diff(x,y);
 
  138            rep_ = expansion::new_expansion_on_heap(
 
  139                expansion::product_capacity(x,y)
 
  141            rep_->assign_product(x,y);
 
 
  165            rep_ = expansion::new_expansion_on_heap(
 
  166                expansion::sum_capacity(x,y,z)
 
  168            rep_->assign_sum(x,y,z);
 
  174            rep_ = expansion::new_expansion_on_heap(
 
  175                expansion::product_capacity(x,y,z)
 
  177            rep_->assign_product(x,y,z);
 
 
  202            rep_ = expansion::new_expansion_on_heap(
 
  203                expansion::sum_capacity(x,y,z,t)
 
  205            rep_->assign_sum(x,y,z,t);
 
  212            const expansion& p1 = expansion_product(x,y);
 
  213            const expansion& p2 = expansion_product(z,t);
 
  214            rep_ = expansion::new_expansion_on_heap(
 
  215                expansion::product_capacity(p1,p2)
 
  217            rep_->assign_sum(p1,p2);
 
 
  238            rep_ = expansion::new_expansion_on_heap(
 
  239                expansion::sum_capacity(x,y)
 
  241            rep_->assign_sum(x,y);
 
  244            rep_ = expansion::new_expansion_on_heap(
 
  245                expansion::diff_capacity(x,y)
 
  247            rep_->assign_diff(x,y);
 
  250            rep_ = expansion::new_expansion_on_heap(
 
  251                expansion::product_capacity(x,y)
 
  253            rep_->assign_product(x,y);
 
 
  273        std::swap(rep_, rhs.rep_);
 
 
  297            std::swap(rep_, rhs.rep_);
 
 
  435        return rep().compare(rhs.
rep());
 
 
  443        return rep().compare(rhs);
 
 
  454        return (
int(compare(rhs))>0);
 
 
  465        return (
int(compare(rhs))>=0);
 
 
  476        return (
int(compare(rhs))<0);
 
 
  487        return (
int(compare(rhs))<=0);
 
 
  497    bool operator> (
double rhs)
 const {
 
  498        return (
int(compare(rhs))>0);
 
 
  508    bool operator>= (
double rhs)
 const {
 
  509        return (
int(compare(rhs))>=0);
 
 
  519    bool operator< (
double rhs)
 const {
 
  520        return (
int(compare(rhs))<0);
 
 
  530    bool operator<= (
double rhs)
 const {
 
  531        return (
int(compare(rhs))<=0);
 
 
  542        return rep().estimate();
 
 
  561        return rep().length();
 
 
  619        return (rep_ == 
nullptr) ?
 
  620            std::string(
"null") :
 
 
  633        if(rhs.rep_ == 
nullptr) {
 
  636            rep_ = expansion::new_expansion_on_heap(rhs.
rep().
capacity());
 
  638            for(
index_t i=0; i<rep_->length(); ++i) {
 
  639                (*rep_)[i] = rhs.
rep()[i];
 
 
  648        if(rep_ != 
nullptr) {
 
  649            expansion::delete_expansion_on_heap(rep_);
 
 
  663        const double* a, 
const double* b, 
const double* c,
 
 
  808        const double* a, 
const double* b, 
const double* c, 
coord_index_t dim
 
 
  939#ifdef GEO_HAS_BIG_STACK 
  961    template <> 
inline expansion_nt 
det3x3(
 
  962        const expansion_nt& a11, 
const expansion_nt& a12,
 
  963        const expansion_nt& a13,
 
  964        const expansion_nt& a21, 
const expansion_nt& a22,
 
  965        const expansion_nt& a23,
 
  966        const expansion_nt& a31, 
const expansion_nt& a32,
 
  967        const expansion_nt& a33
 
  981    template <> 
inline expansion_nt 
det4x4(
 
  982        const expansion_nt& a11, 
const expansion_nt& a12,
 
  983        const expansion_nt& a13, 
const expansion_nt& a14,
 
  984        const expansion_nt& a21, 
const expansion_nt& a22,
 
  985        const expansion_nt& a23, 
const expansion_nt& a24,
 
  986        const expansion_nt& a31, 
const expansion_nt& a32,
 
  987        const expansion_nt& a33, 
const expansion_nt& a34,
 
  988        const expansion_nt& a41, 
const expansion_nt& a42,
 
  989        const expansion_nt& a43, 
const expansion_nt& a44
 
#define geo_assert_not_reached
Sets a non reachable point in the program.
#define geo_debug_assert(x)
Verifies that a condition is met.
Expansion_nt (expansion Number Type) is used to compute the sign of polynoms exactly.
const expansion & rep() const
Gets the internal expansion that represents this expansion_nt.
double estimate() const
Computes an approximation of the stored value in this expansion.
void copy(const expansion_nt &rhs)
Copies an expansion into this one.
Sign sign() const
Gets the sign of this expansion_nt.
expansion & rep()
Gets the internal expansion that represents this expansion_nt.
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.
double component(index_t i) const
Gets the i-th component of this expansion.
~expansion_nt()
Expansion_nt destructor.
std::string to_string() const
Gets a string representation of this expansion.
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.
expansion_nt(expansion_nt &&rhs)
Move-constructor.
expansion_nt(Operation op, const expansion &x, const expansion &y, const expansion &z)
Constructs a new expansion_nt from three expansions.
expansion_nt()
Constructs an uninitialized expansion_nt.
expansion_nt(const expansion &rhs)
Constructs a new expansion_nt from an expansion.
void cleanup()
Cleanups the memory associated with this expansion_nt.
index_t length() const
Gets the length of this expansion.
void optimize()
Optimizes the internal representation without changing the represented value.
expansion_nt(Operation op, const expansion &x, const expansion &y)
Constructs a new expansion_nt from two expansions.
Sign compare(const expansion_nt &rhs) const
Compares two expansion_nt.
expansion_nt(expansion *rep)
Constructs a new expansion_nt from an expansion.
expansion_nt(Operation op, double x, double y)
Constructs a new expansion_nt from two doubles.
expansion_nt(Operation op, const expansion &x, const expansion &y, const expansion &z, const expansion &t)
Constructs a new expansion_nt from four expansions.
Operation
This type is used by the constructor that takes two expansions.
expansion_nt(const expansion_nt &rhs)
Copy-constructor.
Sign compare(double rhs) const
Compares an expansion_nt with a double.
void negate()
Flips the sign of an expansion.
expansion_nt(double x)
Constructs a new expansion_nt from a double.
Represents numbers in arbitrary precision with a low-level API.
index_t length() const
Gets the length of this expansion.
bool equals(const expansion &rhs) const
Compares two expansions.
index_t capacity() const
Gets the capacity of this expansion.
expansion & assign_dot_at(const double *p1, const double *p2, const double *p0, coord_index_t dim)
Assigns the dot product of two vectors to this expansion (should not be used by client code).
static index_t sq_dist_capacity(coord_index_t dim)
Computes the required capacity of an expansion to store the exact squared distance between two points...
expansion & negate()
Changes the sign of an expansion.
static index_t square_capacity(double a)
Computes the required capacity of an expansion to store the exact square of a double.
static index_t dot_at_capacity(coord_index_t dim)
Computes the required capacity of an expansion to store the exact dot product between two vectors.
static expansion * new_expansion_on_heap(index_t capa)
Allocates an expansion on the heap.
expansion & assign_square(double a)
Assigns the square of a double to this expansion (should not be used by client code).
expansion & assign_sq_dist(const double *p1, const double *p2, coord_index_t dim)
Assigns the squared distance between two points to this expansion (should not be used by client code)...
Sign sign() const
Gets the sign of the expansion.
rationalg (generic rational) is used to compute the sign of rational fractions exactly.
std::ostream & operator<<(std::ostream &os, const GEO::expansion_nt &a)
Displays the approximated value of an expansion_nt to a stream.
std::istream & operator>>(std::istream &is, GEO::expansion_nt &a)
Reads a double precision number from a stream and converts it to an approximation.
Common include file, providing basic definitions. Should be included before anything else by all head...
Implementation of multi-precision arithmetics.
Sign ratio_compare(const T &a_num, const T &a_denom, const T &b_num, const T &b_denom)
Compares two rational numbers given as separate numerators and denominators.
void optimize_number_representation(T &x)
place holder for optimizing internal number representation
Global Vorpaline namespace.
bool expansion_nt_is_zero(const expansion_nt &x)
Tests whether an expansion_nt is zero.
Quaternion operator-(const Quaternion &a, const Quaternion &b)
Computes the difference between two Quaternion.
expansion_nt expansion_nt_determinant(const expansion_nt &a00, const expansion_nt &a01, const expansion_nt &a10, const expansion_nt &a11)
Computes a 2x2 determinant.
T det3x3(const T &a11, const T &a12, const T &a13, const T &a21, const T &a22, const T &a23, const T &a31, const T &a32, const T &a33)
Computes a three-by-three determinant.
T det4x4(const T &a11, const T &a12, const T &a13, const T &a14, const T &a21, const T &a22, const T &a23, const T &a24, const T &a31, const T &a32, const T &a33, const T &a34, const T &a41, const T &a42, const T &a43, const T &a44)
Computes a four-by-four determinant.
Sign geo_sgn(const T &x)
Gets the sign of a value.
expansion_nt expansion_nt_square(const expansion_nt &x)
Computes the square of an expansion_nt.
geo_index_t index_t
The type for storing and manipulating indices.
Sign expansion_nt_compare(const expansion_nt &x, const expansion_nt &y)
Compares two expansion_nt.
Sign
Integer constants that represent the sign of a value.
T det2x2(const T &a11, const T &a12, const T &a21, const T &a22)
Computes a two-by-two determinant.
Sign geo_cmp(const T &a, const T &b)
Compares two values.
bool expansion_nt_is_one(const expansion_nt &x)
Tests whether an expansion_nt is equal to one.
Quaternion operator+(const Quaternion &a, const Quaternion &b)
Computes the sum of two Quaternion.
geo_coord_index_t coord_index_t
The type for storing coordinate indices, and iterating on the coordinates of a point.
Generic implementation of rational type.