From f5367709ad0f8a86a0e796f0b327d38e7747fc60 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 7 Oct 2021 17:29:09 +0100 Subject: [PATCH 001/139] Use boost::multiprecision::number API (WIP) --- .../CGAL/Test/_test_algebraic_structure.h | 3 + CGAL_Core/include/CGAL/CORE/BigFloat.h | 7 + CGAL_Core/include/CGAL/CORE/BigInt.h | 294 +++++++++++------- CGAL_Core/include/CGAL/CORE/BigRat.h | 246 +++++++-------- CGAL_Core/include/CGAL/CORE/CoreIO_impl.h | 12 + CGAL_Core/include/CGAL/CORE/Expr_impl.h | 4 +- Number_types/include/CGAL/CORE_BigInt.h | 4 +- 7 files changed, 328 insertions(+), 242 deletions(-) diff --git a/Algebraic_foundations/include/CGAL/Test/_test_algebraic_structure.h b/Algebraic_foundations/include/CGAL/Test/_test_algebraic_structure.h index 5abb39fff255..4b1cad10d07f 100644 --- a/Algebraic_foundations/include/CGAL/Test/_test_algebraic_structure.h +++ b/Algebraic_foundations/include/CGAL/Test/_test_algebraic_structure.h @@ -736,6 +736,7 @@ void test_Type_functions( const CGAL::Euclidean_ring_tag&) { b = AS(5); r = CGAL_NTS mod(a,b); q = CGAL_NTS div(a,b); + std::cout << r << std::endl << q << std::endl; assert( a == b*q+r); CGAL_NTS div_mod(a,b,q,r); assert( a == b*q+r); @@ -876,7 +877,9 @@ void test_algebraic_structure(){ c = b * AS (-3); assert( c == AS (-15)); c = a; + c += b; + assert( c == AS (6)); c = a; c -= b; diff --git a/CGAL_Core/include/CGAL/CORE/BigFloat.h b/CGAL_Core/include/CGAL/CORE/BigFloat.h index 97183f63e508..176de0b19971 100644 --- a/CGAL_Core/include/CGAL/CORE/BigFloat.h +++ b/CGAL_Core/include/CGAL/CORE/BigFloat.h @@ -69,6 +69,7 @@ class CGAL_CORE_EXPORT BigFloat : public RCBigFloat { : RCBigFloat(new BigFloatRep(i)) {} BigFloat(long& x, const extLong& /*r*/, const extLong& /*a*/) : RCBigFloat(new BigFloatRep(x)) {} + /// constructor from BigInt, error and exponent values BigFloat(const BigInt& I, unsigned long er, long ex) : RCBigFloat(new BigFloatRep(I, er, ex)) {} @@ -77,6 +78,7 @@ class CGAL_CORE_EXPORT BigFloat : public RCBigFloat { : RCBigFloat(new BigFloatRep(I, ex)) {} BigFloat(const BigInt& I) : RCBigFloat(new BigFloatRep(I)) {} + /// constructor for BigRat BigFloat(const BigRat& R, const extLong& r = get_static_defRelPrec(), const extLong& a = get_static_defAbsPrec()) @@ -214,10 +216,12 @@ class CGAL_CORE_EXPORT BigFloat : public RCBigFloat { double doubleValue() const { return rep->toDouble(); } + /// return BigInt value BigInt BigIntValue() const { return rep->toBigInt(); } + /// return BigRat value BigRat BigRatValue() const { return rep->BigRatize(); @@ -262,6 +266,7 @@ class CGAL_CORE_EXPORT BigFloat : public RCBigFloat { const BigInt& m() const { return rep->m; } + /// get error bits unsigned long err() const { return rep->err; @@ -359,10 +364,12 @@ class CGAL_CORE_EXPORT BigFloat : public RCBigFloat { /// \name Utility Functions //@{ /// approximate BigInt number + void approx(const BigInt& I, const extLong& r, const extLong& a) { makeCopy(); rep->trunc(I, r, a); } + /// approximate BigFloat number void approx(const BigFloat& B, const extLong& r, const extLong& a) { makeCopy(); diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 7b16a960ac33..5db2b9880cf0 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -24,6 +24,7 @@ #ifndef _CORE_BIGINT_H_ #define _CORE_BIGINT_H_ +#include #include #include #include @@ -31,79 +32,104 @@ namespace CORE { + typedef boost::multiprecision::cpp_int Z; -class BigIntRep : public RCRepImpl { + + + class BigIntRep : public RCRepImpl { public: - BigIntRep() { - mpz_init(mp); - } - // Note : should the copy-ctor be alloed at all ? [Sylvain Pion] - BigIntRep(const BigIntRep& z) : RCRepImpl() { - mpz_init_set(mp, z.mp); - } - BigIntRep(signed char c) { - mpz_init_set_si(mp, c); - } - BigIntRep(unsigned char c) { - mpz_init_set_ui(mp, c); - } - BigIntRep(signed int i) { - mpz_init_set_si(mp, i); - } - BigIntRep(unsigned int i) { - mpz_init_set_ui(mp, i); - } - BigIntRep(signed short int s) { - mpz_init_set_si(mp, s); - } - BigIntRep(unsigned short int s) { - mpz_init_set_ui(mp, s); - } - BigIntRep(signed long int l) { - mpz_init_set_si(mp, l); - } - BigIntRep(unsigned long int l) { - mpz_init_set_ui(mp, l); - } - BigIntRep(float f) { - mpz_init_set_d(mp, f); - } - BigIntRep(double d) { - mpz_init_set_d(mp, d); - } - BigIntRep(const char* s, int base=0) { - mpz_init_set_str(mp, s, base); - } - BigIntRep(const std::string& s, int base=0) { - mpz_init_set_str(mp, s.c_str(), base); - } - explicit BigIntRep(mpz_srcptr z) { - mpz_init_set(mp, z); - } + BigIntRep() + : mp() + {} + + + // Note : should the copy-ctor be allowed at all ? [Sylvain Pion] + BigIntRep(const BigIntRep& z) : RCRepImpl(), mp(z.mp) + {} + + BigIntRep(signed char c) + : mp(c) + {} + + BigIntRep(unsigned char c) + : mp(c) + {} + + BigIntRep(signed int i) + : mp(i) + {} + + BigIntRep(unsigned int i) + : mp(i) + {} + + + BigIntRep(signed short int s) + : mp(s) + {} + BigIntRep(unsigned short int s) + : mp(s) + {} + + BigIntRep(signed long int l) + : mp(l) + {} + + BigIntRep(unsigned long int l) + : mp(l) + {} + + BigIntRep(float f) + : mp(f) + {} + + BigIntRep(double d) + : mp(d) + {} + + BigIntRep(const char* s, int base=0) + : mp(s) + {} + + BigIntRep(const std::string& s, int base=0) + : mp(s) + {} + + + explicit BigIntRep(const Z& z) + : mp(z) + {} + /* ~BigIntRep() { mpz_clear(mp); } + */ - CGAL_CORE_EXPORT CORE_NEW(BigIntRep) - CGAL_CORE_EXPORT CORE_DELETE(BigIntRep) + //CGAL_CORE_EXPORT CORE_NEW(BigIntRep) + //CGAL_CORE_EXPORT CORE_DELETE(BigIntRep) - mpz_srcptr get_mp() const { + const Z& get_mp() const { return mp; } - mpz_ptr get_mp() { + Z& get_mp() { return mp; } private: - mpz_t mp; + Z mp; }; -typedef RCImpl RCBigInt; -class CGAL_CORE_EXPORT BigInt : public RCBigInt { + //typedef RCImpl RCBigInt; + +class CGAL_CORE_EXPORT BigInt : public RCImpl { public: + + typedef RCImpl RCBigInt; + /// \name Constructors //@{ /// default constructor BigInt() : RCBigInt(new BigIntRep()) {} + BigInt(const Z& z) : RCBigInt(new BigIntRep(z)) {} /// constructor for signed char BigInt(signed char x) : RCBigInt(new BigIntRep(x)) {} /// constructor for unsigned char @@ -128,8 +154,9 @@ class CGAL_CORE_EXPORT BigInt : public RCBigInt { BigInt(const char* s, int base=0) : RCBigInt(new BigIntRep(s, base)) {} /// constructor for std::string with base BigInt(const std::string& s, int base=0) : RCBigInt(new BigIntRep(s, base)) {} + /// constructor for mpz_srcptr - explicit BigInt(mpz_srcptr z) : RCBigInt(new BigIntRep(z)) {} + // explicit BigInt(mpz_srcptr z) : RCBigInt(new BigIntRep(z)) {} //@} /// \name Copy-Assignment-Destructor @@ -157,52 +184,53 @@ class CGAL_CORE_EXPORT BigInt : public RCBigInt { //@{ BigInt& operator +=(const BigInt& rhs) { makeCopy(); - mpz_add(get_mp(), get_mp(), rhs.get_mp()); + get_mp() += rhs.get_mp(); return *this; } + BigInt& operator -=(const BigInt& rhs) { makeCopy(); - mpz_sub(get_mp(), get_mp(), rhs.get_mp()); + get_mp() -= rhs.get_mp(); return *this; } BigInt& operator *=(const BigInt& rhs) { makeCopy(); - mpz_mul(get_mp(), get_mp(), rhs.get_mp()); + get_mp() *= rhs.get_mp(); return *this; } BigInt& operator /=(const BigInt& rhs) { makeCopy(); - mpz_tdiv_q(get_mp(), get_mp(), rhs.get_mp()); + get_mp() /= rhs.get_mp(); return *this; } BigInt& operator %=(const BigInt& rhs) { makeCopy(); - mpz_tdiv_r(get_mp(), get_mp(), rhs.get_mp()); + get_mp() %= rhs.get_mp(); return *this; } BigInt& operator &=(const BigInt& rhs) { makeCopy(); - mpz_and(get_mp(), get_mp(), rhs.get_mp()); + get_mp() &= rhs.get_mp(); return *this; } BigInt& operator |=(const BigInt& rhs) { makeCopy(); - mpz_ior(get_mp(), get_mp(), rhs.get_mp()); + get_mp() |= rhs.get_mp(); return *this; } BigInt& operator ^=(const BigInt& rhs) { makeCopy(); - mpz_xor(get_mp(), get_mp(), rhs.get_mp()); + get_mp() ^= rhs.get_mp(); return *this; } BigInt& operator <<=(unsigned long ul) { makeCopy(); - mpz_mul_2exp(get_mp(), get_mp(), ul); + get_mp() <<= ul; return *this; } BigInt& operator >>=(unsigned long ul) { makeCopy(); - mpz_tdiv_q_2exp(get_mp(), get_mp(), ul); + get_mp() >>= ul; return *this; } //@} @@ -214,17 +242,17 @@ class CGAL_CORE_EXPORT BigInt : public RCBigInt { } BigInt operator-() const { BigInt r; - mpz_neg(r.get_mp(), get_mp()); + r.get_mp() = -get_mp(); return r; } BigInt& operator++() { makeCopy(); - mpz_add_ui(get_mp(), get_mp(), 1); + ++get_mp(); return *this; } BigInt& operator--() { makeCopy(); - mpz_sub_ui(get_mp(), get_mp(), 1); + --get_mp(); return *this; } BigInt operator++(int) { @@ -246,11 +274,11 @@ class CGAL_CORE_EXPORT BigInt : public RCBigInt { return false; } /// get mpz pointer (const) - mpz_srcptr get_mp() const { + const Z& get_mp() const { return rep->get_mp(); } /// get mpz pointer - mpz_ptr get_mp() { + Z& get_mp() { return rep->get_mp(); } //@} @@ -260,16 +288,12 @@ class CGAL_CORE_EXPORT BigInt : public RCBigInt { /// set value from const char* int set_str(const char* s, int base = 0) { makeCopy(); - return mpz_set_str(get_mp(), s, base); + get_mp() = Z(s); + return 0; // should be -1 if not correct in the base (we ignore) } /// convert to std::string std::string get_str(int base = 10) const { - int n = mpz_sizeinbase (get_mp(), base) + 2; - char *buffer = new char[n]; - mpz_get_str(buffer, base, get_mp()); - std::string result(buffer); - delete [] buffer; - return result; + return get_mp().convert_to(); } //@} @@ -277,130 +301,152 @@ class CGAL_CORE_EXPORT BigInt : public RCBigInt { //@{ /// intValue int intValue() const { - return static_cast(mpz_get_si(get_mp())); + return get_mp().convert_to(); } /// longValue long longValue() const { - return mpz_get_si(get_mp()); + return get_mp().convert_to(); } /// ulongValue unsigned long ulongValue() const { - return mpz_get_ui(get_mp()); + return get_mp().convert_to(); } /// doubleValue double doubleValue() const { - return mpz_get_d(get_mp()); + return get_mp().convert_to(); } //@} }; inline BigInt operator+(const BigInt& a, const BigInt& b) { BigInt r; - mpz_add(r.get_mp(), a.get_mp(), b.get_mp()); + r.get_mp() = a.get_mp() + b.get_mp(); return r; } + inline BigInt operator-(const BigInt& a, const BigInt& b) { BigInt r; - mpz_sub(r.get_mp(), a.get_mp(), b.get_mp()); + r.get_mp() = a.get_mp() - b.get_mp(); return r; } + inline BigInt operator*(const BigInt& a, const BigInt& b) { BigInt r; - mpz_mul(r.get_mp(), a.get_mp(), b.get_mp()); + r.get_mp() = a.get_mp() * b.get_mp(); return r; } + inline BigInt operator/(const BigInt& a, const BigInt& b) { BigInt r; - mpz_tdiv_q(r.get_mp(), a.get_mp(), b.get_mp()); + r.get_mp() = a.get_mp() / b.get_mp(); return r; } + inline BigInt operator%(const BigInt& a, const BigInt& b) { BigInt r; - mpz_tdiv_r(r.get_mp(), a.get_mp(), b.get_mp()); + r.get_mp() = a.get_mp() % b.get_mp(); return r; } + inline BigInt operator&(const BigInt& a, const BigInt& b) { BigInt r; - mpz_and(r.get_mp(), a.get_mp(), b.get_mp()); + r.get_mp() = a.get_mp() & b.get_mp(); return r; } + inline BigInt operator|(const BigInt& a, const BigInt& b) { BigInt r; - mpz_ior(r.get_mp(), a.get_mp(), b.get_mp()); + r.get_mp() = a.get_mp()| b.get_mp(); return r; } + inline BigInt operator^(const BigInt& a, const BigInt& b) { BigInt r; - mpz_xor(r.get_mp(), a.get_mp(), b.get_mp()); + r.get_mp() = a.get_mp() ^ b.get_mp(); return r; } + inline BigInt operator<<(const BigInt& a, unsigned long ul) { BigInt r; - mpz_mul_2exp(r.get_mp(), a.get_mp(), ul); + r.get_mp() = a.get_mp() << ul; return r; } + inline BigInt operator>>(const BigInt& a, unsigned long ul) { BigInt r; - mpz_tdiv_q_2exp(r.get_mp(), a.get_mp(), ul); + r.get_mp() = a.get_mp() >> ul; return r; } + inline int cmp(const BigInt& x, const BigInt& y) { - return mpz_cmp(x.get_mp(), y.get_mp()); + return x.get_mp().compare(y.get_mp()); } + + inline bool operator==(const BigInt& a, const BigInt& b) { return cmp(a, b) == 0; } + inline bool operator!=(const BigInt& a, const BigInt& b) { return cmp(a, b) != 0; } + inline bool operator>=(const BigInt& a, const BigInt& b) { return cmp(a, b) >= 0; } + inline bool operator>(const BigInt& a, const BigInt& b) { return cmp(a, b) > 0; } + inline bool operator<=(const BigInt& a, const BigInt& b) { return cmp(a, b) <= 0; } + inline bool operator<(const BigInt& a, const BigInt& b) { return cmp(a, b) < 0; } inline std::ostream& operator<<(std::ostream& o, const BigInt& x) { - //return CORE::operator<<(o, x.get_mp()); - return CORE::io_write(o, x.get_mp()); + return o <>(std::istream& i, BigInt& x) { x.makeCopy(); - //return CORE::operator>>(i, x.get_mp()); - return CORE::io_read(i, x.get_mp()); + return i >> x.get_mp(); } /// sign inline int sign(const BigInt& a) { - return mpz_sgn(a.get_mp()); + return sign(a.get_mp()); } + /// abs inline BigInt abs(const BigInt& a) { BigInt r; - mpz_abs(r.get_mp(), a.get_mp()); + r.get_mp() = abs(a.get_mp()); return r; } + /// neg inline BigInt neg(const BigInt& a) { BigInt r; - mpz_neg(r.get_mp(), a.get_mp()); + r.get_mp() = - a.get_mp(); return r; } + /// negate inline void negate(BigInt& a) { a.makeCopy(); - mpz_neg(a.get_mp(), a.get_mp()); + a.get_mp() = - a.get_mp(); } + /// cmpabs inline int cmpabs(const BigInt& a, const BigInt& b) { - return mpz_cmpabs(a.get_mp(), b.get_mp()); + assert(false); + // return mpz_cmpabs(a.get_mp(), b.get_mp()); AF: todo + return 0; } /// \name Conversion Functions @@ -409,63 +455,80 @@ inline int cmpabs(const BigInt& a, const BigInt& b) { inline long longValue(const BigInt& a) { return a.longValue(); } + /// ulongValue inline unsigned long ulongValue(const BigInt& a) { return a.ulongValue(); } + /// doubleValue inline double doubleValue(const BigInt& a) { return a.doubleValue(); } //@} +/* + /// \name File I/O Functions //@{ /// read from file + void readFromFile(BigInt& z, std::istream& in, long maxLength = 0); /// write to file void writeToFile(const BigInt& z, std::ostream& in, int base=10, int charsPerLine=80); //@} +*/ + /// \name Misc Functions //@{ /// isEven inline bool isEven(const BigInt& z) { - return mpz_even_p(z.get_mp()); + return bit_test(z.get_mp(),0) == 0; } /// isOdd inline bool isOdd(const BigInt& z) { - return mpz_odd_p(z.get_mp()); + return bit_test(z.get_mp(),0) == 1; } /// get exponent of power 2 inline unsigned long getBinExpo(const BigInt& z) { - return mpz_scan1(z.get_mp(), 0); + return lsb(abs(z.get_mp())); } + /// get exponent of power k inline void getKaryExpo(const BigInt& z, BigInt& m, int& e, unsigned long k) { + assert(false); // AF: todo + /* mpz_t f; mpz_init_set_ui(f, k); m.makeCopy(); e = mpz_remove(m.get_mp(), z.get_mp(), f); mpz_clear(f); + */ } /// divisible(x,y) = "x | y" inline bool isDivisible(const BigInt& x, const BigInt& y) { - return mpz_divisible_p(x.get_mp(), y.get_mp()) != 0; + assert(false); + return true; // AF mpz_divisible_p(x.get_mp(), y.get_mp()) != 0; } + inline bool isDivisible(int x, int y) { return x % y == 0; } + inline bool isDivisible(long x, long y) { return x % y == 0; + } /// exact div inline void divexact(BigInt& z, const BigInt& x, const BigInt& y) { z.makeCopy(); - mpz_divexact(z.get_mp(), x.get_mp(), y.get_mp()); + assert(false); + // AF: todo mpz_divexact(z.get_mp(), x.get_mp(), y.get_mp()); } + // Chee (1/12/2004) The definition of div_exact(x,y) next // ensure that in Polynomials works with both NT=BigInt and NT=int: inline BigInt div_exact(const BigInt& x, const BigInt& y) { @@ -473,9 +536,11 @@ inline BigInt div_exact(const BigInt& x, const BigInt& y) { divexact(z, x, y); // z is set to x/y; return z; } + inline int div_exact(int x, int y) { return x/y; // precondition: isDivisible(x,y) } + inline long div_exact(long x, long y) { return x/y; // precondition: isDivisible(x,y) } @@ -484,19 +549,21 @@ inline long div_exact(long x, long y) { /// gcd inline BigInt gcd(const BigInt& a, const BigInt& b) { BigInt r; - mpz_gcd(r.get_mp(), a.get_mp(), b.get_mp()); + r.get_mp() = gcd(a.get_mp(), b.get_mp()); return r; } + /// div_rem inline void div_rem(BigInt& q, BigInt& r, const BigInt& a, const BigInt& b) { q.makeCopy(); r.makeCopy(); - mpz_tdiv_qr(q.get_mp(), r.get_mp(), a.get_mp(), b.get_mp()); + divide_qr(a.get_mp(), b.get_mp(), q.get_mp(), r.get_mp()); } + /// power inline void power(BigInt& c, const BigInt& a, unsigned long ul) { c.makeCopy(); - mpz_pow_ui(c.get_mp(), a.get_mp(), ul); + c.get_mp() = pow(a.get_mp(), ul); } // pow @@ -508,8 +575,9 @@ inline BigInt pow(const BigInt& a, unsigned long ui) { // bit length inline int bitLength(const BigInt& a) { - return mpz_sizeinbase(a.get_mp(), 2); + return msb(abs(a.get_mp())); /// AF todo was mpz_sizeinbase(a.get_mp(), 2); } + /// floorLg -- floor of log_2(a) /** Convention: a=0, floorLg(a) returns -1. * This makes sense for integer a. @@ -517,6 +585,7 @@ inline int bitLength(const BigInt& a) { inline long floorLg(const BigInt& a) { return (sign(a) == 0) ? (-1) : (bitLength(a)-1); } + /// ceilLg -- ceiling of log_2(a) where a=BigInt, int or long /** Convention: a=0, ceilLg(a) returns -1. * This makes sense for integer a. @@ -525,11 +594,14 @@ inline long ceilLg(const BigInt& a) { if (sign(a) == 0) return -1; unsigned long len = bitLength(a); - return (mpz_scan1(a.get_mp(), 0) == len-1) ? (len-1) : len; + + return (lsb(a.get_mp()) == len - 1) ? (len - 1) : len; } + inline long ceilLg(long a) { // need this for Polynomial return ceilLg(BigInt(a)); } + inline long ceilLg(int a) { // need this for Polynomial return ceilLg(BigInt(a)); } diff --git a/CGAL_Core/include/CGAL/CORE/BigRat.h b/CGAL_Core/include/CGAL/CORE/BigRat.h index 29b99509d406..1d980394301d 100644 --- a/CGAL_Core/include/CGAL/CORE/BigRat.h +++ b/CGAL_Core/include/CGAL/CORE/BigRat.h @@ -29,93 +29,87 @@ namespace CORE { + typedef boost::multiprecision::cpp_rational Q; + class BigRatRep : public RCRepImpl { public: - BigRatRep() { - mpq_init(mp); - } + BigRatRep() + : mp() + {} + // Note : should the copy-ctor be alloed at all ? [Sylvain Pion] - BigRatRep(const BigRatRep& z) : RCRepImpl() { - mpq_init(mp); - mpq_set(mp, z.mp); - } - BigRatRep(signed char c) { - mpq_init(mp); - mpq_set_si(mp, c, 1); - } - BigRatRep(unsigned char c) { - mpq_init(mp); - mpq_set_ui(mp, c, 1); - } - BigRatRep(signed int i) { - mpq_init(mp); - mpq_set_si(mp, i, 1); - } - BigRatRep(unsigned int i) { - mpq_init(mp); - mpq_set_ui(mp, i, 1); - } - BigRatRep(signed short int s) { - mpq_init(mp); - mpq_set_si(mp, s, 1); - } - BigRatRep(unsigned short int s) { - mpq_init(mp); - mpq_set_ui(mp, s, 1); - } - BigRatRep(signed long int l) { - mpq_init(mp); - mpq_set_si(mp, l, 1); - } - BigRatRep(unsigned long int l) { - mpq_init(mp); - mpq_set_ui(mp, l, 1); - } - BigRatRep(float f) { - mpq_init(mp); - mpq_set_d(mp, f); - } - BigRatRep(double d) { - mpq_init(mp); - mpq_set_d(mp, d); - } - BigRatRep(const char* s) { - mpq_init(mp); - mpq_set_str(mp, s, 0); - } - BigRatRep(const std::string& s) { - mpq_init(mp); - mpq_set_str(mp, s.c_str(), 0); - } - explicit BigRatRep(mpq_srcptr q) { - mpq_init(mp); - mpq_set(mp, q); - } - BigRatRep(mpz_srcptr z) { - mpq_init(mp); - mpq_set_z(mp, z); - } - BigRatRep(mpz_srcptr n, mpz_srcptr d) { - mpq_init(mp); - mpz_set(mpq_numref(mp), n); - mpz_set(mpq_denref(mp), d); - mpq_canonicalize(mp); - } - ~BigRatRep() { - mpq_clear(mp); - } + BigRatRep(const BigRatRep& z) : RCRepImpl(), mp(z.mp) + {} + + + BigRatRep(signed char c) + : mp(c) + {} + + BigRatRep(unsigned char c) + : mp(c) + {} + + BigRatRep(signed int i) + : mp(i) + {} + + BigRatRep(unsigned int i) + : mp(i) + {} + + BigRatRep(signed short int s) + : mp(s) + {} + + BigRatRep(unsigned short int s) + : mp(s) + {} + + BigRatRep(signed long int l) + : mp(l) + {} + + BigRatRep(unsigned long int l) + : mp(l) + {} - CGAL_CORE_EXPORT CORE_NEW(BigRatRep) - CGAL_CORE_EXPORT CORE_DELETE(BigRatRep) + BigRatRep(float f) + : mp(f) + {} - mpq_srcptr get_mp() const { + BigRatRep(double d) + : mp(d) + {} + + BigRatRep(const char* s) + : mp(s) + {} + + BigRatRep(const std::string& s) + : mp(s) + {} + + explicit BigRatRep(const Z& q) + : mp(q) + {} + + BigRatRep(const Z& n, const Z& d) + : mp(n,d) + {} + + + //CGAL_CORE_EXPORT CORE_NEW(BigRatRep) +// CGAL_CORE_EXPORT CORE_DELETE(BigRatRep) + + const Q& get_mp() const { return mp; } - mpq_ptr get_mp() { + Q& get_mp() { return mp; } private: - mpq_t mp; + Q mp; }; //BigRatRep class BigFloat; @@ -152,7 +146,7 @@ class BigRat : public RCBigRat { /// constructor for std::string with base BigRat(const std::string& s) : RCBigRat(new BigRatRep(s)) {} /// constructor for mpq_srcptr - explicit BigRat(mpq_srcptr z) : RCBigRat(new BigRatRep(z)) {} + explicit BigRat(const Z& z) : RCBigRat(new BigRatRep(z)) {} /// constructor for BigInt BigRat(const BigInt& z) : RCBigRat(new BigRatRep(z.get_mp())) {} /// constructor for two BigInts @@ -187,32 +181,34 @@ class BigRat : public RCBigRat { //@{ BigRat& operator +=(const BigRat& rhs) { makeCopy(); - mpq_add(get_mp(), get_mp(), rhs.get_mp()); + get_mp() += rhs.get_mp(); return *this; } BigRat& operator -=(const BigRat& rhs) { makeCopy(); - mpq_sub(get_mp(), get_mp(), rhs.get_mp()); + get_mp() -= rhs.get_mp(); return *this; } BigRat& operator *=(const BigRat& rhs) { makeCopy(); - mpq_mul(get_mp(), get_mp(), rhs.get_mp()); + get_mp() *= rhs.get_mp(); return *this; } BigRat& operator /=(const BigRat& rhs) { makeCopy(); - mpq_div(get_mp(), get_mp(), rhs.get_mp()); + get_mp() /= rhs.get_mp(); return *this; } BigRat& operator <<=(unsigned long ul) { makeCopy(); - mpq_mul_2exp(get_mp(), get_mp(), ul); + assert(false); + // AF no shift for Q get_mp() <<= ul; return *this; } BigRat& operator >>=(unsigned long ul) { makeCopy(); - mpq_div_2exp(get_mp(), get_mp(), ul); + assert(false); + // AF no >> for Q get_mp() >>= ul; return *this; } //@} @@ -223,7 +219,7 @@ class BigRat : public RCBigRat { /// exact division by 2 (this method is provided for compatibility) BigRat div2() const { BigRat r; BigRat t(2); // probably not most efficient way - mpq_div(r.get_mp(), get_mp(), t.get_mp()); + r.get_mp() /= t.get_mp(); return r; } BigRat operator+() const { @@ -231,17 +227,17 @@ class BigRat : public RCBigRat { } BigRat operator-() const { BigRat r; - mpq_neg(r.get_mp(), get_mp()); + r.get_mp() = - get_mp(); return r; } BigRat& operator++() { makeCopy(); - mpz_add(get_num_mp(),get_num_mp(),get_den_mp()); + get_num_mp() += get_den_mp(); return *this; } BigRat& operator--() { makeCopy(); - mpz_sub(get_num_mp(),get_num_mp(),get_den_mp()); + get_num_mp() -= get_den_mp(); return *this; } BigRat operator++(int) { @@ -261,7 +257,8 @@ class BigRat : public RCBigRat { /// Canonicalize void canonicalize() { makeCopy(); - mpq_canonicalize(get_mp()); + assert(false); + // AF todo mpq_canonicalize(get_mp()); } /// Has Exact Division static bool hasExactDivision() { @@ -269,28 +266,28 @@ class BigRat : public RCBigRat { } /// return mpz pointer of numerator (const) - mpz_srcptr get_num_mp() const { - return mpq_numref(get_mp()); + Z get_num_mp() const { + return numerator(get_mp()); } - /// return mpz pointer of numerator - mpz_ptr get_num_mp() { - return mpq_numref(get_mp()); + /// return mpz pointer of numerator // no references as numerator() returns a copy + Z get_num_mp() { + return numerator(get_mp()); } /// return mpz pointer of denominator - mpz_srcptr get_den_mp() const { - return mpq_denref(get_mp()); + Z get_den_mp() const { + return denominator(get_mp()); } /// return mpz pointer of denominator - mpz_ptr get_den_mp() { - return mpq_denref(get_mp()); + Z get_den_mp() { + return denominator(get_mp()); } /// get mpq pointer (const) - mpq_srcptr get_mp() const { + const Q& get_mp() const { return rep->get_mp(); } /// get mpq pointer - mpq_ptr get_mp() { + Q& get_mp() { return rep->get_mp(); } //@} @@ -300,16 +297,12 @@ class BigRat : public RCBigRat { /// set value from const char* int set_str(const char* s, int base = 0) { makeCopy(); - return mpq_set_str(get_mp(), s, base); + get_mp() = Q(s); + return 0; } /// convert to std::string std::string get_str(int base = 10) const { - int n = mpz_sizeinbase(mpq_numref(get_mp()), base) + mpz_sizeinbase(mpq_denref(get_mp()), base)+ 3; - char *buffer = new char[n]; - mpq_get_str(buffer, base, get_mp()); - std::string result(buffer); - delete [] buffer; - return result; + return get_mp().convert_to(); } //@} @@ -317,20 +310,21 @@ class BigRat : public RCBigRat { //@{ /// intValue int intValue() const { - return static_cast(doubleValue()); + return get_mp().convert_to(); } /// longValue long longValue() const { - return static_cast(doubleValue()); + return get_mp().convert_to(); } + /// doubleValue double doubleValue() const { - return mpq_get_d(get_mp()); + return get_mp().convert_to(); } /// BigIntValue BigInt BigIntValue() const { BigInt r; - mpz_tdiv_q(r.get_mp(), get_num_mp(), get_den_mp()); + r.get_mp() = Z( get_num_mp() / get_den_mp()); // AF check that this is the integer divsion without rest return r; } //@} @@ -338,22 +332,22 @@ class BigRat : public RCBigRat { inline BigRat operator+(const BigRat& a, const BigRat& b) { BigRat r; - mpq_add(r.get_mp(), a.get_mp(), b.get_mp()); + r.get_mp() = a.get_mp() + b.get_mp(); return r; } inline BigRat operator-(const BigRat& a, const BigRat& b) { BigRat r; - mpq_sub(r.get_mp(), a.get_mp(), b.get_mp()); + r.get_mp() = a.get_mp() - b.get_mp(); return r; } inline BigRat operator*(const BigRat& a, const BigRat& b) { BigRat r; - mpq_mul(r.get_mp(), a.get_mp(), b.get_mp()); + r.get_mp() = a.get_mp() * b.get_mp(); return r; } inline BigRat operator/(const BigRat& a, const BigRat& b) { BigRat r; - mpq_div(r.get_mp(), a.get_mp(), b.get_mp()); + r.get_mp() = a.get_mp() / b.get_mp(); return r; } // Chee (3/19/2004): @@ -362,7 +356,7 @@ inline BigRat operator/(const BigRat& a, const BigRat& b) { /// divisible(x,y) = "x | y" inline BigRat div_exact(const BigRat& x, const BigRat& y) { BigRat z; - mpq_div(z.get_mp(), x.get_mp(), y.get_mp()); + z.get_mp() = x.get_mp() / y.get_mp(); return z; } /// numerator @@ -396,22 +390,22 @@ inline bool isInteger(const BigRat& x) { } inline bool isDivisible(const BigRat& x, const BigRat& y) { BigRat r; - mpq_div(r.get_mp(), x.get_mp(), y.get_mp()); + r.get_mp() = x.get_mp() / y.get_mp(); return isInteger(r); } inline BigRat operator<<(const BigRat& a, unsigned long ul) { BigRat r; - mpq_mul_2exp(r.get_mp(), a.get_mp(), ul); + //AF todo no << for Q r.get_mp() = a.get_mp() << int(ul) ; return r; } inline BigRat operator>>(const BigRat& a, unsigned long ul) { BigRat r; - mpq_div_2exp(r.get_mp(), a.get_mp(), ul); + // AF todo no >> for Q r.get_mp() = a.get_mp() >> ul; return r; } inline int cmp(const BigRat& x, const BigRat& y) { - return mpq_cmp(x.get_mp(), y.get_mp()); + return x.get_mp().compare(y.get_mp()); } inline bool operator==(const BigRat& a, const BigRat& b) { return cmp(a, b) == 0; @@ -433,29 +427,27 @@ inline bool operator<(const BigRat& a, const BigRat& b) { } inline std::ostream& operator<<(std::ostream& o, const BigRat& x) { - //return CORE::operator<<(o, x.get_mp()); - return CORE::io_write(o, x.get_mp()); + return o << x.get_mp(); } inline std::istream& operator>>(std::istream& i, BigRat& x) { x.makeCopy(); - //return CORE::operator>>(i, x.get_mp()); - return CORE::io_read(i, x.get_mp()); + return i >> x.get_mp(); } /// sign inline int sign(const BigRat& a) { - return mpq_sgn(a.get_mp()); + return sign(a.get_mp()); } /// abs inline BigRat abs(const BigRat& a) { BigRat r; - mpq_abs(r.get_mp(), a.get_mp()); + r.get_mp() = abs( a.get_mp()); return r; } /// neg inline BigRat neg(const BigRat& a) { BigRat r; - mpq_neg(r.get_mp(), a.get_mp()); + r.get_mp() = - a.get_mp(); return r; } /// div2 diff --git a/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h b/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h index 0e4a2044e747..785f6cc5cd64 100644 --- a/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h +++ b/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h @@ -268,6 +268,9 @@ void readFromFile(BigInt& z, std::istream& in, long maxLength) { CGAL_INLINE_FUNCTION void writeToFile(const BigInt& z, std::ostream& out, int base, int charsPerLine) { + + assert(false); + /* BigInt c = abs(z); // get the absoulte value string @@ -286,10 +289,14 @@ void writeToFile(const BigInt& z, std::ostream& out, int base, int charsPerLine) write_base_number(out, buffer, length, base, charsPerLine); out << "\n"; delete[] buffer; + */ } CGAL_INLINE_FUNCTION void readFromFile(BigFloat& bf, std::istream& in, long maxLength) { + + assert(false); + /* char *buffer; long length; long exponent; @@ -326,10 +333,14 @@ void readFromFile(BigFloat& bf, std::istream& in, long maxLength) { // construct BigFloat bf = BigFloat(mantissa, 0, exponent); + */ } CGAL_INLINE_FUNCTION void writeToFile(const BigFloat& bf, std::ostream& out, int base, int charsPerLine) { + + assert(false); + /* BigInt c(CORE::abs(bf.m())); // get the absoulte value string @@ -351,6 +362,7 @@ void writeToFile(const BigFloat& bf, std::ostream& out, int base, int charsPerLi write_base_number(out, buffer, length, base, charsPerLine); out << '\n'; delete[] buffer; + */ } /* Underconstruction ---- diff --git a/CGAL_Core/include/CGAL/CORE/Expr_impl.h b/CGAL_Core/include/CGAL/CORE/Expr_impl.h index 72dc46015bf1..6b036d31544e 100644 --- a/CGAL_Core/include/CGAL/CORE/Expr_impl.h +++ b/CGAL_Core/include/CGAL/CORE/Expr_impl.h @@ -1215,8 +1215,8 @@ void BinOpRep::debugTree(int level, int indent, int depthLimit) const { second->debugTree(level, indent + 2, depthLimit - 1); } -CORE_MEMORY_IMPL(BigIntRep) -CORE_MEMORY_IMPL(BigRatRep) +// AF CORE_MEMORY_IMPL(BigIntRep) +// AF CORE_MEMORY_IMPL(BigRatRep) CORE_MEMORY_IMPL(ConstDoubleRep) CORE_MEMORY_IMPL(ConstRealRep) diff --git a/Number_types/include/CGAL/CORE_BigInt.h b/Number_types/include/CGAL/CORE_BigInt.h index 0b599543164a..bdeaddd10e12 100644 --- a/Number_types/include/CGAL/CORE_BigInt.h +++ b/Number_types/include/CGAL/CORE_BigInt.h @@ -48,7 +48,7 @@ template <> class Algebraic_structure_traits< CORE::BigInt > //! computes the largest NT not larger than the square root of \a a. Type operator()( const Type& x) const { Type result; - mpz_sqrt(result.get_mp(), x.get_mp()); + result.get_mp() = sqrt( x.get_mp()); return result; } }; @@ -63,7 +63,7 @@ template <> class Algebraic_structure_traits< CORE::BigInt > if ( x == Type(0) && y == Type(0) ) return Type(0); Type result; - mpz_gcd(result.get_mp(), x.get_mp(), y.get_mp()); + result.get_mp() = gcd( x.get_mp(), y.get_mp()); return result; } }; From b801aaa8feba5db004ab1d60e523de568c168744 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 7 Oct 2021 18:26:17 +0100 Subject: [PATCH 002/139] Fix getKaryExpo() --- CGAL_Core/include/CGAL/CORE/BigInt.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 5db2b9880cf0..33015bc6925d 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -497,8 +497,17 @@ inline unsigned long getBinExpo(const BigInt& z) { } /// get exponent of power k -inline void getKaryExpo(const BigInt& z, BigInt& m, int& e, unsigned long k) { - assert(false); // AF: todo +inline void getKaryExpo(const BigInt& z, BigInt& m, int& e, unsigned long uk) { + BigInt k(uk), q, r; + e = 0; + m = z; + for(;;) { + divide_qr(m.get_mp(), k.get_mp(), q.get_mp(), r.get_mp()); + if (!r.get_mp().is_zero()) break; + m.get_mp() = q.get_mp(); + ++e; + } + /* mpz_t f; mpz_init_set_ui(f, k); From 945ba57bc1d4e932b03969b5a2bd103888a99436 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 11 Oct 2021 14:39:17 +0100 Subject: [PATCH 003/139] lsb works ony on positive numbers --- CGAL_Core/include/CGAL/CORE/BigInt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 33015bc6925d..282afc347459 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -604,7 +604,7 @@ inline long ceilLg(const BigInt& a) { return -1; unsigned long len = bitLength(a); - return (lsb(a.get_mp()) == len - 1) ? (len - 1) : len; + return (lsb(abs(a.get_mp())) == len - 1) ? (len - 1) : len; } inline long ceilLg(long a) { // need this for Polynomial From dc93a3eccd3f652d292934a921d9db8a9bfb1a58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 11 Oct 2021 15:40:14 +0200 Subject: [PATCH 004/139] fix include --- CGAL_Core/include/CGAL/CORE/BigInt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 282afc347459..adf8bbb5d2b3 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -24,7 +24,7 @@ #ifndef _CORE_BIGINT_H_ #define _CORE_BIGINT_H_ -#include +#include #include #include #include From b93c2ce96a23b0532c57df70237903e790851eab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 11 Oct 2021 17:12:16 +0200 Subject: [PATCH 005/139] fixes while doing a review --- CGAL_Core/include/CGAL/CORE/BigInt.h | 2 +- CGAL_Core/include/CGAL/CORE/BigRat.h | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index adf8bbb5d2b3..23d71446ee26 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -584,7 +584,7 @@ inline BigInt pow(const BigInt& a, unsigned long ui) { // bit length inline int bitLength(const BigInt& a) { - return msb(abs(a.get_mp())); /// AF todo was mpz_sizeinbase(a.get_mp(), 2); + return msb(abs(a.get_mp()))+1; /// AF todo was mpz_sizeinbase(a.get_mp(), 2); } /// floorLg -- floor of log_2(a) diff --git a/CGAL_Core/include/CGAL/CORE/BigRat.h b/CGAL_Core/include/CGAL/CORE/BigRat.h index 1d980394301d..e5379f119ffb 100644 --- a/CGAL_Core/include/CGAL/CORE/BigRat.h +++ b/CGAL_Core/include/CGAL/CORE/BigRat.h @@ -219,7 +219,7 @@ class BigRat : public RCBigRat { /// exact division by 2 (this method is provided for compatibility) BigRat div2() const { BigRat r; BigRat t(2); // probably not most efficient way - r.get_mp() /= t.get_mp(); + r.get_mp() = get_mp() / t.get_mp(); return r; } BigRat operator+() const { @@ -232,12 +232,12 @@ class BigRat : public RCBigRat { } BigRat& operator++() { makeCopy(); - get_num_mp() += get_den_mp(); + ++get_mp(); return *this; } BigRat& operator--() { makeCopy(); - get_num_mp() -= get_den_mp(); + --get_mp(); return *this; } BigRat operator++(int) { @@ -324,7 +324,8 @@ class BigRat : public RCBigRat { /// BigIntValue BigInt BigIntValue() const { BigInt r; - r.get_mp() = Z( get_num_mp() / get_den_mp()); // AF check that this is the integer divsion without rest + Z rem; + divide_qr(get_num_mp(),get_den_mp(), r.get_mp(), rem); return r; } //@} From e2f38514ceaff4eb56c855264e45a20b92dd3de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 11 Oct 2021 17:14:05 +0200 Subject: [PATCH 006/139] revert changes --- CGAL_Core/include/CGAL/CORE/BigFloat.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigFloat.h b/CGAL_Core/include/CGAL/CORE/BigFloat.h index 176de0b19971..97183f63e508 100644 --- a/CGAL_Core/include/CGAL/CORE/BigFloat.h +++ b/CGAL_Core/include/CGAL/CORE/BigFloat.h @@ -69,7 +69,6 @@ class CGAL_CORE_EXPORT BigFloat : public RCBigFloat { : RCBigFloat(new BigFloatRep(i)) {} BigFloat(long& x, const extLong& /*r*/, const extLong& /*a*/) : RCBigFloat(new BigFloatRep(x)) {} - /// constructor from BigInt, error and exponent values BigFloat(const BigInt& I, unsigned long er, long ex) : RCBigFloat(new BigFloatRep(I, er, ex)) {} @@ -78,7 +77,6 @@ class CGAL_CORE_EXPORT BigFloat : public RCBigFloat { : RCBigFloat(new BigFloatRep(I, ex)) {} BigFloat(const BigInt& I) : RCBigFloat(new BigFloatRep(I)) {} - /// constructor for BigRat BigFloat(const BigRat& R, const extLong& r = get_static_defRelPrec(), const extLong& a = get_static_defAbsPrec()) @@ -216,12 +214,10 @@ class CGAL_CORE_EXPORT BigFloat : public RCBigFloat { double doubleValue() const { return rep->toDouble(); } - /// return BigInt value BigInt BigIntValue() const { return rep->toBigInt(); } - /// return BigRat value BigRat BigRatValue() const { return rep->BigRatize(); @@ -266,7 +262,6 @@ class CGAL_CORE_EXPORT BigFloat : public RCBigFloat { const BigInt& m() const { return rep->m; } - /// get error bits unsigned long err() const { return rep->err; @@ -364,12 +359,10 @@ class CGAL_CORE_EXPORT BigFloat : public RCBigFloat { /// \name Utility Functions //@{ /// approximate BigInt number - void approx(const BigInt& I, const extLong& r, const extLong& a) { makeCopy(); rep->trunc(I, r, a); } - /// approximate BigFloat number void approx(const BigFloat& B, const extLong& r, const extLong& a) { makeCopy(); From 112b633ad646bbcf09c0b74b1f09c53fe81d21fa Mon Sep 17 00:00:00 2001 From: Sebastien Loriot Date: Mon, 11 Oct 2021 17:16:04 +0200 Subject: [PATCH 007/139] add tmp assertions --- CGAL_Core/include/CGAL/CORE/BigRat.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CGAL_Core/include/CGAL/CORE/BigRat.h b/CGAL_Core/include/CGAL/CORE/BigRat.h index e5379f119ffb..8e1eb82e1713 100644 --- a/CGAL_Core/include/CGAL/CORE/BigRat.h +++ b/CGAL_Core/include/CGAL/CORE/BigRat.h @@ -396,11 +396,13 @@ inline bool isDivisible(const BigRat& x, const BigRat& y) { } inline BigRat operator<<(const BigRat& a, unsigned long ul) { BigRat r; + assert(false); //AF todo no << for Q r.get_mp() = a.get_mp() << int(ul) ; return r; } inline BigRat operator>>(const BigRat& a, unsigned long ul) { BigRat r; + assert(false); // AF todo no >> for Q r.get_mp() = a.get_mp() >> ul; return r; } From ed41c475f4d681d41461dd4480f079206882e891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 12 Oct 2021 09:07:47 +0200 Subject: [PATCH 008/139] remove TWS --- CGAL_Core/include/CGAL/CORE/BigInt.h | 2 +- CGAL_Core/include/CGAL/CORE/BigRat.h | 6 +++--- CGAL_Core/include/CGAL/CORE/CoreIO_impl.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 23d71446ee26..122874124c51 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -95,7 +95,7 @@ namespace CORE { : mp(s) {} - + explicit BigIntRep(const Z& z) : mp(z) {} diff --git a/CGAL_Core/include/CGAL/CORE/BigRat.h b/CGAL_Core/include/CGAL/CORE/BigRat.h index 8e1eb82e1713..ec9c12c3184e 100644 --- a/CGAL_Core/include/CGAL/CORE/BigRat.h +++ b/CGAL_Core/include/CGAL/CORE/BigRat.h @@ -36,11 +36,11 @@ class BigRatRep : public RCRepImpl { BigRatRep() : mp() {} - + // Note : should the copy-ctor be alloed at all ? [Sylvain Pion] BigRatRep(const BigRatRep& z) : RCRepImpl(), mp(z.mp) {} - + BigRatRep(signed char c) : mp(c) @@ -397,7 +397,7 @@ inline bool isDivisible(const BigRat& x, const BigRat& y) { inline BigRat operator<<(const BigRat& a, unsigned long ul) { BigRat r; assert(false); - //AF todo no << for Q r.get_mp() = a.get_mp() << int(ul) ; + //AF todo no << for Q r.get_mp() = a.get_mp() << int(ul) ; return r; } inline BigRat operator>>(const BigRat& a, unsigned long ul) { diff --git a/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h b/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h index 785f6cc5cd64..de0f59831a8b 100644 --- a/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h +++ b/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h @@ -268,7 +268,7 @@ void readFromFile(BigInt& z, std::istream& in, long maxLength) { CGAL_INLINE_FUNCTION void writeToFile(const BigInt& z, std::ostream& out, int base, int charsPerLine) { - + assert(false); /* BigInt c = abs(z); From a7b0b300288920d4c0bfc9d428f7c6d6da8936a1 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 12 Oct 2021 09:17:52 +0100 Subject: [PATCH 009/139] Add an assert() --- CGAL_Core/include/CGAL/CORE/BigInt.h | 1 + 1 file changed, 1 insertion(+) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 122874124c51..5a1d522d83e6 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -493,6 +493,7 @@ inline bool isOdd(const BigInt& z) { /// get exponent of power 2 inline unsigned long getBinExpo(const BigInt& z) { + assert(! z.get_mp().is_zero()); return lsb(abs(z.get_mp())); } From ef4b0ca15479f4979e4fde6491d26080eaa41249 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 12 Oct 2021 10:06:23 +0100 Subject: [PATCH 010/139] Add implementations; Fix getBinExpo() for zero --- CGAL_Core/include/CGAL/CORE/BigInt.h | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 5a1d522d83e6..71ea0b2b8166 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -493,7 +493,9 @@ inline bool isOdd(const BigInt& z) { /// get exponent of power 2 inline unsigned long getBinExpo(const BigInt& z) { - assert(! z.get_mp().is_zero()); + if (z.get_mp().is_zero()) { + return (std::numeric_limits::max)(); + } return lsb(abs(z.get_mp())); } @@ -508,20 +510,13 @@ inline void getKaryExpo(const BigInt& z, BigInt& m, int& e, unsigned long uk) { m.get_mp() = q.get_mp(); ++e; } - - /* - mpz_t f; - mpz_init_set_ui(f, k); - m.makeCopy(); - e = mpz_remove(m.get_mp(), z.get_mp(), f); - mpz_clear(f); - */ } /// divisible(x,y) = "x | y" inline bool isDivisible(const BigInt& x, const BigInt& y) { - assert(false); - return true; // AF mpz_divisible_p(x.get_mp(), y.get_mp()) != 0; + BigInt z, r; + divide_qr(x.get_mp(), y.get_mp(), z.get_mp(), r.get_mp()); + return r.get_mp().is_zero(); } inline bool isDivisible(int x, int y) { @@ -535,8 +530,8 @@ inline bool isDivisible(long x, long y) { /// exact div inline void divexact(BigInt& z, const BigInt& x, const BigInt& y) { z.makeCopy(); - assert(false); - // AF: todo mpz_divexact(z.get_mp(), x.get_mp(), y.get_mp()); + BigInt r; + divide_qr(x.get_mp(), y.get_mp(), z.get_mp(), r.get_mp() ); // was void mpz_divexact (mpz_t q, const mpz_t n, const mpz_t d) Is this faster? } // Chee (1/12/2004) The definition of div_exact(x,y) next From 74040d9d107d48737a8f3065638b092ed4807070 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 12 Oct 2021 15:49:26 +0100 Subject: [PATCH 011/139] msb(BigInt) is only defined for i > 0 --- CGAL_Core/include/CGAL/CORE/BigInt.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 71ea0b2b8166..8b2444d1da3f 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -458,6 +458,7 @@ inline long longValue(const BigInt& a) { /// ulongValue inline unsigned long ulongValue(const BigInt& a) { + assert(a >= BigInt(0)); return a.ulongValue(); } @@ -580,6 +581,9 @@ inline BigInt pow(const BigInt& a, unsigned long ui) { // bit length inline int bitLength(const BigInt& a) { + if (a.get_mp().is_zero()) { + return 0; + } return msb(abs(a.get_mp()))+1; /// AF todo was mpz_sizeinbase(a.get_mp(), 2); } From f13e14994cfa49209eb977f68e805aa6c3651e75 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 12 Oct 2021 15:50:41 +0100 Subject: [PATCH 012/139] I think we must call abs(); Someone has to check --- CGAL_Core/include/CGAL/CORE/BigFloat_impl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h b/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h index 3cbd077e4878..6734428f812d 100644 --- a/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h +++ b/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h @@ -455,6 +455,7 @@ void BigFloatRep::centerize(const BigFloatRep& a, const BigFloatRep& b) { // Zilin & Vikram, 08/24/04 // err = 1 + longValue(chunkShift(r.m, r.exp - exp)); BigInt E = chunkShift(r.m, r.exp - exp); + E = abs(E); bigNormal(E); } From 64a64e1a8ac0cf03700743fbd92b3159c2be8f75 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 13 Oct 2021 23:11:56 +0100 Subject: [PATCH 013/139] Add a makeCopy() --- CGAL_Core/include/CGAL/CORE/BigInt.h | 1 + 1 file changed, 1 insertion(+) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 8b2444d1da3f..2a35194c519e 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -505,6 +505,7 @@ inline void getKaryExpo(const BigInt& z, BigInt& m, int& e, unsigned long uk) { BigInt k(uk), q, r; e = 0; m = z; + m.makeCopy(); for(;;) { divide_qr(m.get_mp(), k.get_mp(), q.get_mp(), r.get_mp()); if (!r.get_mp().is_zero()) break; From 4ede33059ba96e5eb304165f157e3bdba32b410c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 14 Oct 2021 15:14:38 +0200 Subject: [PATCH 014/139] add a switch for the gmp backend --- CGAL_Core/include/CGAL/CORE/BigInt.h | 4 ++++ CGAL_Core/include/CGAL/CORE/BigRat.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 2a35194c519e..af0ebf0602f6 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -32,7 +32,11 @@ namespace CORE { +#ifdef CGAL_CORE_USE_GMP_BACKEND + typedef boost::multiprecision::mpz_int Z; +#else typedef boost::multiprecision::cpp_int Z; +#endif diff --git a/CGAL_Core/include/CGAL/CORE/BigRat.h b/CGAL_Core/include/CGAL/CORE/BigRat.h index ec9c12c3184e..1cab0679018f 100644 --- a/CGAL_Core/include/CGAL/CORE/BigRat.h +++ b/CGAL_Core/include/CGAL/CORE/BigRat.h @@ -29,7 +29,11 @@ namespace CORE { +#ifdef CGAL_CORE_USE_GMP_BACKEND + typedef boost::multiprecision::mpq_rational Q; +#else typedef boost::multiprecision::cpp_rational Q; +#endif class BigRatRep : public RCRepImpl { public: From 65b10f226a76723fee1bd4f6abb89f5f53965c40 Mon Sep 17 00:00:00 2001 From: Sebastien Loriot Date: Wed, 1 Jun 2022 20:16:45 +0200 Subject: [PATCH 015/139] fix function Co-authored-by: Marc Glisse --- CGAL_Core/include/CGAL/CORE/BigInt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index af0ebf0602f6..c20ed181b72f 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -449,7 +449,7 @@ inline void negate(BigInt& a) { /// cmpabs inline int cmpabs(const BigInt& a, const BigInt& b) { assert(false); - // return mpz_cmpabs(a.get_mp(), b.get_mp()); AF: todo + return cmp(abs(a), abs(b)); return 0; } From ee0ec71857a4a10bfee04c05829c9ea3bf30e26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 2 Jun 2022 15:55:57 +0200 Subject: [PATCH 016/139] add a template version of the constructor --- CGAL_Core/include/CGAL/CORE/BigInt.h | 42 ++-------------------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index c20ed181b72f..d88cee258954 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -46,51 +46,15 @@ namespace CORE { : mp() {} - // Note : should the copy-ctor be allowed at all ? [Sylvain Pion] - BigIntRep(const BigIntRep& z) : RCRepImpl(), mp(z.mp) - {} - - BigIntRep(signed char c) - : mp(c) + BigIntRep(const BigIntRep& z) : RCRepImpl(), mp(z.mp) {} - BigIntRep(unsigned char c) + template + BigIntRep(T c) : mp(c) {} - BigIntRep(signed int i) - : mp(i) - {} - - BigIntRep(unsigned int i) - : mp(i) - {} - - - BigIntRep(signed short int s) - : mp(s) - {} - BigIntRep(unsigned short int s) - : mp(s) - {} - - BigIntRep(signed long int l) - : mp(l) - {} - - BigIntRep(unsigned long int l) - : mp(l) - {} - - BigIntRep(float f) - : mp(f) - {} - - BigIntRep(double d) - : mp(d) - {} - BigIntRep(const char* s, int base=0) : mp(s) {} From 32e89c1b91dbe2b61f46a41279257d9b2d7530c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 2 Jun 2022 15:56:08 +0200 Subject: [PATCH 017/139] add assertions --- CGAL_Core/include/CGAL/CORE/BigInt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index d88cee258954..44be47eeb1c3 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -57,7 +57,7 @@ namespace CORE { BigIntRep(const char* s, int base=0) : mp(s) - {} + { assert(base == 0); } BigIntRep(const std::string& s, int base=0) : mp(s) @@ -412,7 +412,6 @@ inline void negate(BigInt& a) { /// cmpabs inline int cmpabs(const BigInt& a, const BigInt& b) { - assert(false); return cmp(abs(a), abs(b)); return 0; } @@ -502,6 +501,7 @@ inline void divexact(BigInt& z, const BigInt& x, const BigInt& y) { z.makeCopy(); BigInt r; divide_qr(x.get_mp(), y.get_mp(), z.get_mp(), r.get_mp() ); // was void mpz_divexact (mpz_t q, const mpz_t n, const mpz_t d) Is this faster? + assert(r.get_mp().is_zero()); } // Chee (1/12/2004) The definition of div_exact(x,y) next From 6fa89d7cdcf71785c7be27af8331f537692600d1 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 6 Jun 2022 08:43:53 +0100 Subject: [PATCH 018/139] Change minimum version number of boost --- Documentation/doc/Documentation/Third_party.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/doc/Documentation/Third_party.txt b/Documentation/doc/Documentation/Third_party.txt index e563c92a416a..394f39d12f11 100644 --- a/Documentation/doc/Documentation/Third_party.txt +++ b/Documentation/doc/Documentation/Third_party.txt @@ -56,7 +56,7 @@ or `h The \stl comes with the compiler, and as such no installation is required. \subsection thirdpartyBoost Boost -Version 1.66 or later +Version 1.70 or later The \boost libraries are a set of portable C++ source libraries. Most of \boost libraries are header-only, but a few of them need to be compiled or @@ -72,7 +72,7 @@ from `htt As there is no canonical directory for where to find \boost on Windows, we recommend that you define the environment variable -`BOOST_ROOT` and set it to where you have installed \boost, e.g., `C:\boost\boost_1_69_0`. +`BOOST_ROOT` and set it to where you have installed \boost, e.g., `C:\boost\boost_1_70_0`. \subsection thirdpartyMPFR GNU Multiple Precision Arithmetic (GMP) and GNU Multiple Precision Floating-Point Reliably (MPFR) Libraries GMP Version 4.2 or later, MPFR Version 2.2.1 or later From 2e3f44abb93768b5dd0b258b73514e4bd61d15fe Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 6 Jun 2022 11:39:47 +0100 Subject: [PATCH 019/139] Require in CMake a recent boost when using CORE. --- Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake b/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake index 3387eae26c84..c4aa62e4f428 100644 --- a/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake +++ b/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake @@ -54,6 +54,7 @@ endif() # function(CGAL_setup_CGAL_Core_dependencies target) + find_package( Boost 1.70 REQUIRED ) use_CGAL_GMP_support(CGAL_Core INTERFACE) target_compile_definitions(${target} INTERFACE CGAL_USE_CORE=1) target_link_libraries( CGAL_Core INTERFACE CGAL::CGAL ) From e98692d8b8e061e774bec88b1ded11f200a4b6b4 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 25 Oct 2022 15:32:26 +0100 Subject: [PATCH 020/139] WIP: Replace CORE::BigInt and BigRat with the boost::mp classes. Just typedef --- .../include/CGAL/CORE_arithmetic_kernel.h | 5 +- CGAL_Core/include/CGAL/CORE/BigFloat.h | 16 +- CGAL_Core/include/CGAL/CORE/BigFloat_impl.h | 2 +- CGAL_Core/include/CGAL/CORE/BigInt.h | 199 ++++++++++++++++-- CGAL_Core/include/CGAL/CORE/BigRat.h | 34 ++- CGAL_Core/include/CGAL/CORE/CoreIO_impl.h | 3 +- CGAL_Core/include/CGAL/CORE/Promote.h | 6 +- CGAL_Core/include/CGAL/CORE/Real.h | 8 +- CGAL_Core/include/CGAL/CORE/RealRep.h | 10 +- Number_types/include/CGAL/CORE_BigFloat.h | 6 +- Number_types/include/CGAL/CORE_BigInt.h | 4 +- Number_types/include/CGAL/CORE_BigRat.h | 5 +- .../include/CGAL/CORE_coercion_traits.h | 19 +- Number_types/include/CGAL/boost_mp.h | 18 ++ .../test/Number_types/CORE_BigInt.cpp | 1 + .../test/Number_types/CORE_BigRat.cpp | 8 +- 16 files changed, 294 insertions(+), 50 deletions(-) diff --git a/Arithmetic_kernel/include/CGAL/CORE_arithmetic_kernel.h b/Arithmetic_kernel/include/CGAL/CORE_arithmetic_kernel.h index 5df573c77de3..3fc908252acb 100644 --- a/Arithmetic_kernel/include/CGAL/CORE_arithmetic_kernel.h +++ b/Arithmetic_kernel/include/CGAL/CORE_arithmetic_kernel.h @@ -54,7 +54,7 @@ class CORE_arithmetic_kernel : public internal::Arithmetic_kernel_base { }; - +#if 0 template <> struct Get_arithmetic_kernel{ typedef CORE_arithmetic_kernel Arithmetic_kernel; @@ -63,6 +63,8 @@ template <> struct Get_arithmetic_kernel{ typedef CORE_arithmetic_kernel Arithmetic_kernel; }; +#endif + template <> struct Get_arithmetic_kernel{ typedef CORE_arithmetic_kernel Arithmetic_kernel; @@ -74,6 +76,7 @@ struct Get_arithmetic_kernel{ } //namespace CGAL + #endif // CGAL_USE_CORE #endif // CGAL_CORE_ARITHMETIC_KERNEL_H diff --git a/CGAL_Core/include/CGAL/CORE/BigFloat.h b/CGAL_Core/include/CGAL/CORE/BigFloat.h index 97183f63e508..c5df8cb8134d 100644 --- a/CGAL_Core/include/CGAL/CORE/BigFloat.h +++ b/CGAL_Core/include/CGAL/CORE/BigFloat.h @@ -59,7 +59,7 @@ class CGAL_CORE_EXPORT BigFloat : public RCBigFloat { /// constructor for const char* (default base = 10) BigFloat(const char* s) : RCBigFloat(new BigFloatRep(s)) {} /// constructor for std::string(default base = 10) - BigFloat(const std::string& s) : RCBigFloat(new BigFloatRep(s)) {} + BigFloat(const std::string& s) : RCBigFloat(new BigFloatRep(s.c_str())) {} /// constructor for int and long // This is a hack because in Sturm, we need to approximate any @@ -614,11 +614,23 @@ inline BigFloat gcd(const BigFloat& a, const BigFloat& b) { //mpz_tdiv_qr(q.get_mp(), r.get_mp(), a.get_mp(), b.get_mp()); //}// - +/* AF // constructor BigRat from BigFloat inline BigRat::BigRat(const BigFloat& f) : RCBigRat(new BigRatRep()){ *this = f.BigRatValue(); } +*/ + + double doubleValue(const BigFloat& bf) + { + return bf.doubleValue(); + } + + long longValue(const BigFloat& bf) + { + return bf.longValue(); + } + } //namespace CORE #ifdef CGAL_HEADER_ONLY diff --git a/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h b/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h index 4663d7d9251d..3230bc8a1ab6 100644 --- a/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h +++ b/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h @@ -870,7 +870,7 @@ BigFloatRep::toDecimal(unsigned int width, bool Scientific) const { M <<= e2; // M = x * 2^(e2) } - std::string decRep = M.get_str(); + std::string decRep = M.convert_to(); // Determine the "significant part" of this string, i.e. the part which // is guaranteed to be correct in the presence of error, // except that the last digit which might be subject to +/- 1. diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 44be47eeb1c3..02e0645c4c25 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -30,6 +30,176 @@ #include #include +#if 1 + +namespace CORE { + +#ifdef CGAL_CORE_USE_GMP_BACKEND + typedef boost::multiprecision::mpz_int BigInt; +#else + typedef boost::multiprecision::cpp_int BigInt; +#endif + + +inline int cmp(const BigInt& x, const BigInt& y) { + return x.compare(y); +} + + + int set_str(BigInt& a, const char* s) { + // AF makeCopy(); + a = BigInt(s); + return 0; // should be -1 if not correct in the base (we ignore) + } + + /// longValue +inline long longValue(const BigInt& a) { + return a.convert_to();; +} + + /// doubleValue +inline double doubleValue(const BigInt& a) { + return a.convert_to();; +} + + /// isEven +inline bool isEven(const BigInt& z) { + return bit_test(z,0) == 0; +} +/// isOdd +inline bool isOdd(const BigInt& z) { + return bit_test(z,0) == 1; +} + + inline bool isDivisible(const BigInt& x, const BigInt& y) { + BigInt q, r; + divide_qr(x, y, q, r); + return r.is_zero(); +} + +inline bool isDivisible(int x, int y) { + return x % y == 0; +} + +inline bool isDivisible(long x, long y) { + return x % y == 0; + +} + /// get exponent of power 2 +inline unsigned long getBinExpo(const BigInt& z) { + if (z.is_zero()) { + return (std::numeric_limits::max)(); + } + return lsb(abs(z)); +} + + // bit length +inline int bitLength(const BigInt& a) { + if (a.is_zero()) { + return 0; + } + return msb(abs(a))+1; +} + +/// floorLg -- floor of log_2(a) +/** Convention: a=0, floorLg(a) returns -1. + * This makes sense for integer a. + */ +inline long floorLg(const BigInt& a) { + return (sign(a) == 0) ? (-1) : (bitLength(a)-1); +} + + +/// div_rem +inline void div_rem(BigInt& q, BigInt& r, const BigInt& a, const BigInt& b) { + // AF q.makeCopy(); + // AF r.makeCopy(); + divide_qr(a, b, q, r); +} + + + /// ulongValue +inline unsigned long ulongValue(const BigInt& a) { + assert(a >= BigInt(0)); + return a.convert_to(); +} + + /// exact div +inline void divexact(BigInt& z, const BigInt& x, const BigInt& y) { + // AF z.makeCopy(); + BigInt r; + divide_qr(x, y, z, r ); // was void mpz_divexact (mpz_t q, const mpz_t n, const mpz_t d) Is this faster? + assert(r.is_zero()); +} + +// Chee (1/12/2004) The definition of div_exact(x,y) next +// ensure that in Polynomials works with both NT=BigInt and NT=int: +inline BigInt div_exact(const BigInt& x, const BigInt& y) { + BigInt z; // precodition: isDivisible(x,y) + divexact(z, x, y); // z is set to x/y; + return z; +} + +inline int div_exact(int x, int y) { + return x/y; // precondition: isDivisible(x,y) +} + +inline long div_exact(long x, long y) { + return x/y; // precondition: isDivisible(x,y) +} + + +/// ceilLg -- ceiling of log_2(a) where a=BigInt, int or long +/** Convention: a=0, ceilLg(a) returns -1. + * This makes sense for integer a. + */ +inline long ceilLg(const BigInt& a) { + if (sign(a) == 0) + return -1; + unsigned long len = bitLength(a); + + return (lsb(abs(a)) == len - 1) ? (len - 1) : len; +} + +inline long ceilLg(long a) { // need this for Polynomial + return ceilLg(BigInt(a)); +} + +inline long ceilLg(int a) { // need this for Polynomial + return ceilLg(BigInt(a)); +} + + +/// negate +inline void negate(BigInt& a) { + // AF a.makeCopy(); + a= - a; +} + +/// get exponent of power k +inline void getKaryExpo(const BigInt& z, BigInt& m, int& e, unsigned long uk) { + BigInt k(uk), q, r; + e = 0; + m = z; + // AF m.makeCopy(); + for(;;) { + divide_qr(m, k, q, r); + if (!r.is_zero()) break; + m = q; + ++e; + } +} + + inline void power(BigInt& c, const BigInt& a, unsigned long ul) { + // AF c.makeCopy(); + c = pow(a, ul); +} + +} // namespace CORE + +#else + + namespace CORE { #ifdef CGAL_CORE_USE_GMP_BACKEND @@ -55,11 +225,7 @@ namespace CORE { : mp(c) {} - BigIntRep(const char* s, int base=0) - : mp(s) - { assert(base == 0); } - - BigIntRep(const std::string& s, int base=0) + BigIntRep(const std::string& s) : mp(s) {} @@ -118,10 +284,9 @@ class CGAL_CORE_EXPORT BigInt : public RCImpl { BigInt(float x) : RCBigInt(new BigIntRep(x)) {} /// constructor for double BigInt(double x) : RCBigInt(new BigIntRep(x)) {} - /// constructor for const char* with base - BigInt(const char* s, int base=0) : RCBigInt(new BigIntRep(s, base)) {} - /// constructor for std::string with base - BigInt(const std::string& s, int base=0) : RCBigInt(new BigIntRep(s, base)) {} + + /// constructor for std::string + BigInt(const std::string& s) : RCBigInt(new BigIntRep(s)) {} /// constructor for mpz_srcptr // explicit BigInt(mpz_srcptr z) : RCBigInt(new BigIntRep(z)) {} @@ -254,13 +419,13 @@ class CGAL_CORE_EXPORT BigInt : public RCImpl { /// \name String Conversion Functions //@{ /// set value from const char* - int set_str(const char* s, int base = 0) { + int set_str(const char* s) { makeCopy(); get_mp() = Z(s); return 0; // should be -1 if not correct in the base (we ignore) } /// convert to std::string - std::string get_str(int base = 10) const { + std::string get_str() const { return get_mp().convert_to(); } //@} @@ -443,7 +608,7 @@ inline double doubleValue(const BigInt& a) { void readFromFile(BigInt& z, std::istream& in, long maxLength = 0); /// write to file -void writeToFile(const BigInt& z, std::ostream& in, int base=10, int charsPerLine=80); +void writeToFile(const BigInt& z, std::ostream& in, int charsPerLine=80); //@} */ @@ -483,8 +648,8 @@ inline void getKaryExpo(const BigInt& z, BigInt& m, int& e, unsigned long uk) { /// divisible(x,y) = "x | y" inline bool isDivisible(const BigInt& x, const BigInt& y) { - BigInt z, r; - divide_qr(x.get_mp(), y.get_mp(), z.get_mp(), r.get_mp()); + BigInt q, r; + divide_qr(x.get_mp(), y.get_mp(), q.get_mp(), r.get_mp()); return r.get_mp().is_zero(); } @@ -538,7 +703,7 @@ inline void div_rem(BigInt& q, BigInt& r, const BigInt& a, const BigInt& b) { /// power inline void power(BigInt& c, const BigInt& a, unsigned long ul) { c.makeCopy(); - c.get_mp() = pow(a.get_mp(), ul); + //c.get_mp() = pow(a.get_mp(), ul); } // pow @@ -553,7 +718,7 @@ inline int bitLength(const BigInt& a) { if (a.get_mp().is_zero()) { return 0; } - return msb(abs(a.get_mp()))+1; /// AF todo was mpz_sizeinbase(a.get_mp(), 2); + return msb(abs(a.get_mp()))+1; } /// floorLg -- floor of log_2(a) @@ -590,4 +755,6 @@ inline long ceilLg(int a) { // need this for Polynomial } //namespace CORE +#endif + #endif // _CORE_BIGINT_H_ diff --git a/CGAL_Core/include/CGAL/CORE/BigRat.h b/CGAL_Core/include/CGAL/CORE/BigRat.h index 1cab0679018f..cd4747303d96 100644 --- a/CGAL_Core/include/CGAL/CORE/BigRat.h +++ b/CGAL_Core/include/CGAL/CORE/BigRat.h @@ -27,6 +27,26 @@ #include +#if 1 +namespace CORE { +#ifdef CGAL_CORE_USE_GMP_BACKEND + typedef boost::multiprecision::mpq_rational BigRat; +#else + typedef boost::multiprecision::cpp_rational BigRat; +#endif + + + /// BigIntValue + BigInt BigIntValue(const BigRat& br) { + BigInt r, rem; + divide_qr(numerator(br), denominator(br), r, rem); + return r; + } + +} // namespace CORE + +#else + namespace CORE { #ifdef CGAL_CORE_USE_GMP_BACKEND @@ -203,6 +223,8 @@ class BigRat : public RCBigRat { get_mp() /= rhs.get_mp(); return *this; } + + /* BigRat& operator <<=(unsigned long ul) { makeCopy(); assert(false); @@ -215,6 +237,7 @@ class BigRat : public RCBigRat { // AF no >> for Q get_mp() >>= ul; return *this; } + */ //@} /// \name div2, unary, increment, decrement operators @@ -259,11 +282,15 @@ class BigRat : public RCBigRat { /// \name Helper Functions //@{ /// Canonicalize + + /* void canonicalize() { makeCopy(); assert(false); // AF todo mpq_canonicalize(get_mp()); } + */ + /// Has Exact Division static bool hasExactDivision() { return true; @@ -398,6 +425,8 @@ inline bool isDivisible(const BigRat& x, const BigRat& y) { r.get_mp() = x.get_mp() / y.get_mp(); return isInteger(r); } + + /* inline BigRat operator<<(const BigRat& a, unsigned long ul) { BigRat r; assert(false); @@ -410,7 +439,7 @@ inline BigRat operator>>(const BigRat& a, unsigned long ul) { // AF todo no >> for Q r.get_mp() = a.get_mp() >> ul; return r; } - + */ inline int cmp(const BigRat& x, const BigRat& y) { return x.get_mp().compare(y.get_mp()); } @@ -477,4 +506,7 @@ inline BigInt BigIntValue(const BigRat& a) { } //namespace CORE + +#endif + #endif // _CORE_BIGRAT_H_ diff --git a/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h b/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h index de0f59831a8b..df803aee9b8e 100644 --- a/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h +++ b/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h @@ -164,6 +164,7 @@ void read_base_number(std::istream& in, BigInt& m, long length, long maxBits) { // read base and compute digits if (c == '0') { + assert(false); // no longer supported in.get(c); if (c == 'b') { base = 2; @@ -202,7 +203,7 @@ void read_base_number(std::istream& in, BigInt& m, long length, long maxBits) { append_char(buffer, size, pos, '\0'); // convert string to bigint. - if (m.set_str(buffer, base) < 0) + if (set_str(m, buffer) < 0) core_io_error_handler("CoreIO::read_from_file()","bad big number format."); delete[] buffer; diff --git a/CGAL_Core/include/CGAL/CORE/Promote.h b/CGAL_Core/include/CGAL/CORE/Promote.h index 62a98e434efe..d4c95c25bf08 100644 --- a/CGAL_Core/include/CGAL/CORE/Promote.h +++ b/CGAL_Core/include/CGAL/CORE/Promote.h @@ -30,6 +30,8 @@ #define __PROMOTE_H__ #include +#include +#include namespace CORE { @@ -119,9 +121,9 @@ class Promotion { * */ -class BigInt; +//class BigInt; class BigFloat; -class BigRat; +//class BigRat; class Expr; DEFINE_MAX_TYPE(long, BigInt, BigInt) diff --git a/CGAL_Core/include/CGAL/CORE/Real.h b/CGAL_Core/include/CGAL/CORE/Real.h index b79503eb4c22..78a094adcfaf 100644 --- a/CGAL_Core/include/CGAL/CORE/Real.h +++ b/CGAL_Core/include/CGAL/CORE/Real.h @@ -277,7 +277,7 @@ const long halfLongMin = LONG_MIN /2; struct _real_add { template static Real eval(const T& a, const T& b) { - return a+b; + return T(a+b); } // specialized for two long values static Real eval(long a, long b) { @@ -291,7 +291,7 @@ struct _real_add { struct _real_sub { template static Real eval(const T& a, const T& b) { - return a-b; + return T(a-b); } // specialized for two long values static Real eval(long a, long b) { @@ -305,7 +305,7 @@ struct _real_sub { struct _real_mul { template static Real eval(const T& a, const T& b) { - return a*b; + return T(a*b); } // specialized for two long values static Real eval(long a, long b) { @@ -478,7 +478,7 @@ inline Real sqrt(const Real& x) { // unary minus operator template inline Real Realbase_for::operator-() const { - return -ker; + return -T(ker); } template <> inline Real RealLong::operator-() const { diff --git a/CGAL_Core/include/CGAL/CORE/RealRep.h b/CGAL_Core/include/CGAL/CORE/RealRep.h index 5a18d2748d13..6513a5693e17 100644 --- a/CGAL_Core/include/CGAL/CORE/RealRep.h +++ b/CGAL_Core/include/CGAL/CORE/RealRep.h @@ -92,10 +92,10 @@ class Realbase_for : public RealRep { int ID() const; long longValue() const { - return ker.longValue(); + return CORE::longValue(ker); } double doubleValue() const { - return ker.doubleValue(); + return CORE::doubleValue(ker); } BigInt BigIntValue() const { return BigInt(ker); @@ -231,7 +231,7 @@ inline BigInt RealBigInt::BigIntValue() const { } template<> inline BigInt RealBigRat::BigIntValue() const { - return ker.BigIntValue(); + return CORE::BigIntValue(ker); } template<> inline BigInt RealBigFloat::BigIntValue() const { @@ -500,11 +500,11 @@ inline unsigned long RealBigRat::height() const { // toString() template<> inline std::string RealBigInt::toString(long, bool) const { - return ker.get_str(); + return ker.convert_to(); } template<> inline std::string RealBigRat::toString(long, bool) const { - return ker.get_str(); + return ker.convert_to(); } template<> inline std::string RealBigFloat::toString(long prec, bool sci) const { diff --git a/Number_types/include/CGAL/CORE_BigFloat.h b/Number_types/include/CGAL/CORE_BigFloat.h index 812036e3aa60..11934a244b97 100644 --- a/Number_types/include/CGAL/CORE_BigFloat.h +++ b/Number_types/include/CGAL/CORE_BigFloat.h @@ -181,10 +181,12 @@ class Interval_traits if(::CORE::bitLength(err.m()+err.err()) >= digits_long){ long shift = ::CORE::bitLength(err.m()) - digits_long + 1 ; //std::cout << "shift " << shift<< std::endl; - long new_err = ((err.m()+err.err()) >> shift).longValue()+1; + CORE::BigInt bi = (err.m() + err.err()); + bi = bi >> shift; + long new_err = CORE::longValue(bi)+1; err = CORE::BigFloat(0,new_err,0) * CORE::BigFloat::exp2(err.exp()*CORE::CHUNK_BIT+shift); }else{ - err = CORE::BigFloat(0,err.m().longValue()+err.err(),err.exp()); + err = CORE::BigFloat(0, CORE::longValue(err.m())+err.err(),err.exp()); } //print_bf(err,"new_err"); diff --git a/Number_types/include/CGAL/CORE_BigInt.h b/Number_types/include/CGAL/CORE_BigInt.h index bdeaddd10e12..d9d2b09f6bbb 100644 --- a/Number_types/include/CGAL/CORE_BigInt.h +++ b/Number_types/include/CGAL/CORE_BigInt.h @@ -10,7 +10,6 @@ // // Author(s) : Michael Hemmer - #ifndef CGAL_CORE_BIGINT_H #define CGAL_CORE_BIGINT_H @@ -24,6 +23,8 @@ #include #include +#if 0 + namespace CGAL { // @@ -215,6 +216,7 @@ namespace Eigen { }; }; } +#endif #include diff --git a/Number_types/include/CGAL/CORE_BigRat.h b/Number_types/include/CGAL/CORE_BigRat.h index caf9b73886ed..c69b610673e7 100644 --- a/Number_types/include/CGAL/CORE_BigRat.h +++ b/Number_types/include/CGAL/CORE_BigRat.h @@ -10,7 +10,6 @@ // // Author(s) : Michael Hemmer - #ifndef CGAL_CORE_BIGRAT_H #define CGAL_CORE_BIGRAT_H @@ -21,6 +20,8 @@ #include #include // used for To_interval-functor +#if 0 + //#if defined(CGAL_CORE_BIGRAT_NUMER_DENOM_ARE_MEMBERS) // #define CGAL_CORE_NUMERATOR(X) ((X).numerator()) // #define CGAL_CORE_DENOMINATOR(X) ((X).denominator()) @@ -252,6 +253,8 @@ namespace Eigen { }; } +#endif + #include #endif // CGAL_CORE_BIGRAT_H diff --git a/Number_types/include/CGAL/CORE_coercion_traits.h b/Number_types/include/CGAL/CORE_coercion_traits.h index 3a7151ef8615..2623cd09cfd2 100644 --- a/Number_types/include/CGAL/CORE_coercion_traits.h +++ b/Number_types/include/CGAL/CORE_coercion_traits.h @@ -24,13 +24,12 @@ #include -//#include namespace CGAL { //CORE internal coercions: - +#if 0 // The following definitions reflect the interaction of the CORE number types // with the built in types, // CORE BigInt: @@ -46,7 +45,7 @@ namespace CGAL { CGAL_DEFINE_COERCION_TRAITS_FROM_TO(float ,::CORE::BigRat) CGAL_DEFINE_COERCION_TRAITS_FROM_TO(double ,::CORE::BigRat) CGAL_DEFINE_COERCION_TRAITS_FROM_TO(::CORE::BigInt,::CORE::BigRat) - +#endif // CORE Expr: CGAL_DEFINE_COERCION_TRAITS_FROM_TO(short ,::CORE::Expr) CGAL_DEFINE_COERCION_TRAITS_FROM_TO(int ,::CORE::Expr) @@ -78,8 +77,8 @@ struct Coercion_traits{ CORE::BigFloat result; result.approx(x,CORE::get_static_defRelPrec().toLong(),LONG_MAX); // Do not use MakeFloorExact as it changes the Bigfloat - CGAL_postcondition( ::CORE::BigRat(::CORE::BigFloat(result.m()-result.err(),0,result.exp())) <= x ); - CGAL_postcondition( ::CORE::BigRat(::CORE::BigFloat(result.m()+result.err(),0,result.exp())) >= x ); + // AF CGAL_postcondition( ::CORE::BigRat(::CORE::BigFloat(result.m()-result.err(),0,result.exp())) <= x ); + // AF CGAL_postcondition( ::CORE::BigRat(::CORE::BigFloat(result.m()+result.err(),0,result.exp())) >= x ); return result; } }; @@ -98,8 +97,8 @@ struct Coercion_traits{ CORE::BigFloat result(x,CORE::get_static_defRelPrec().toLong(),LONG_MAX); // Do not use MakeFloorExact as it changes the Bigfloat - CGAL_postcondition( ::CORE::BigRat(::CORE::BigFloat(result.m()-result.err(),0,result.exp())) <= x ); - CGAL_postcondition( ::CORE::BigRat(::CORE::BigFloat(result.m()+result.err(),0,result.exp())) >= x ); + // AF CGAL_postcondition( ::CORE::BigRat(::CORE::BigFloat(result.m()-result.err(),0,result.exp())) <= x ); + // AF CGAL_postcondition( ::CORE::BigRat(::CORE::BigFloat(result.m()+result.err(),0,result.exp())) >= x ); return result; } }; @@ -117,8 +116,8 @@ struct Coercion_traits{ Type operator()(const ::CORE::Expr x) const { CORE::BigFloat result(x, CORE::get_static_defRelPrec().toLong(),LONG_MAX); // Do not use MakeFloorExact as it changes the Bigfloat - CGAL_postcondition( ::CORE::BigRat(::CORE::BigFloat(result.m()-result.err(),0,result.exp())) <= x ); - CGAL_postcondition( ::CORE::BigRat(::CORE::BigFloat(result.m()+result.err(),0,result.exp())) >= x ); + // AF CGAL_postcondition( ::CORE::BigRat(::CORE::BigFloat(result.m()-result.err(),0,result.exp())) <= x ); + // AF CGAL_postcondition( ::CORE::BigRat(::CORE::BigFloat(result.m()+result.err(),0,result.exp())) >= x ); return result; } }; @@ -150,6 +149,8 @@ template <> struct Coercion_traits< ::CORE::Expr, CORE::BigFloat > } //namespace CGAL + + #endif // CGAL_USE_CORE #endif //CGAL_CORE_COERCION_TRAITS_H 1 //EOF diff --git a/Number_types/include/CGAL/boost_mp.h b/Number_types/include/CGAL/boost_mp.h index 340e423ad67c..d8bb53bf243c 100644 --- a/Number_types/include/CGAL/boost_mp.h +++ b/Number_types/include/CGAL/boost_mp.h @@ -57,6 +57,24 @@ // TODO: work on the coercions (end of the file) namespace CGAL { +template<> +struct Needs_parens_as_product{ + bool operator()(const typename boost::multiprecision::cpp_int& x){ + return x < 0; + } +}; + +template<> +struct Needs_parens_as_product{ + bool operator()(const typename boost::multiprecision::cpp_rational& x){ + if (denominator(x) != 1 ) + return true; + else + return needs_parens_as_product(numerator(x)) ; + } + +}; + // Algebraic_structure_traits diff --git a/Number_types/test/Number_types/CORE_BigInt.cpp b/Number_types/test/Number_types/CORE_BigInt.cpp index 8cfe816f0439..d02fbb87f26a 100644 --- a/Number_types/test/Number_types/CORE_BigInt.cpp +++ b/Number_types/test/Number_types/CORE_BigInt.cpp @@ -33,6 +33,7 @@ void test_io(){ std::stringstream ss; CGAL::IO::set_pretty_mode(ss); ss << CGAL::IO::oformat(NT(1), CGAL::Parens_as_product_tag()); + std::cout << ss.str() << std::endl; assert( ss.str() == "1"); }{ std::stringstream ss; diff --git a/Number_types/test/Number_types/CORE_BigRat.cpp b/Number_types/test/Number_types/CORE_BigRat.cpp index 60124ec0277e..670791cb0116 100644 --- a/Number_types/test/Number_types/CORE_BigRat.cpp +++ b/Number_types/test/Number_types/CORE_BigRat.cpp @@ -19,18 +19,18 @@ void test_io(){ std::stringstream ss; CGAL::IO::set_ascii_mode(ss); ss << CGAL::IO::oformat(NT(1)); - //std::cout << ss.str()< Date: Tue, 25 Oct 2022 15:36:46 +0100 Subject: [PATCH 021/139] trailing whitespace --- Number_types/include/CGAL/CORE_coercion_traits.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Number_types/include/CGAL/CORE_coercion_traits.h b/Number_types/include/CGAL/CORE_coercion_traits.h index 2623cd09cfd2..b48c9710eeca 100644 --- a/Number_types/include/CGAL/CORE_coercion_traits.h +++ b/Number_types/include/CGAL/CORE_coercion_traits.h @@ -45,7 +45,7 @@ namespace CGAL { CGAL_DEFINE_COERCION_TRAITS_FROM_TO(float ,::CORE::BigRat) CGAL_DEFINE_COERCION_TRAITS_FROM_TO(double ,::CORE::BigRat) CGAL_DEFINE_COERCION_TRAITS_FROM_TO(::CORE::BigInt,::CORE::BigRat) -#endif +#endif // CORE Expr: CGAL_DEFINE_COERCION_TRAITS_FROM_TO(short ,::CORE::Expr) CGAL_DEFINE_COERCION_TRAITS_FROM_TO(int ,::CORE::Expr) From 0fdc4e8582dcb80c60229e47976c83fa3f9ac883 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 26 Oct 2022 14:18:36 +0100 Subject: [PATCH 022/139] Add Eigen::Num_traits specializations --- Number_types/include/CGAL/boost_mp.h | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/Number_types/include/CGAL/boost_mp.h b/Number_types/include/CGAL/boost_mp.h index d8bb53bf243c..11822a39f2b5 100644 --- a/Number_types/include/CGAL/boost_mp.h +++ b/Number_types/include/CGAL/boost_mp.h @@ -914,6 +914,53 @@ template< > class Real_embeddable_traits< Quotient struct NumTraits; + template<> struct NumTraits + { + typedef boost::multiprecision::cpp_int Real; + typedef boost::multiprecision::cpp_rational NonInteger; + typedef boost::multiprecision::cpp_int Nested; + typedef boost::multiprecision::cpp_int Literal; + + static inline Real epsilon() { return 0; } + static inline Real dummy_precision() { return 0; } + + enum { + IsInteger = 1, + IsSigned = 1, + IsComplex = 0, + RequireInitialization = 1, + ReadCost = 6, + AddCost = 30, + MulCost = 50 + }; + }; + + template<> struct NumTraits + { + typedef boost::multiprecision::cpp_rational Real; + typedef boost::multiprecision::cpp_rational NonInteger; + typedef boost::multiprecision::cpp_rational Nested; + typedef boost::multiprecision::cpp_rational Literal; + + static inline Real epsilon() { return 0; } + static inline Real dummy_precision() { return 0; } + + enum { + IsInteger = 0, + IsSigned = 1, + IsComplex = 0, + RequireInitialization = 1, + ReadCost = 6, + AddCost = 150, + MulCost = 100 + }; + }; +} + +} // namespace Eigen + #include #endif // BOOST_VERSION From 7667782cab575124f57b69952781f007cfba66a3 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 26 Oct 2022 15:33:03 +0100 Subject: [PATCH 023/139] typo --- Number_types/include/CGAL/boost_mp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Number_types/include/CGAL/boost_mp.h b/Number_types/include/CGAL/boost_mp.h index 11822a39f2b5..6e086d8f16ea 100644 --- a/Number_types/include/CGAL/boost_mp.h +++ b/Number_types/include/CGAL/boost_mp.h @@ -957,7 +957,7 @@ namespace Eigen { MulCost = 100 }; }; -} + } // namespace Eigen From 03ae1c466a1117487c4b99c35e206d40b4020565 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 26 Oct 2022 16:41:34 +0100 Subject: [PATCH 024/139] Add specialization for GMP backend --- Number_types/include/CGAL/boost_mp.h | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/Number_types/include/CGAL/boost_mp.h b/Number_types/include/CGAL/boost_mp.h index 6e086d8f16ea..9aadd5dfc1ec 100644 --- a/Number_types/include/CGAL/boost_mp.h +++ b/Number_types/include/CGAL/boost_mp.h @@ -958,6 +958,51 @@ namespace Eigen { }; }; +#ifdef CGAL_USE_GMP + + template<> struct NumTraits + { + typedef boost::multiprecision::mpz_int Real; + typedef boost::multiprecision::mpq_rational NonInteger; + typedef boost::multiprecision::mpz_int Nested; + typedef boost::multiprecision::mpz_int Literal; + + static inline Real epsilon() { return 0; } + static inline Real dummy_precision() { return 0; } + + enum { + IsInteger = 1, + IsSigned = 1, + IsComplex = 0, + RequireInitialization = 1, + ReadCost = 6, + AddCost = 30, + MulCost = 50 + }; + }; + + template<> struct NumTraits + { + typedef boost::multiprecision::mpq_rational Real; + typedef boost::multiprecision::mpq_rational NonInteger; + typedef boost::multiprecision::mpq_rational Nested; + typedef boost::multiprecision::mpq_rational Literal; + + static inline Real epsilon() { return 0; } + static inline Real dummy_precision() { return 0; } + + enum { + IsInteger = 0, + IsSigned = 1, + IsComplex = 0, + RequireInitialization = 1, + ReadCost = 6, + AddCost = 150, + MulCost = 100 + }; + }; +#endif // CGAL_USE_GMP + } // namespace Eigen From af780e26be66c1db221308c026552b862cfd93a6 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 27 Oct 2022 09:13:09 +0100 Subject: [PATCH 025/139] cleaning --- .../include/CGAL/Test/_test_algebraic_structure.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/Algebraic_foundations/include/CGAL/Test/_test_algebraic_structure.h b/Algebraic_foundations/include/CGAL/Test/_test_algebraic_structure.h index e801fd9fab02..5a5e23c7d8fc 100644 --- a/Algebraic_foundations/include/CGAL/Test/_test_algebraic_structure.h +++ b/Algebraic_foundations/include/CGAL/Test/_test_algebraic_structure.h @@ -736,7 +736,6 @@ void test_Type_functions( const CGAL::Euclidean_ring_tag&) { b = AS(5); r = CGAL_NTS mod(a,b); q = CGAL_NTS div(a,b); - std::cout << r << std::endl << q << std::endl; assert( a == b*q+r); CGAL_NTS div_mod(a,b,q,r); assert( a == b*q+r); @@ -877,9 +876,7 @@ void test_algebraic_structure(){ c = b * AS (-3); assert( c == AS (-15)); c = a; - c += b; - assert( c == AS (6)); c = a; c -= b; From 27ca0dfb038711df6992017a0192e7a9970cc6fa Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 27 Oct 2022 09:35:47 +0100 Subject: [PATCH 026/139] BigInt and BigRep are no longer real CORE storage --- CGAL_Core/include/CGAL/CORE/Expr_impl.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/Expr_impl.h b/CGAL_Core/include/CGAL/CORE/Expr_impl.h index 97d9ab88b53c..d8e2b7883af9 100644 --- a/CGAL_Core/include/CGAL/CORE/Expr_impl.h +++ b/CGAL_Core/include/CGAL/CORE/Expr_impl.h @@ -1215,8 +1215,6 @@ void BinOpRep::debugTree(int level, int indent, int depthLimit) const { second->debugTree(level, indent + 2, depthLimit - 1); } -// AF CORE_MEMORY_IMPL(BigIntRep) -// AF CORE_MEMORY_IMPL(BigRatRep) CORE_MEMORY_IMPL(ConstDoubleRep) CORE_MEMORY_IMPL(ConstRealRep) From a56d1a5f4f14ef30575e6f76d7090d10e78ff810 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 27 Oct 2022 10:19:39 +0100 Subject: [PATCH 027/139] Simplify Coercion_traits --- .../include/CGAL/CORE_coercion_traits.h | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/Number_types/include/CGAL/CORE_coercion_traits.h b/Number_types/include/CGAL/CORE_coercion_traits.h index b48c9710eeca..1da49ca624b5 100644 --- a/Number_types/include/CGAL/CORE_coercion_traits.h +++ b/Number_types/include/CGAL/CORE_coercion_traits.h @@ -29,23 +29,6 @@ namespace CGAL { //CORE internal coercions: -#if 0 -// The following definitions reflect the interaction of the CORE number types -// with the built in types, -// CORE BigInt: - CGAL_DEFINE_COERCION_TRAITS_FROM_TO(short ,::CORE::BigInt) - CGAL_DEFINE_COERCION_TRAITS_FROM_TO(int ,::CORE::BigInt) - CGAL_DEFINE_COERCION_TRAITS_FROM_TO(long ,::CORE::BigInt) - - -// CORE BigRat: - CGAL_DEFINE_COERCION_TRAITS_FROM_TO(short ,::CORE::BigRat) - CGAL_DEFINE_COERCION_TRAITS_FROM_TO(int ,::CORE::BigRat) - CGAL_DEFINE_COERCION_TRAITS_FROM_TO(long ,::CORE::BigRat) - CGAL_DEFINE_COERCION_TRAITS_FROM_TO(float ,::CORE::BigRat) - CGAL_DEFINE_COERCION_TRAITS_FROM_TO(double ,::CORE::BigRat) - CGAL_DEFINE_COERCION_TRAITS_FROM_TO(::CORE::BigInt,::CORE::BigRat) -#endif // CORE Expr: CGAL_DEFINE_COERCION_TRAITS_FROM_TO(short ,::CORE::Expr) CGAL_DEFINE_COERCION_TRAITS_FROM_TO(int ,::CORE::Expr) From e82ae363b3da1460d2d2867cbb681f3dd55ab2f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 27 Oct 2022 11:39:39 +0200 Subject: [PATCH 028/139] take CORE into account in Boost mp's arithmetic kernel --- .../include/CGAL/BOOST_MP_arithmetic_kernel.h | 14 +- CGAL_Core/include/CGAL/CORE/BigInt.h | 2 +- Number_types/include/CGAL/boost_mp.h | 998 +--------------- Number_types/include/CGAL/boost_mp_type.h | 1010 +++++++++++++++++ 4 files changed, 1026 insertions(+), 998 deletions(-) create mode 100644 Number_types/include/CGAL/boost_mp_type.h diff --git a/Arithmetic_kernel/include/CGAL/BOOST_MP_arithmetic_kernel.h b/Arithmetic_kernel/include/CGAL/BOOST_MP_arithmetic_kernel.h index b1c1b1532e83..641642b32375 100644 --- a/Arithmetic_kernel/include/CGAL/BOOST_MP_arithmetic_kernel.h +++ b/Arithmetic_kernel/include/CGAL/BOOST_MP_arithmetic_kernel.h @@ -19,6 +19,9 @@ #ifdef CGAL_USE_BOOST_MP +// already protected by CGAL_USE_CORE macro +#include + //Currently already included in boost_mp.h //#include //#ifdef CGAL_USE_GMP @@ -26,20 +29,29 @@ //#endif // FIXME: the could be several kernels based on Boost.Multiprecision. - namespace CGAL { /** \ingroup CGAL_Arithmetic_kernel * \brief The Boost.Multiprecision set of exact number types */ + +#if !defined(CGAL_USE_CORE) || defined(CGAL_CORE_USE_GMP_BACKEND) struct BOOST_cpp_arithmetic_kernel : internal::Arithmetic_kernel_base { typedef boost::multiprecision::cpp_int Integer; typedef boost::multiprecision::cpp_rational Rational; }; +#else +typedef CORE_arithmetic_kernel BOOST_cpp_arithmetic_kernel; +#endif + #ifdef CGAL_USE_GMP +#if !defined(CGAL_USE_CORE) || !defined(CGAL_CORE_USE_GMP_BACKEND) struct BOOST_gmp_arithmetic_kernel : internal::Arithmetic_kernel_base { typedef boost::multiprecision::mpz_int Integer; typedef boost::multiprecision::mpq_rational Rational; }; +#else +typedef CORE_arithmetic_kernel BOOST_gmp_arithmetic_kernel; +#endif #endif template diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 02e0645c4c25..e709c7d5ef54 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -24,7 +24,7 @@ #ifndef _CORE_BIGINT_H_ #define _CORE_BIGINT_H_ -#include +#include #include #include #include diff --git a/Number_types/include/CGAL/boost_mp.h b/Number_types/include/CGAL/boost_mp.h index 9aadd5dfc1ec..1fc45cfee160 100644 --- a/Number_types/include/CGAL/boost_mp.h +++ b/Number_types/include/CGAL/boost_mp.h @@ -12,1001 +12,7 @@ #ifndef CGAL_BOOST_MP_H #define CGAL_BOOST_MP_H -#include -#include - -// It is easier to disable this number type completely for old versions. -// Before 1.63, I/O is broken. Again, disabling the whole file is just the -// easy solution. -// MSVC had trouble with versions <= 1.69: -// https://github.com/boostorg/multiprecision/issues/98 -#if !defined CGAL_DO_NOT_USE_BOOST_MP && \ - (!defined _MSC_VER || BOOST_VERSION >= 107000) -#define CGAL_USE_BOOST_MP 1 - -#include -#include // *ary_function -#include -#include -// We can't just include all Boost.Multiprecision here... -#include -#include -// ... but we kind of have to :-( -#include -#ifdef CGAL_USE_GMP -// Same dance as in CGAL/gmp.h -# include -# if defined(BOOST_MSVC) -# pragma warning(push) -# pragma warning(disable: 4127 4244 4146 4267) // conversion with loss of data - // warning on - applied on unsigned number -# endif - -# include - -# if defined(BOOST_MSVC) -# pragma warning(pop) -# endif - -# include -#endif -#ifdef CGAL_USE_MPFR -# include -#endif - -// TODO: work on the coercions (end of the file) - -namespace CGAL { -template<> -struct Needs_parens_as_product{ - bool operator()(const typename boost::multiprecision::cpp_int& x){ - return x < 0; - } -}; - -template<> -struct Needs_parens_as_product{ - bool operator()(const typename boost::multiprecision::cpp_rational& x){ - if (denominator(x) != 1 ) - return true; - else - return needs_parens_as_product(numerator(x)) ; - } - -}; - - -// Algebraic_structure_traits - -template ::value> > -struct AST_boost_mp; - -template -struct AST_boost_mp > - : Algebraic_structure_traits_base< NT, Euclidean_ring_tag > { - typedef NT Type; - typedef Euclidean_ring_tag Algebraic_category; - typedef Boolean_tag::is_exact> Is_exact; - typedef Tag_false Is_numerical_sensitive; - - struct Is_zero: public CGAL::cpp98::unary_function { - bool operator()( const Type& x) const { - return x.is_zero(); - } - }; - - struct Div: - public CGAL::cpp98::binary_function { - template - Type operator()(const T& x, const U& y) const { - return x / y; - } - }; - - struct Mod: - public CGAL::cpp98::binary_function { - template - Type operator()(const T& x, const U& y) const { - return x % y; - } - }; - - struct Gcd : public CGAL::cpp98::binary_function { - template - Type operator()(const T& x, const U& y) const { - return boost::multiprecision::gcd(x, y); - } - }; - - struct Sqrt : public CGAL::cpp98::unary_function { - template - Type operator()(const T& x) const { - return boost::multiprecision::sqrt(x); - } - }; -}; - -template -struct AST_boost_mp > - : public Algebraic_structure_traits_base< NT , Field_tag > { - public: - typedef NT Type; - typedef Field_tag Algebraic_category; - typedef Tag_true Is_exact; - typedef Tag_false Is_numerical_sensitive; - - struct Is_zero: public CGAL::cpp98::unary_function { - bool operator()( const Type& x) const { - return x.is_zero(); - } - }; - - struct Div: - public CGAL::cpp98::binary_function { - template - Type operator()(const T& x, const U& y) const { - return x / y; - } - }; -}; - -template -struct Algebraic_structure_traits > -: AST_boost_mp > {}; -template -struct Algebraic_structure_traits > -: Algebraic_structure_traits::result_type > {}; - -// Real_embeddable_traits - -namespace Boost_MP_internal { - - // here we know that `intv` contains int64 numbers such that their msb is std::numeric_limits::digits-1 - // TODO: possibly return denormals sometimes... - inline - std::pair shift_positive_interval( const std::pair& intv, const int e ) { - CGAL_assertion(intv.first > 0.0); - CGAL_assertion(intv.second > 0.0); - -#ifdef CGAL_LITTLE_ENDIAN - CGAL_assertion_code( - union { - struct { uint64_t man:52; uint64_t exp:11; uint64_t sig:1; } s; - double d; - } conv; - - conv.d = intv.first; - ) -#else - //WARNING: untested! - CGAL_assertion_code( - union { - - struct { uint64_t sig:1; uint64_t exp:11; uint64_t man:52; } s; - double d; - } conv; - - conv.d = intv.first; - ) -#endif - // Check that the exponent of intv.inf is 52, which corresponds to a 53 bit integer - CGAL_assertion(conv.s.exp - ((1 << (11 - 1)) - 1) == std::numeric_limits::digits - 1); - - typedef std::numeric_limits limits; - - // warning: min_exponent and max_exponent are 1 more than what the name suggests - if (e < limits::min_exponent - limits::digits) - return {0, (limits::min)()}; - if (e > limits::max_exponent - limits::digits) - return {(limits::max)(), limits::infinity()}; // intv is positive - - const double scale = std::ldexp(1.0, e); // ldexp call is exact - return { scale * intv.first, scale * intv.second }; // cases that would require a rounding mode have been handled above - } - - // This function checks if the computed interval is correct and if it is tight. - template - bool are_bounds_correct( const double l, const double u, const Type& x ) { - typedef std::numeric_limits limits; - - const double inf = std::numeric_limits::infinity(); - if ( u!=l && (l==-inf || u==inf - || (u==0 && l >= -(limits::min)()) - || (l==0 && u <= (limits::min)())) ) - { - return x > Type((limits::max)()) || - x < Type(-(limits::max)()) || - (x > Type(-(limits::min)()) && x < Type((limits::min)())); - } - - if (!(u == l || u == std::nextafter(l, +inf))) return false; - //TODO: Type(nextafter(l,inf))>x && Type(nextafter(u,-inf)) get_0ulp_interval( const int shift, const uint64_t p ) { - - const double pp_dbl = static_cast(p); - const std::pair intv(pp_dbl, pp_dbl); - - return shift_positive_interval(intv, -shift); - } - - // This one returns 1 unit length interval. - inline - std::pair get_1ulp_interval( const int shift, const uint64_t p ) { - - const double pp_dbl = static_cast(p); - const double qq_dbl = pp_dbl+1; - const std::pair intv(pp_dbl, qq_dbl); - return shift_positive_interval(intv, -shift); - } - - template - std::pair to_interval( ET x, int extra_shift = 0 ); - - // This is a version of to_interval that converts a rational type into a - // double tight interval. - template - std::pair to_interval( ET xnum, ET xden ) { - - CGAL_assertion(!CGAL::is_zero(xden)); - CGAL_assertion_code(const Type input(xnum, xden)); - double l = 0.0, u = 0.0; - if (CGAL::is_zero(xnum)) { // return [0.0, 0.0] - CGAL_assertion(are_bounds_correct(l, u, input)); - return std::make_pair(l, u); - } - CGAL_assertion(!CGAL::is_zero(xnum)); - - // Handle signs. - bool change_sign = false; - const bool is_num_pos = CGAL::is_positive(xnum); - const bool is_den_pos = CGAL::is_positive(xden); - if (!is_num_pos && !is_den_pos) { - xnum = -xnum; - xden = -xden; - } else if (!is_num_pos && is_den_pos) { - change_sign = true; - xnum = -xnum; - } else if (is_num_pos && !is_den_pos) { - change_sign = true; - xden = -xden; - } - CGAL_assertion(CGAL::is_positive(xnum) && CGAL::is_positive(xden)); - - const int64_t num_dbl_digits = std::numeric_limits::digits - 1; - const int64_t msb_num = static_cast(boost::multiprecision::msb(xnum)); - const int64_t msb_den = static_cast(boost::multiprecision::msb(xden)); - -#if 0 // Optimisation for the case of input that are double - // An alternative strategy would be to convert numerator and denominator to - // intervals, then divide. However, this would require setting the rounding - // mode (and dividing intervals is not completely free). An important - // special case is when the rational is exactly equal to a double - // (fit_in_double). Then the denominator is a power of 2, so we can skip - // the division and it becomes unnecessary to set the rounding mode, we - // just need to modify the exponent correction for the denominator. - if(msb_den == static_cast(lsb(xden))) { - std::tie(l,u)=to_interval(xnum, msb_den); - if (change_sign) { - CGAL_assertion(are_bounds_correct(-u, -l, input)); - return {-u, -l}; - } - CGAL_assertion(are_bounds_correct(l, u, input)); - return {u, l}; - } -#endif - - const int64_t msb_diff = msb_num - msb_den; - // Shift so the division result has at least 53 (and at most 54) bits - int shift = static_cast(num_dbl_digits - msb_diff + 1); - CGAL_assertion(shift == num_dbl_digits - msb_diff + 1); - - if (shift > 0) { - xnum <<= +shift; - } else if (shift < 0) { - xden <<= -shift; - } - CGAL_assertion(num_dbl_digits + 1 == - static_cast(boost::multiprecision::msb(xnum)) - - static_cast(boost::multiprecision::msb(xden))); - - ET p, r; - boost::multiprecision::divide_qr(xnum, xden, p, r); - uint64_t uip = static_cast(p); - const int64_t p_bits = static_cast(boost::multiprecision::msb(p)); - bool exact = r.is_zero(); - - if (p_bits > num_dbl_digits) { // case 54 bits - exact &= ((uip & 1) == 0); - uip>>=1; - --shift; - } - std::tie(l, u) = exact ? get_0ulp_interval(shift, uip) : get_1ulp_interval(shift, uip); - - if (change_sign) { - const double t = l; - l = -u; - u = -t; - } - - CGAL_assertion(are_bounds_correct(l, u, input)); - return std::make_pair(l, u); - } - - // This is a version of to_interval that converts an integer type into a - // double tight interval. - template - std::pair to_interval( ET x, int extra_shift) { - - CGAL_assertion_code(const ET input = x); - double l = 0.0, u = 0.0; - if (CGAL::is_zero(x)) { // return [0.0, 0.0] - CGAL_assertion(are_bounds_correct(l, u, input)); - return std::make_pair(l, u); - } - CGAL_assertion(!CGAL::is_zero(x)); - - bool change_sign = false; - const bool is_pos = CGAL::is_positive(x); - if (!is_pos) { - change_sign = true; - x = -x; - } - CGAL_assertion(CGAL::is_positive(x)); - - const int64_t n = static_cast(boost::multiprecision::msb(x)) + 1; - const int64_t num_dbl_digits = std::numeric_limits::digits; - - if (n > num_dbl_digits) { - const int64_t mindig = static_cast(boost::multiprecision::lsb(x)); - int e = static_cast(n - num_dbl_digits); - x >>= e; - if (n - mindig > num_dbl_digits) - std::tie(l, u) = get_1ulp_interval(-e+extra_shift, static_cast(x)); - else - std::tie(l, u) = get_0ulp_interval(-e+extra_shift, static_cast(x)); - } else { - l = u = extra_shift==0 ? static_cast(static_cast(x)) - : std::ldexp(static_cast(static_cast(x)),-extra_shift); - } - - if (change_sign) { - const double t = l; - l = -u; - u = -t; - } - - CGAL_assertion(extra_shift != 0 || are_bounds_correct(l, u, input)); - return std::make_pair(l, u); - } - -} // Boost_MP_internal - -template -struct RET_boost_mp_base - : public INTERN_RET::Real_embeddable_traits_base< NT , CGAL::Tag_true > { - - typedef NT Type; - - struct Is_zero: public CGAL::cpp98::unary_function { - bool operator()( const Type& x) const { - return x.is_zero(); - } - }; - - struct Is_positive: public CGAL::cpp98::unary_function { - bool operator()( const Type& x) const { - return x.sign() > 0; - } - }; - - struct Is_negative: public CGAL::cpp98::unary_function { - bool operator()( const Type& x) const { - return x.sign() < 0; - } - }; - - struct Abs : public CGAL::cpp98::unary_function { - template - Type operator()(const T& x) const { - return boost::multiprecision::abs(x); - } - }; - - struct Sgn : public CGAL::cpp98::unary_function { - ::CGAL::Sign operator()(Type const& x) const { - return CGAL::sign(x.sign()); - } - }; - - struct Compare - : public CGAL::cpp98::binary_function { - Comparison_result operator()(const Type& x, const Type& y) const { - return CGAL::sign(x.compare(y)); - } - }; - - struct To_double - : public CGAL::cpp98::unary_function { - double operator()(const Type& x) const { - return x.template convert_to(); - } - }; - - struct To_interval - : public CGAL::cpp98::unary_function< Type, std::pair< double, double > > { - - std::pair - operator()(const Type& x) const { - - // See if https://github.com/boostorg/multiprecision/issues/108 suggests anything better - // assume the conversion is within 1 ulp - // adding IA::smallest() doesn't work because inf-e=inf, even rounded down. - - // We must use to_nearest here. - double i; - const double inf = std::numeric_limits::infinity(); - { - Protect_FPU_rounding P(CGAL_FE_TONEAREST); - i = static_cast(x); - if (i == +inf) { - return std::make_pair((std::numeric_limits::max)(), i); - } else if (i == -inf) { - return std::make_pair(i, std::numeric_limits::lowest()); - } - } - double s = i; - CGAL_assertion(CGAL::abs(i) != inf && CGAL::abs(s) != inf); - - // Throws uncaught exception: Cannot convert a non-finite number to an integer. - // We can catch it earlier by using the CGAL_assertion() one line above. - const int cmp = x.compare(i); - if (cmp > 0) { - s = nextafter(s, +inf); - CGAL_assertion(x.compare(s) < 0); - } - else if (cmp < 0) { - i = nextafter(i, -inf); - CGAL_assertion(x.compare(i) > 0); - } - return std::pair(i, s); - } - }; -}; - -template ::value> > -struct RET_boost_mp; - -template -struct RET_boost_mp > - : RET_boost_mp_base { - typedef NT Type; - struct To_interval - : public CGAL::cpp98::unary_function< Type, std::pair< double, double > > { - - std::pair operator()( const Type& x ) const { - return Boost_MP_internal::to_interval(x); - } - }; -}; - -template -struct RET_boost_mp > - : RET_boost_mp_base { - typedef NT Type; - struct To_interval - : public CGAL::cpp98::unary_function< Type, std::pair< double, double > > { - - std::pair operator()( const Type& x ) const { - return Boost_MP_internal::to_interval( - boost::multiprecision::numerator(x), boost::multiprecision::denominator(x)); - } - }; -}; - -#ifdef CGAL_USE_MPFR -// Because of these full specializations, things get instantiated more eagerly. Make them artificially partial if necessary. -template <> -struct RET_boost_mp - : RET_boost_mp_base { - typedef boost::multiprecision::mpz_int Type; - struct To_interval - : public CGAL::cpp98::unary_function< Type, std::pair< double, double > > { - std::pair - operator()(const Type& x) const { -#if MPFR_VERSION_MAJOR >= 3 - MPFR_DECL_INIT (y, 53); /* Assume IEEE-754 */ - int r = mpfr_set_z (y, x.backend().data(), MPFR_RNDA); - double i = mpfr_get_d (y, MPFR_RNDA); /* EXACT but can overflow */ - if (r == 0 && is_finite (i)) - return std::pair(i, i); - else - { - double s = nextafter (i, 0); - if (i < 0) - return std::pair(i, s); - else - return std::pair(s, i); - } -#else - mpfr_t y; - mpfr_init2 (y, 53); /* Assume IEEE-754 */ - mpfr_set_z (y, x.backend().data(), GMP_RNDD); - double i = mpfr_get_d (y, GMP_RNDD); /* EXACT but can overflow */ - mpfr_set_z (y, x.backend().data(), GMP_RNDU); - double s = mpfr_get_d (y, GMP_RNDU); /* EXACT but can overflow */ - mpfr_clear (y); - return std::pair(i, s); -#endif - } - }; -}; -template <> -struct RET_boost_mp - : RET_boost_mp_base { - typedef boost::multiprecision::mpq_rational Type; - struct To_interval - : public CGAL::cpp98::unary_function< Type, std::pair< double, double > > { - std::pair - operator()(const Type& x) const { -# if MPFR_VERSION_MAJOR >= 3 - mpfr_exp_t emin = mpfr_get_emin(); - mpfr_set_emin(-1073); - MPFR_DECL_INIT (y, 53); /* Assume IEEE-754 */ - int r = mpfr_set_q (y, x.backend().data(), MPFR_RNDA); - r = mpfr_subnormalize (y, r, MPFR_RNDA); /* Round subnormals */ - double i = mpfr_get_d (y, MPFR_RNDA); /* EXACT but can overflow */ - mpfr_set_emin(emin); /* Restore old value, users may care */ - // With mpfr_set_emax(1024) we could drop the is_finite test - if (r == 0 && is_finite (i)) - return std::pair(i, i); - else - { - double s = nextafter (i, 0); - if (i < 0) - return std::pair(i, s); - else - return std::pair(s, i); - } -# else - mpfr_t y; - mpfr_init2 (y, 53); /* Assume IEEE-754 */ - mpfr_set_q (y, x.backend().data(), GMP_RNDD); - double i = mpfr_get_d (y, GMP_RNDD); /* EXACT but can overflow */ - mpfr_set_q (y, x.backend().data(), GMP_RNDU); - double s = mpfr_get_d (y, GMP_RNDU); /* EXACT but can overflow */ - mpfr_clear (y); - return std::pair(i, s); -# endif - } - }; -}; -#endif - -template -struct Real_embeddable_traits > -: RET_boost_mp > {}; -template -struct Real_embeddable_traits > -: Real_embeddable_traits::result_type > {}; - -// Modular_traits - -template ::value> > -struct MT_boost_mp { - typedef T NT; - typedef ::CGAL::Tag_false Is_modularizable; - typedef ::CGAL::Null_functor Residue_type; - typedef ::CGAL::Null_functor Modular_image; - typedef ::CGAL::Null_functor Modular_image_representative; -}; - -template -struct MT_boost_mp > { - typedef T NT; - typedef CGAL::Tag_true Is_modularizable; - typedef Residue Residue_type; - - struct Modular_image{ - Residue_type operator()(const NT& a){ - NT tmp(CGAL::mod(a,NT(Residue::get_current_prime()))); - return CGAL::Residue(tmp.template convert_to()); - } - }; - struct Modular_image_representative{ - NT operator()(const Residue_type& x){ - return NT(x.get_value()); - } - }; -}; - -template -struct Modular_traits > -: MT_boost_mp > {}; -template -struct Modular_traits > -: Modular_traits::result_type > {}; - -// Split_double - -template ::value> > -struct SD_boost_mp { - void operator()(double d, NT &num, NT &den) const - { - num = d; - den = 1; - } -}; - -template -struct SD_boost_mp > -{ - void operator()(double d, NT &num, NT &den) const - { - std::pair p = split_numerator_denominator(d); - num = NT(p.first); - den = NT(p.second); - } -}; - -template -struct Split_double > -: SD_boost_mp > {}; -template -struct Split_double > -: Split_double::result_type > {}; - - -// Fraction_traits - -template ::value> > -struct FT_boost_mp { - typedef T Type; - typedef Tag_false Is_fraction; - typedef Null_tag Numerator_type; - typedef Null_tag Denominator_type; - typedef Null_functor Common_factor; - typedef Null_functor Decompose; - typedef Null_functor Compose; -}; - -template -struct FT_boost_mp > { - typedef NT Type; - - typedef ::CGAL::Tag_true Is_fraction; - typedef typename boost::multiprecision::component_type::type Numerator_type; - typedef Numerator_type Denominator_type; - - typedef typename Algebraic_structure_traits< Numerator_type >::Gcd Common_factor; - - class Decompose { - public: - typedef Type first_argument_type; - typedef Numerator_type& second_argument_type; - typedef Denominator_type& third_argument_type; - void operator () ( - const Type& rat, - Numerator_type& num, - Denominator_type& den) { - num = numerator(rat); - den = denominator(rat); - } - }; - - class Compose { - public: - typedef Numerator_type first_argument_type; - typedef Denominator_type second_argument_type; - typedef Type result_type; - Type operator ()( - const Numerator_type& num , - const Denominator_type& den ) { - return Type(num, den); - } - }; -}; - -template -struct Fraction_traits > -: FT_boost_mp > {}; -template -struct Fraction_traits > -: Fraction_traits::result_type > {}; - - -// Coercions - -namespace internal { namespace boost_mp { BOOST_MPL_HAS_XXX_TRAIT_DEF(type) } } - -template -struct Coercion_traits, boost::multiprecision::number > -{ - typedef boost::common_type, boost::multiprecision::number > CT; - typedef Boolean_tag::value> Are_implicit_interoperable; - // FIXME: the implicit/explicit answers shouldn't be the same... - typedef Are_implicit_interoperable Are_explicit_interoperable; - // FIXME: won't compile when they are not interoperable. - typedef typename CT::type Type; - struct Cast{ - typedef Type result_type; - template - Type operator()(const U& x) const { - return Type(x); - } - }; -}; -// Avoid ambiguity with the specialization for ... -template -struct Coercion_traits, boost::multiprecision::number > -{ - typedef boost::multiprecision::number Type; - typedef Tag_true Are_implicit_interoperable; - typedef Tag_true Are_explicit_interoperable; - struct Cast{ - typedef Type result_type; - template - Type operator()(const U& x) const { - return Type(x); - } - }; -}; - -template -struct Coercion_traits < -boost::multiprecision::detail::expression, -boost::multiprecision::detail::expression > -: Coercion_traits < -typename boost::multiprecision::detail::expression::result_type, -typename boost::multiprecision::detail::expression::result_type> -{ }; -// Avoid ambiguity with the specialization for ... -template -struct Coercion_traits < -boost::multiprecision::detail::expression, -boost::multiprecision::detail::expression > -: Coercion_traits < -typename boost::multiprecision::detail::expression::result_type, -typename boost::multiprecision::detail::expression::result_type> -{ }; - -template -struct Coercion_traits, boost::multiprecision::detail::expression > -: Coercion_traits < -boost::multiprecision::number, -typename boost::multiprecision::detail::expression::result_type> -{ }; - -template -struct Coercion_traits, boost::multiprecision::number > -: Coercion_traits < -typename boost::multiprecision::detail::expression::result_type, -boost::multiprecision::number > -{ }; - -// TODO: fix existing coercions -// (double -> rational is implicit only for 1.56+, see ticket #10082) -// The real solution would be to avoid specializing Coercion_traits for all pairs of number types and let it auto-detect what works, so only broken types need an explicit specialization. - -// Ignore types smaller than long -#define CGAL_COERCE_INT(int) \ -template \ -struct Coercion_traits, int> { \ - typedef boost::multiprecision::number Type; \ - typedef Tag_true Are_implicit_interoperable; \ - typedef Tag_true Are_explicit_interoperable; \ - struct Cast{ \ - typedef Type result_type; \ - template Type operator()(const U& x) const { return Type(x); } \ - }; \ -}; \ -template \ -struct Coercion_traits > \ -: Coercion_traits, int> {}; \ -template \ -struct Coercion_traits, int> \ -: Coercion_traits::result_type, int>{}; \ -template \ -struct Coercion_traits > \ -: Coercion_traits::result_type, int>{} - -CGAL_COERCE_INT(short); -CGAL_COERCE_INT(int); -CGAL_COERCE_INT(long); -#undef CGAL_COERCE_INT - -// Ignore bounded-precision rationals -#define CGAL_COERCE_FLOAT(float) \ -template \ -struct Coercion_traits, float> { \ - typedef boost::multiprecision::number Type; \ - typedef Boolean_tag::value != boost::multiprecision::number_kind_integer> Are_implicit_interoperable; \ - typedef Are_implicit_interoperable Are_explicit_interoperable; \ - struct Cast{ \ - typedef Type result_type; \ - template Type operator()(const U& x) const { return Type(x); } \ - }; \ -}; \ -template \ -struct Coercion_traits > \ -: Coercion_traits, float> {}; \ -template \ -struct Coercion_traits, float> \ -: Coercion_traits::result_type, float>{}; \ -template \ -struct Coercion_traits > \ -: Coercion_traits::result_type, float>{} - -CGAL_COERCE_FLOAT(float); -CGAL_COERCE_FLOAT(double); -#undef CGAL_COERCE_FLOAT - -// Because of https://github.com/boostorg/multiprecision/issues/29 , this is not perfect and fails to read some KDS files. - -template <> -class Input_rep : public IO_rep_is_specialized { - boost::multiprecision::cpp_rational& q; -public: - Input_rep(boost::multiprecision::cpp_rational& qq) : q(qq) {} - std::istream& operator()(std::istream& in) const { - internal::read_float_or_quotient(in, q); - return in; - } -}; -#ifdef CGAL_USE_GMP -template <> -class Input_rep : public IO_rep_is_specialized { - boost::multiprecision::mpq_rational& q; -public: - Input_rep(boost::multiprecision::mpq_rational& qq) : q(qq) {} - std::istream& operator()(std::istream& in) const { - internal::read_float_or_quotient(in, q); - return in; - } -}; -#endif - -// Copied from leda_rational.h -namespace internal { - // See: Stream_support/include/CGAL/IO/io.h - template - void read_float_or_quotient(std::istream & is, ET& et); - - template <> - inline void read_float_or_quotient(std::istream & is, boost::multiprecision::cpp_rational& et) - { - internal::read_float_or_quotient(is, et); - } -#ifdef CGAL_USE_GMP - template <> - inline void read_float_or_quotient(std::istream & is, boost::multiprecision::mpq_rational& et) - { - internal::read_float_or_quotient(is, et); - } -#endif -} // namespace internal - -#ifdef CGAL_USE_BOOST_MP - -template< > class Real_embeddable_traits< Quotient > - : public INTERN_QUOTIENT::Real_embeddable_traits_quotient_base< Quotient > { - - public: - typedef Quotient Type; - - class To_interval - : public CGAL::cpp98::unary_function< Type, std::pair< double, double > > { - public: - std::pair operator()( const Type& x ) const { - return Boost_MP_internal::to_interval(x.num, x.den); - } - }; -}; - -#endif // CGAL_USE_BOOST_MP - -} //namespace CGAL - -namespace Eigen { - template struct NumTraits; - template<> struct NumTraits - { - typedef boost::multiprecision::cpp_int Real; - typedef boost::multiprecision::cpp_rational NonInteger; - typedef boost::multiprecision::cpp_int Nested; - typedef boost::multiprecision::cpp_int Literal; - - static inline Real epsilon() { return 0; } - static inline Real dummy_precision() { return 0; } - - enum { - IsInteger = 1, - IsSigned = 1, - IsComplex = 0, - RequireInitialization = 1, - ReadCost = 6, - AddCost = 30, - MulCost = 50 - }; - }; - - template<> struct NumTraits - { - typedef boost::multiprecision::cpp_rational Real; - typedef boost::multiprecision::cpp_rational NonInteger; - typedef boost::multiprecision::cpp_rational Nested; - typedef boost::multiprecision::cpp_rational Literal; - - static inline Real epsilon() { return 0; } - static inline Real dummy_precision() { return 0; } - - enum { - IsInteger = 0, - IsSigned = 1, - IsComplex = 0, - RequireInitialization = 1, - ReadCost = 6, - AddCost = 150, - MulCost = 100 - }; - }; - -#ifdef CGAL_USE_GMP - - template<> struct NumTraits - { - typedef boost::multiprecision::mpz_int Real; - typedef boost::multiprecision::mpq_rational NonInteger; - typedef boost::multiprecision::mpz_int Nested; - typedef boost::multiprecision::mpz_int Literal; - - static inline Real epsilon() { return 0; } - static inline Real dummy_precision() { return 0; } - - enum { - IsInteger = 1, - IsSigned = 1, - IsComplex = 0, - RequireInitialization = 1, - ReadCost = 6, - AddCost = 30, - MulCost = 50 - }; - }; - - template<> struct NumTraits - { - typedef boost::multiprecision::mpq_rational Real; - typedef boost::multiprecision::mpq_rational NonInteger; - typedef boost::multiprecision::mpq_rational Nested; - typedef boost::multiprecision::mpq_rational Literal; - - static inline Real epsilon() { return 0; } - static inline Real dummy_precision() { return 0; } - - enum { - IsInteger = 0, - IsSigned = 1, - IsComplex = 0, - RequireInitialization = 1, - ReadCost = 6, - AddCost = 150, - MulCost = 100 - }; - }; -#endif // CGAL_USE_GMP - - -} // namespace Eigen - +#include #include -#endif // BOOST_VERSION -#endif +#endif // CGAL_BOOST_MP_H diff --git a/Number_types/include/CGAL/boost_mp_type.h b/Number_types/include/CGAL/boost_mp_type.h new file mode 100644 index 000000000000..1a0d78f18215 --- /dev/null +++ b/Number_types/include/CGAL/boost_mp_type.h @@ -0,0 +1,1010 @@ +// Copyright (c) 2017 +// INRIA Saclay-Ile de France (France), +// +// This file is part of CGAL (www.cgal.org) +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Marc Glisse + +#ifndef CGAL_BOOST_MP_TYPE_H +#define CGAL_BOOST_MP_TYPE_H + +#include +#include + +// It is easier to disable this number type completely for old versions. +// Before 1.63, I/O is broken. Again, disabling the whole file is just the +// easy solution. +// MSVC had trouble with versions <= 1.69: +// https://github.com/boostorg/multiprecision/issues/98 +#if !defined CGAL_DO_NOT_USE_BOOST_MP && \ + (!defined _MSC_VER || BOOST_VERSION >= 107000) +#define CGAL_USE_BOOST_MP 1 + +#include +#include // *ary_function +#include +#include +// We can't just include all Boost.Multiprecision here... +#include +#include +// ... but we kind of have to :-( +#include +#ifdef CGAL_USE_GMP +// Same dance as in CGAL/gmp.h +# include +# if defined(BOOST_MSVC) +# pragma warning(push) +# pragma warning(disable: 4127 4244 4146 4267) // conversion with loss of data + // warning on - applied on unsigned number +# endif + +# include + +# if defined(BOOST_MSVC) +# pragma warning(pop) +# endif + +# include +#endif +#ifdef CGAL_USE_MPFR +# include +#endif + +// TODO: work on the coercions (end of the file) + +namespace CGAL { +template<> +struct Needs_parens_as_product{ + bool operator()(const typename boost::multiprecision::cpp_int& x){ + return x < 0; + } +}; + +template<> +struct Needs_parens_as_product{ + bool operator()(const typename boost::multiprecision::cpp_rational& x){ + if (denominator(x) != 1 ) + return true; + else + return needs_parens_as_product(numerator(x)) ; + } + +}; + + +// Algebraic_structure_traits + +template ::value> > +struct AST_boost_mp; + +template +struct AST_boost_mp > + : Algebraic_structure_traits_base< NT, Euclidean_ring_tag > { + typedef NT Type; + typedef Euclidean_ring_tag Algebraic_category; + typedef Boolean_tag::is_exact> Is_exact; + typedef Tag_false Is_numerical_sensitive; + + struct Is_zero: public CGAL::cpp98::unary_function { + bool operator()( const Type& x) const { + return x.is_zero(); + } + }; + + struct Div: + public CGAL::cpp98::binary_function { + template + Type operator()(const T& x, const U& y) const { + return x / y; + } + }; + + struct Mod: + public CGAL::cpp98::binary_function { + template + Type operator()(const T& x, const U& y) const { + return x % y; + } + }; + + struct Gcd : public CGAL::cpp98::binary_function { + template + Type operator()(const T& x, const U& y) const { + return boost::multiprecision::gcd(x, y); + } + }; + + struct Sqrt : public CGAL::cpp98::unary_function { + template + Type operator()(const T& x) const { + return boost::multiprecision::sqrt(x); + } + }; +}; + +template +struct AST_boost_mp > + : public Algebraic_structure_traits_base< NT , Field_tag > { + public: + typedef NT Type; + typedef Field_tag Algebraic_category; + typedef Tag_true Is_exact; + typedef Tag_false Is_numerical_sensitive; + + struct Is_zero: public CGAL::cpp98::unary_function { + bool operator()( const Type& x) const { + return x.is_zero(); + } + }; + + struct Div: + public CGAL::cpp98::binary_function { + template + Type operator()(const T& x, const U& y) const { + return x / y; + } + }; +}; + +template +struct Algebraic_structure_traits > +: AST_boost_mp > {}; +template +struct Algebraic_structure_traits > +: Algebraic_structure_traits::result_type > {}; + +// Real_embeddable_traits + +namespace Boost_MP_internal { + + // here we know that `intv` contains int64 numbers such that their msb is std::numeric_limits::digits-1 + // TODO: possibly return denormals sometimes... + inline + std::pair shift_positive_interval( const std::pair& intv, const int e ) { + CGAL_assertion(intv.first > 0.0); + CGAL_assertion(intv.second > 0.0); + +#ifdef CGAL_LITTLE_ENDIAN + CGAL_assertion_code( + union { + struct { uint64_t man:52; uint64_t exp:11; uint64_t sig:1; } s; + double d; + } conv; + + conv.d = intv.first; + ) +#else + //WARNING: untested! + CGAL_assertion_code( + union { + + struct { uint64_t sig:1; uint64_t exp:11; uint64_t man:52; } s; + double d; + } conv; + + conv.d = intv.first; + ) +#endif + // Check that the exponent of intv.inf is 52, which corresponds to a 53 bit integer + CGAL_assertion(conv.s.exp - ((1 << (11 - 1)) - 1) == std::numeric_limits::digits - 1); + + typedef std::numeric_limits limits; + + // warning: min_exponent and max_exponent are 1 more than what the name suggests + if (e < limits::min_exponent - limits::digits) + return {0, (limits::min)()}; + if (e > limits::max_exponent - limits::digits) + return {(limits::max)(), limits::infinity()}; // intv is positive + + const double scale = std::ldexp(1.0, e); // ldexp call is exact + return { scale * intv.first, scale * intv.second }; // cases that would require a rounding mode have been handled above + } + + // This function checks if the computed interval is correct and if it is tight. + template + bool are_bounds_correct( const double l, const double u, const Type& x ) { + typedef std::numeric_limits limits; + + const double inf = std::numeric_limits::infinity(); + if ( u!=l && (l==-inf || u==inf + || (u==0 && l >= -(limits::min)()) + || (l==0 && u <= (limits::min)())) ) + { + return x > Type((limits::max)()) || + x < Type(-(limits::max)()) || + (x > Type(-(limits::min)()) && x < Type((limits::min)())); + } + + if (!(u == l || u == std::nextafter(l, +inf))) return false; + //TODO: Type(nextafter(l,inf))>x && Type(nextafter(u,-inf)) get_0ulp_interval( const int shift, const uint64_t p ) { + + const double pp_dbl = static_cast(p); + const std::pair intv(pp_dbl, pp_dbl); + + return shift_positive_interval(intv, -shift); + } + + // This one returns 1 unit length interval. + inline + std::pair get_1ulp_interval( const int shift, const uint64_t p ) { + + const double pp_dbl = static_cast(p); + const double qq_dbl = pp_dbl+1; + const std::pair intv(pp_dbl, qq_dbl); + return shift_positive_interval(intv, -shift); + } + + template + std::pair to_interval( ET x, int extra_shift = 0 ); + + // This is a version of to_interval that converts a rational type into a + // double tight interval. + template + std::pair to_interval( ET xnum, ET xden ) { + + CGAL_assertion(!CGAL::is_zero(xden)); + CGAL_assertion_code(const Type input(xnum, xden)); + double l = 0.0, u = 0.0; + if (CGAL::is_zero(xnum)) { // return [0.0, 0.0] + CGAL_assertion(are_bounds_correct(l, u, input)); + return std::make_pair(l, u); + } + CGAL_assertion(!CGAL::is_zero(xnum)); + + // Handle signs. + bool change_sign = false; + const bool is_num_pos = CGAL::is_positive(xnum); + const bool is_den_pos = CGAL::is_positive(xden); + if (!is_num_pos && !is_den_pos) { + xnum = -xnum; + xden = -xden; + } else if (!is_num_pos && is_den_pos) { + change_sign = true; + xnum = -xnum; + } else if (is_num_pos && !is_den_pos) { + change_sign = true; + xden = -xden; + } + CGAL_assertion(CGAL::is_positive(xnum) && CGAL::is_positive(xden)); + + const int64_t num_dbl_digits = std::numeric_limits::digits - 1; + const int64_t msb_num = static_cast(boost::multiprecision::msb(xnum)); + const int64_t msb_den = static_cast(boost::multiprecision::msb(xden)); + +#if 0 // Optimisation for the case of input that are double + // An alternative strategy would be to convert numerator and denominator to + // intervals, then divide. However, this would require setting the rounding + // mode (and dividing intervals is not completely free). An important + // special case is when the rational is exactly equal to a double + // (fit_in_double). Then the denominator is a power of 2, so we can skip + // the division and it becomes unnecessary to set the rounding mode, we + // just need to modify the exponent correction for the denominator. + if(msb_den == static_cast(lsb(xden))) { + std::tie(l,u)=to_interval(xnum, msb_den); + if (change_sign) { + CGAL_assertion(are_bounds_correct(-u, -l, input)); + return {-u, -l}; + } + CGAL_assertion(are_bounds_correct(l, u, input)); + return {u, l}; + } +#endif + + const int64_t msb_diff = msb_num - msb_den; + // Shift so the division result has at least 53 (and at most 54) bits + int shift = static_cast(num_dbl_digits - msb_diff + 1); + CGAL_assertion(shift == num_dbl_digits - msb_diff + 1); + + if (shift > 0) { + xnum <<= +shift; + } else if (shift < 0) { + xden <<= -shift; + } + CGAL_assertion(num_dbl_digits + 1 == + static_cast(boost::multiprecision::msb(xnum)) - + static_cast(boost::multiprecision::msb(xden))); + + ET p, r; + boost::multiprecision::divide_qr(xnum, xden, p, r); + uint64_t uip = static_cast(p); + const int64_t p_bits = static_cast(boost::multiprecision::msb(p)); + bool exact = r.is_zero(); + + if (p_bits > num_dbl_digits) { // case 54 bits + exact &= ((uip & 1) == 0); + uip>>=1; + --shift; + } + std::tie(l, u) = exact ? get_0ulp_interval(shift, uip) : get_1ulp_interval(shift, uip); + + if (change_sign) { + const double t = l; + l = -u; + u = -t; + } + + CGAL_assertion(are_bounds_correct(l, u, input)); + return std::make_pair(l, u); + } + + // This is a version of to_interval that converts an integer type into a + // double tight interval. + template + std::pair to_interval( ET x, int extra_shift) { + + CGAL_assertion_code(const ET input = x); + double l = 0.0, u = 0.0; + if (CGAL::is_zero(x)) { // return [0.0, 0.0] + CGAL_assertion(are_bounds_correct(l, u, input)); + return std::make_pair(l, u); + } + CGAL_assertion(!CGAL::is_zero(x)); + + bool change_sign = false; + const bool is_pos = CGAL::is_positive(x); + if (!is_pos) { + change_sign = true; + x = -x; + } + CGAL_assertion(CGAL::is_positive(x)); + + const int64_t n = static_cast(boost::multiprecision::msb(x)) + 1; + const int64_t num_dbl_digits = std::numeric_limits::digits; + + if (n > num_dbl_digits) { + const int64_t mindig = static_cast(boost::multiprecision::lsb(x)); + int e = static_cast(n - num_dbl_digits); + x >>= e; + if (n - mindig > num_dbl_digits) + std::tie(l, u) = get_1ulp_interval(-e+extra_shift, static_cast(x)); + else + std::tie(l, u) = get_0ulp_interval(-e+extra_shift, static_cast(x)); + } else { + l = u = extra_shift==0 ? static_cast(static_cast(x)) + : std::ldexp(static_cast(static_cast(x)),-extra_shift); + } + + if (change_sign) { + const double t = l; + l = -u; + u = -t; + } + + CGAL_assertion(extra_shift != 0 || are_bounds_correct(l, u, input)); + return std::make_pair(l, u); + } + +} // Boost_MP_internal + +template +struct RET_boost_mp_base + : public INTERN_RET::Real_embeddable_traits_base< NT , CGAL::Tag_true > { + + typedef NT Type; + + struct Is_zero: public CGAL::cpp98::unary_function { + bool operator()( const Type& x) const { + return x.is_zero(); + } + }; + + struct Is_positive: public CGAL::cpp98::unary_function { + bool operator()( const Type& x) const { + return x.sign() > 0; + } + }; + + struct Is_negative: public CGAL::cpp98::unary_function { + bool operator()( const Type& x) const { + return x.sign() < 0; + } + }; + + struct Abs : public CGAL::cpp98::unary_function { + template + Type operator()(const T& x) const { + return boost::multiprecision::abs(x); + } + }; + + struct Sgn : public CGAL::cpp98::unary_function { + ::CGAL::Sign operator()(Type const& x) const { + return CGAL::sign(x.sign()); + } + }; + + struct Compare + : public CGAL::cpp98::binary_function { + Comparison_result operator()(const Type& x, const Type& y) const { + return CGAL::sign(x.compare(y)); + } + }; + + struct To_double + : public CGAL::cpp98::unary_function { + double operator()(const Type& x) const { + return x.template convert_to(); + } + }; + + struct To_interval + : public CGAL::cpp98::unary_function< Type, std::pair< double, double > > { + + std::pair + operator()(const Type& x) const { + + // See if https://github.com/boostorg/multiprecision/issues/108 suggests anything better + // assume the conversion is within 1 ulp + // adding IA::smallest() doesn't work because inf-e=inf, even rounded down. + + // We must use to_nearest here. + double i; + const double inf = std::numeric_limits::infinity(); + { + Protect_FPU_rounding P(CGAL_FE_TONEAREST); + i = static_cast(x); + if (i == +inf) { + return std::make_pair((std::numeric_limits::max)(), i); + } else if (i == -inf) { + return std::make_pair(i, std::numeric_limits::lowest()); + } + } + double s = i; + CGAL_assertion(CGAL::abs(i) != inf && CGAL::abs(s) != inf); + + // Throws uncaught exception: Cannot convert a non-finite number to an integer. + // We can catch it earlier by using the CGAL_assertion() one line above. + const int cmp = x.compare(i); + if (cmp > 0) { + s = nextafter(s, +inf); + CGAL_assertion(x.compare(s) < 0); + } + else if (cmp < 0) { + i = nextafter(i, -inf); + CGAL_assertion(x.compare(i) > 0); + } + return std::pair(i, s); + } + }; +}; + +template ::value> > +struct RET_boost_mp; + +template +struct RET_boost_mp > + : RET_boost_mp_base { + typedef NT Type; + struct To_interval + : public CGAL::cpp98::unary_function< Type, std::pair< double, double > > { + + std::pair operator()( const Type& x ) const { + return Boost_MP_internal::to_interval(x); + } + }; +}; + +template +struct RET_boost_mp > + : RET_boost_mp_base { + typedef NT Type; + struct To_interval + : public CGAL::cpp98::unary_function< Type, std::pair< double, double > > { + + std::pair operator()( const Type& x ) const { + return Boost_MP_internal::to_interval( + boost::multiprecision::numerator(x), boost::multiprecision::denominator(x)); + } + }; +}; + +#ifdef CGAL_USE_MPFR +// Because of these full specializations, things get instantiated more eagerly. Make them artificially partial if necessary. +template <> +struct RET_boost_mp + : RET_boost_mp_base { + typedef boost::multiprecision::mpz_int Type; + struct To_interval + : public CGAL::cpp98::unary_function< Type, std::pair< double, double > > { + std::pair + operator()(const Type& x) const { +#if MPFR_VERSION_MAJOR >= 3 + MPFR_DECL_INIT (y, 53); /* Assume IEEE-754 */ + int r = mpfr_set_z (y, x.backend().data(), MPFR_RNDA); + double i = mpfr_get_d (y, MPFR_RNDA); /* EXACT but can overflow */ + if (r == 0 && is_finite (i)) + return std::pair(i, i); + else + { + double s = nextafter (i, 0); + if (i < 0) + return std::pair(i, s); + else + return std::pair(s, i); + } +#else + mpfr_t y; + mpfr_init2 (y, 53); /* Assume IEEE-754 */ + mpfr_set_z (y, x.backend().data(), GMP_RNDD); + double i = mpfr_get_d (y, GMP_RNDD); /* EXACT but can overflow */ + mpfr_set_z (y, x.backend().data(), GMP_RNDU); + double s = mpfr_get_d (y, GMP_RNDU); /* EXACT but can overflow */ + mpfr_clear (y); + return std::pair(i, s); +#endif + } + }; +}; +template <> +struct RET_boost_mp + : RET_boost_mp_base { + typedef boost::multiprecision::mpq_rational Type; + struct To_interval + : public CGAL::cpp98::unary_function< Type, std::pair< double, double > > { + std::pair + operator()(const Type& x) const { +# if MPFR_VERSION_MAJOR >= 3 + mpfr_exp_t emin = mpfr_get_emin(); + mpfr_set_emin(-1073); + MPFR_DECL_INIT (y, 53); /* Assume IEEE-754 */ + int r = mpfr_set_q (y, x.backend().data(), MPFR_RNDA); + r = mpfr_subnormalize (y, r, MPFR_RNDA); /* Round subnormals */ + double i = mpfr_get_d (y, MPFR_RNDA); /* EXACT but can overflow */ + mpfr_set_emin(emin); /* Restore old value, users may care */ + // With mpfr_set_emax(1024) we could drop the is_finite test + if (r == 0 && is_finite (i)) + return std::pair(i, i); + else + { + double s = nextafter (i, 0); + if (i < 0) + return std::pair(i, s); + else + return std::pair(s, i); + } +# else + mpfr_t y; + mpfr_init2 (y, 53); /* Assume IEEE-754 */ + mpfr_set_q (y, x.backend().data(), GMP_RNDD); + double i = mpfr_get_d (y, GMP_RNDD); /* EXACT but can overflow */ + mpfr_set_q (y, x.backend().data(), GMP_RNDU); + double s = mpfr_get_d (y, GMP_RNDU); /* EXACT but can overflow */ + mpfr_clear (y); + return std::pair(i, s); +# endif + } + }; +}; +#endif + +template +struct Real_embeddable_traits > +: RET_boost_mp > {}; +template +struct Real_embeddable_traits > +: Real_embeddable_traits::result_type > {}; + +// Modular_traits + +template ::value> > +struct MT_boost_mp { + typedef T NT; + typedef ::CGAL::Tag_false Is_modularizable; + typedef ::CGAL::Null_functor Residue_type; + typedef ::CGAL::Null_functor Modular_image; + typedef ::CGAL::Null_functor Modular_image_representative; +}; + +template +struct MT_boost_mp > { + typedef T NT; + typedef CGAL::Tag_true Is_modularizable; + typedef Residue Residue_type; + + struct Modular_image{ + Residue_type operator()(const NT& a){ + NT tmp(CGAL::mod(a,NT(Residue::get_current_prime()))); + return CGAL::Residue(tmp.template convert_to()); + } + }; + struct Modular_image_representative{ + NT operator()(const Residue_type& x){ + return NT(x.get_value()); + } + }; +}; + +template +struct Modular_traits > +: MT_boost_mp > {}; +template +struct Modular_traits > +: Modular_traits::result_type > {}; + +// Split_double + +template ::value> > +struct SD_boost_mp { + void operator()(double d, NT &num, NT &den) const + { + num = d; + den = 1; + } +}; + +template +struct SD_boost_mp > +{ + void operator()(double d, NT &num, NT &den) const + { + std::pair p = split_numerator_denominator(d); + num = NT(p.first); + den = NT(p.second); + } +}; + +template +struct Split_double > +: SD_boost_mp > {}; +template +struct Split_double > +: Split_double::result_type > {}; + + +// Fraction_traits + +template ::value> > +struct FT_boost_mp { + typedef T Type; + typedef Tag_false Is_fraction; + typedef Null_tag Numerator_type; + typedef Null_tag Denominator_type; + typedef Null_functor Common_factor; + typedef Null_functor Decompose; + typedef Null_functor Compose; +}; + +template +struct FT_boost_mp > { + typedef NT Type; + + typedef ::CGAL::Tag_true Is_fraction; + typedef typename boost::multiprecision::component_type::type Numerator_type; + typedef Numerator_type Denominator_type; + + typedef typename Algebraic_structure_traits< Numerator_type >::Gcd Common_factor; + + class Decompose { + public: + typedef Type first_argument_type; + typedef Numerator_type& second_argument_type; + typedef Denominator_type& third_argument_type; + void operator () ( + const Type& rat, + Numerator_type& num, + Denominator_type& den) { + num = numerator(rat); + den = denominator(rat); + } + }; + + class Compose { + public: + typedef Numerator_type first_argument_type; + typedef Denominator_type second_argument_type; + typedef Type result_type; + Type operator ()( + const Numerator_type& num , + const Denominator_type& den ) { + return Type(num, den); + } + }; +}; + +template +struct Fraction_traits > +: FT_boost_mp > {}; +template +struct Fraction_traits > +: Fraction_traits::result_type > {}; + + +// Coercions + +namespace internal { namespace boost_mp { BOOST_MPL_HAS_XXX_TRAIT_DEF(type) } } + +template +struct Coercion_traits, boost::multiprecision::number > +{ + typedef boost::common_type, boost::multiprecision::number > CT; + typedef Boolean_tag::value> Are_implicit_interoperable; + // FIXME: the implicit/explicit answers shouldn't be the same... + typedef Are_implicit_interoperable Are_explicit_interoperable; + // FIXME: won't compile when they are not interoperable. + typedef typename CT::type Type; + struct Cast{ + typedef Type result_type; + template + Type operator()(const U& x) const { + return Type(x); + } + }; +}; +// Avoid ambiguity with the specialization for ... +template +struct Coercion_traits, boost::multiprecision::number > +{ + typedef boost::multiprecision::number Type; + typedef Tag_true Are_implicit_interoperable; + typedef Tag_true Are_explicit_interoperable; + struct Cast{ + typedef Type result_type; + template + Type operator()(const U& x) const { + return Type(x); + } + }; +}; + +template +struct Coercion_traits < +boost::multiprecision::detail::expression, +boost::multiprecision::detail::expression > +: Coercion_traits < +typename boost::multiprecision::detail::expression::result_type, +typename boost::multiprecision::detail::expression::result_type> +{ }; +// Avoid ambiguity with the specialization for ... +template +struct Coercion_traits < +boost::multiprecision::detail::expression, +boost::multiprecision::detail::expression > +: Coercion_traits < +typename boost::multiprecision::detail::expression::result_type, +typename boost::multiprecision::detail::expression::result_type> +{ }; + +template +struct Coercion_traits, boost::multiprecision::detail::expression > +: Coercion_traits < +boost::multiprecision::number, +typename boost::multiprecision::detail::expression::result_type> +{ }; + +template +struct Coercion_traits, boost::multiprecision::number > +: Coercion_traits < +typename boost::multiprecision::detail::expression::result_type, +boost::multiprecision::number > +{ }; + +// TODO: fix existing coercions +// (double -> rational is implicit only for 1.56+, see ticket #10082) +// The real solution would be to avoid specializing Coercion_traits for all pairs of number types and let it auto-detect what works, so only broken types need an explicit specialization. + +// Ignore types smaller than long +#define CGAL_COERCE_INT(int) \ +template \ +struct Coercion_traits, int> { \ + typedef boost::multiprecision::number Type; \ + typedef Tag_true Are_implicit_interoperable; \ + typedef Tag_true Are_explicit_interoperable; \ + struct Cast{ \ + typedef Type result_type; \ + template Type operator()(const U& x) const { return Type(x); } \ + }; \ +}; \ +template \ +struct Coercion_traits > \ +: Coercion_traits, int> {}; \ +template \ +struct Coercion_traits, int> \ +: Coercion_traits::result_type, int>{}; \ +template \ +struct Coercion_traits > \ +: Coercion_traits::result_type, int>{} + +CGAL_COERCE_INT(short); +CGAL_COERCE_INT(int); +CGAL_COERCE_INT(long); +#undef CGAL_COERCE_INT + +// Ignore bounded-precision rationals +#define CGAL_COERCE_FLOAT(float) \ +template \ +struct Coercion_traits, float> { \ + typedef boost::multiprecision::number Type; \ + typedef Boolean_tag::value != boost::multiprecision::number_kind_integer> Are_implicit_interoperable; \ + typedef Are_implicit_interoperable Are_explicit_interoperable; \ + struct Cast{ \ + typedef Type result_type; \ + template Type operator()(const U& x) const { return Type(x); } \ + }; \ +}; \ +template \ +struct Coercion_traits > \ +: Coercion_traits, float> {}; \ +template \ +struct Coercion_traits, float> \ +: Coercion_traits::result_type, float>{}; \ +template \ +struct Coercion_traits > \ +: Coercion_traits::result_type, float>{} + +CGAL_COERCE_FLOAT(float); +CGAL_COERCE_FLOAT(double); +#undef CGAL_COERCE_FLOAT + +// Because of https://github.com/boostorg/multiprecision/issues/29 , this is not perfect and fails to read some KDS files. + +template <> +class Input_rep : public IO_rep_is_specialized { + boost::multiprecision::cpp_rational& q; +public: + Input_rep(boost::multiprecision::cpp_rational& qq) : q(qq) {} + std::istream& operator()(std::istream& in) const { + internal::read_float_or_quotient(in, q); + return in; + } +}; +#ifdef CGAL_USE_GMP +template <> +class Input_rep : public IO_rep_is_specialized { + boost::multiprecision::mpq_rational& q; +public: + Input_rep(boost::multiprecision::mpq_rational& qq) : q(qq) {} + std::istream& operator()(std::istream& in) const { + internal::read_float_or_quotient(in, q); + return in; + } +}; +#endif + +// Copied from leda_rational.h +namespace internal { + // See: Stream_support/include/CGAL/IO/io.h + template + void read_float_or_quotient(std::istream & is, ET& et); + + template <> + inline void read_float_or_quotient(std::istream & is, boost::multiprecision::cpp_rational& et) + { + internal::read_float_or_quotient(is, et); + } +#ifdef CGAL_USE_GMP + template <> + inline void read_float_or_quotient(std::istream & is, boost::multiprecision::mpq_rational& et) + { + internal::read_float_or_quotient(is, et); + } +#endif +} // namespace internal + +#ifdef CGAL_USE_BOOST_MP + +template< > class Real_embeddable_traits< Quotient > + : public INTERN_QUOTIENT::Real_embeddable_traits_quotient_base< Quotient > { + + public: + typedef Quotient Type; + + class To_interval + : public CGAL::cpp98::unary_function< Type, std::pair< double, double > > { + public: + std::pair operator()( const Type& x ) const { + return Boost_MP_internal::to_interval(x.num, x.den); + } + }; +}; + +#endif // CGAL_USE_BOOST_MP + +} //namespace CGAL + +namespace Eigen { + template struct NumTraits; + template<> struct NumTraits + { + typedef boost::multiprecision::cpp_int Real; + typedef boost::multiprecision::cpp_rational NonInteger; + typedef boost::multiprecision::cpp_int Nested; + typedef boost::multiprecision::cpp_int Literal; + + static inline Real epsilon() { return 0; } + static inline Real dummy_precision() { return 0; } + + enum { + IsInteger = 1, + IsSigned = 1, + IsComplex = 0, + RequireInitialization = 1, + ReadCost = 6, + AddCost = 30, + MulCost = 50 + }; + }; + + template<> struct NumTraits + { + typedef boost::multiprecision::cpp_rational Real; + typedef boost::multiprecision::cpp_rational NonInteger; + typedef boost::multiprecision::cpp_rational Nested; + typedef boost::multiprecision::cpp_rational Literal; + + static inline Real epsilon() { return 0; } + static inline Real dummy_precision() { return 0; } + + enum { + IsInteger = 0, + IsSigned = 1, + IsComplex = 0, + RequireInitialization = 1, + ReadCost = 6, + AddCost = 150, + MulCost = 100 + }; + }; + +#ifdef CGAL_USE_GMP + + template<> struct NumTraits + { + typedef boost::multiprecision::mpz_int Real; + typedef boost::multiprecision::mpq_rational NonInteger; + typedef boost::multiprecision::mpz_int Nested; + typedef boost::multiprecision::mpz_int Literal; + + static inline Real epsilon() { return 0; } + static inline Real dummy_precision() { return 0; } + + enum { + IsInteger = 1, + IsSigned = 1, + IsComplex = 0, + RequireInitialization = 1, + ReadCost = 6, + AddCost = 30, + MulCost = 50 + }; + }; + + template<> struct NumTraits + { + typedef boost::multiprecision::mpq_rational Real; + typedef boost::multiprecision::mpq_rational NonInteger; + typedef boost::multiprecision::mpq_rational Nested; + typedef boost::multiprecision::mpq_rational Literal; + + static inline Real epsilon() { return 0; } + static inline Real dummy_precision() { return 0; } + + enum { + IsInteger = 0, + IsSigned = 1, + IsComplex = 0, + RequireInitialization = 1, + ReadCost = 6, + AddCost = 150, + MulCost = 100 + }; + }; +#endif // CGAL_USE_GMP + + +} // namespace Eigen + +#endif // BOOST_VERSION +#endif From 1ba311a602306d597a3cb699085ce53da7d20c9b Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 27 Oct 2022 10:40:01 +0100 Subject: [PATCH 029/139] Prefix macro with CORE_ --- CGAL_Core/include/CGAL/CORE/Promote.h | 38 +++++++++++------------ CGAL_Core/include/CGAL/CORE/poly/Poly.h | 6 ++-- CGAL_Core/include/CGAL/CORE/poly/Poly.tcc | 4 +-- 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/Promote.h b/CGAL_Core/include/CGAL/CORE/Promote.h index d4c95c25bf08..b084026e72ea 100644 --- a/CGAL_Core/include/CGAL/CORE/Promote.h +++ b/CGAL_Core/include/CGAL/CORE/Promote.h @@ -69,10 +69,10 @@ class Promotion { typedef T ResultT; }; -#define MAX_TYPE(T1, T2) \ +#define CORE_MAX_TYPE(T1, T2) \ typename Promotion::ResultT -#define DEFINE_MAX_TYPE(T1, T2, Tr) \ +#define CORE_DEFINE_MAX_TYPE(T1, T2, Tr) \ template<> class Promotion { \ public: \ typedef Tr ResultT; \ @@ -85,15 +85,15 @@ class Promotion { /* * For example: * - * DEFINE_MAX_TYPE(BigInt, BigRat, BigRat) // define the promotion + * CORE_DEFINE_MAX_TYPE(BigInt, BigRat, BigRat) // define the promotion * * template // define function f with type templates - * MAX_TYPE(T1, T2) f(T1& , T2& ); + * CORE_MAX_TYPE(T1, T2) f(T1& , T2& ); * * or * * template // define function f with type templates - * const MAX_TYPE(T1, T2)& f(T1& , T2& ); + * const CORE_MAX_TYPE(T1, T2)& f(T1& , T2& ); * * BigInt a = 1; * BigRat b = "1/3"; @@ -126,24 +126,24 @@ class BigFloat; //class BigRat; class Expr; -DEFINE_MAX_TYPE(long, BigInt, BigInt) -DEFINE_MAX_TYPE(long, BigFloat, BigFloat) -DEFINE_MAX_TYPE(long, BigRat, BigRat) -DEFINE_MAX_TYPE(long, Expr, Expr) +CORE_DEFINE_MAX_TYPE(long, BigInt, BigInt) +CORE_DEFINE_MAX_TYPE(long, BigFloat, BigFloat) +CORE_DEFINE_MAX_TYPE(long, BigRat, BigRat) +CORE_DEFINE_MAX_TYPE(long, Expr, Expr) -DEFINE_MAX_TYPE(int, BigInt, BigInt) -DEFINE_MAX_TYPE(int, BigFloat, BigFloat) -DEFINE_MAX_TYPE(int, BigRat, BigRat) -DEFINE_MAX_TYPE(int, Expr, Expr) +CORE_DEFINE_MAX_TYPE(int, BigInt, BigInt) +CORE_DEFINE_MAX_TYPE(int, BigFloat, BigFloat) +CORE_DEFINE_MAX_TYPE(int, BigRat, BigRat) +CORE_DEFINE_MAX_TYPE(int, Expr, Expr) -DEFINE_MAX_TYPE(BigInt, BigFloat, BigFloat) -DEFINE_MAX_TYPE(BigInt, BigRat, BigRat) -DEFINE_MAX_TYPE(BigInt, Expr, Expr) +CORE_DEFINE_MAX_TYPE(BigInt, BigFloat, BigFloat) +CORE_DEFINE_MAX_TYPE(BigInt, BigRat, BigRat) +CORE_DEFINE_MAX_TYPE(BigInt, Expr, Expr) -DEFINE_MAX_TYPE(BigFloat, BigRat, BigRat) -DEFINE_MAX_TYPE(BigFloat, Expr, Expr) +CORE_DEFINE_MAX_TYPE(BigFloat, BigRat, BigRat) +CORE_DEFINE_MAX_TYPE(BigFloat, Expr, Expr) -DEFINE_MAX_TYPE(BigRat, Expr, Expr) +CORE_DEFINE_MAX_TYPE(BigRat, Expr, Expr) } //namespace CORE diff --git a/CGAL_Core/include/CGAL/CORE/poly/Poly.h b/CGAL_Core/include/CGAL/CORE/poly/Poly.h index bd56376a5b24..445cbbb94ace 100644 --- a/CGAL_Core/include/CGAL/CORE/poly/Poly.h +++ b/CGAL_Core/include/CGAL/CORE/poly/Poly.h @@ -196,12 +196,10 @@ class Polynomial { /// In particular, if the value is 0, we return 0. /// @param oldMSB is any estimate of the negative log of the evaluation BigFloat evalExactSign(const BigFloat& val, const extLong& oldMSB=54) const; + /// Polynomial evaluation that return the same type as its argument - /// Caution: The type T must be greater or equal to the type NT - /// NOTE: Eventually, we will remove this restriction by - /// introduce MaxType(NT,T) for the return type. template - MAX_TYPE(NT, T) eval(const T&) const; + CORE_MAX_TYPE(NT, T) eval(const T&) const; // Bounds BigFloat CauchyUpperBound() const; // Cauchy Root Upper Bound diff --git a/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc b/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc index 325f64d528c8..65828f16db96 100644 --- a/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc +++ b/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc @@ -771,8 +771,8 @@ BigFloat Polynomial::eval(const BigFloat& f) const { // evaluation template template -MAX_TYPE(NT, T) Polynomial::eval(const T& f) const { // evaluation - typedef MAX_TYPE(NT, T) ResultT; +CORE_MAX_TYPE(NT, T) Polynomial::eval(const T& f) const { // evaluation + typedef CORE_MAX_TYPE(NT, T) ResultT; if (degree == -1) return ResultT(0); if (degree == 0) From 811e9530d6bfe58f880dc745a2634d0cf64c3b51 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 27 Oct 2022 10:44:15 +0100 Subject: [PATCH 030/139] clenup --- .../include/CGAL/CORE_arithmetic_kernel.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Arithmetic_kernel/include/CGAL/CORE_arithmetic_kernel.h b/Arithmetic_kernel/include/CGAL/CORE_arithmetic_kernel.h index 3fc908252acb..600092834e58 100644 --- a/Arithmetic_kernel/include/CGAL/CORE_arithmetic_kernel.h +++ b/Arithmetic_kernel/include/CGAL/CORE_arithmetic_kernel.h @@ -54,16 +54,6 @@ class CORE_arithmetic_kernel : public internal::Arithmetic_kernel_base { }; -#if 0 -template <> -struct Get_arithmetic_kernel{ - typedef CORE_arithmetic_kernel Arithmetic_kernel; -}; -template <> -struct Get_arithmetic_kernel{ - typedef CORE_arithmetic_kernel Arithmetic_kernel; -}; -#endif template <> struct Get_arithmetic_kernel{ From 81dc0a4c60dc659d7151693cc1cec117491d6e11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 27 Oct 2022 12:06:02 +0200 Subject: [PATCH 031/139] use GMP if boost less than 1.80 --- CGAL_Core/include/CGAL/CORE/BigInt.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index e709c7d5ef54..711df1166d7c 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -32,6 +32,10 @@ #if 1 +#if !(BOOST_VERSION > 107900 && defined(CGAL_USE_BOOST_MP)) +#define CGAL_CORE_USE_GMP_BACKEND 1 +#endif + namespace CORE { #ifdef CGAL_CORE_USE_GMP_BACKEND From 015b927d2e49314dcf7b0d2c10a7952a710d05c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 27 Oct 2022 12:27:49 +0200 Subject: [PATCH 032/139] add Is_square --- Number_types/include/CGAL/boost_mp_type.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Number_types/include/CGAL/boost_mp_type.h b/Number_types/include/CGAL/boost_mp_type.h index 1a0d78f18215..d8f77fbbcba5 100644 --- a/Number_types/include/CGAL/boost_mp_type.h +++ b/Number_types/include/CGAL/boost_mp_type.h @@ -89,6 +89,8 @@ struct AST_boost_mp ::is_exact> Is_exact; typedef Tag_false Is_numerical_sensitive; + typedef INTERN_AST::Is_square_per_sqrt< Type > Is_square; + struct Is_zero: public CGAL::cpp98::unary_function { bool operator()( const Type& x) const { return x.is_zero(); From 7c50cf7821a79b3a1b0a2989c53fe12d82aa7f60 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 27 Oct 2022 11:43:05 +0100 Subject: [PATCH 033/139] Make Counted_number work --- Number_types/include/CGAL/Counted_number.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Number_types/include/CGAL/Counted_number.h b/Number_types/include/CGAL/Counted_number.h index bb3dc060f0e5..87de07ebc343 100644 --- a/Number_types/include/CGAL/Counted_number.h +++ b/Number_types/include/CGAL/Counted_number.h @@ -121,8 +121,12 @@ class Counted_number { Counted_number() {} //explicit Counted_number(int n) :m_rep(n){} explicit Counted_number(NT n) :m_rep(n){} + Counted_number operator-() const - {inc_neg_count();return Counted_number(-m_rep);} + { + inc_neg_count(); NT neg = -m_rep; return Counted_number(neg); + } + Counted_number const & operator+=(Counted_number const &n) { inc_add_count(); From d777cd02184fb3f5f7ffbcc7cf902b66b884b98f Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 27 Oct 2022 12:17:49 +0100 Subject: [PATCH 034/139] Deal with expressions --- CGAL_Core/include/CGAL/CORE/Real.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/Real.h b/CGAL_Core/include/CGAL/CORE/Real.h index 78a094adcfaf..ec7cc8878d50 100644 --- a/CGAL_Core/include/CGAL/CORE/Real.h +++ b/CGAL_Core/include/CGAL/CORE/Real.h @@ -282,7 +282,7 @@ struct _real_add { // specialized for two long values static Real eval(long a, long b) { if ((a > halfLongMax && b > halfLongMax) || (a < halfLongMin && b < halfLongMin)) - return BigInt(a)+BigInt(b); + return BigInt(BigInt(a)+ BigInt(b)); else return a+b; } @@ -296,7 +296,7 @@ struct _real_sub { // specialized for two long values static Real eval(long a, long b) { if ((a > halfLongMax && b < halfLongMin) || (a < halfLongMin && b > halfLongMax)) - return BigInt(a)-BigInt(b); + return BigInt(BigInt(a)-BigInt(b)); else return a-b; } @@ -310,7 +310,7 @@ struct _real_mul { // specialized for two long values static Real eval(long a, long b) { if (flrLg(a) + flrLg(b) >= static_cast(LONG_BIT-2)) - return BigInt(a)*BigInt(b); + return BigInt(BigInt(a)*BigInt(b)); else return a*b; } From bf1f7d74be1b83acd2a87fb1ad20baaa1bdb7d84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 27 Oct 2022 13:10:40 +0200 Subject: [PATCH 035/139] add missing inline --- CGAL_Core/include/CGAL/CORE/BigFloat.h | 16 ++++++++-------- CGAL_Core/include/CGAL/CORE/BigInt.h | 6 +++--- CGAL_Core/include/CGAL/CORE/BigRat.h | 11 ++++++----- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigFloat.h b/CGAL_Core/include/CGAL/CORE/BigFloat.h index c5df8cb8134d..794bc25d447b 100644 --- a/CGAL_Core/include/CGAL/CORE/BigFloat.h +++ b/CGAL_Core/include/CGAL/CORE/BigFloat.h @@ -621,15 +621,15 @@ inline BigRat::BigRat(const BigFloat& f) : RCBigRat(new BigRatRep()){ } */ - double doubleValue(const BigFloat& bf) - { - return bf.doubleValue(); - } +inline double doubleValue(const BigFloat& bf) +{ + return bf.doubleValue(); +} - long longValue(const BigFloat& bf) - { - return bf.longValue(); - } +inline long longValue(const BigFloat& bf) +{ + return bf.longValue(); +} } //namespace CORE diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 711df1166d7c..84dfb62950eb 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -50,7 +50,7 @@ inline int cmp(const BigInt& x, const BigInt& y) { } - int set_str(BigInt& a, const char* s) { +inline int set_str(BigInt& a, const char* s) { // AF makeCopy(); a = BigInt(s); return 0; // should be -1 if not correct in the base (we ignore) @@ -75,7 +75,7 @@ inline bool isOdd(const BigInt& z) { return bit_test(z,0) == 1; } - inline bool isDivisible(const BigInt& x, const BigInt& y) { +inline bool isDivisible(const BigInt& x, const BigInt& y) { BigInt q, r; divide_qr(x, y, q, r); return r.is_zero(); @@ -194,7 +194,7 @@ inline void getKaryExpo(const BigInt& z, BigInt& m, int& e, unsigned long uk) { } } - inline void power(BigInt& c, const BigInt& a, unsigned long ul) { +inline void power(BigInt& c, const BigInt& a, unsigned long ul) { // AF c.makeCopy(); c = pow(a, ul); } diff --git a/CGAL_Core/include/CGAL/CORE/BigRat.h b/CGAL_Core/include/CGAL/CORE/BigRat.h index cd4747303d96..a616523ff119 100644 --- a/CGAL_Core/include/CGAL/CORE/BigRat.h +++ b/CGAL_Core/include/CGAL/CORE/BigRat.h @@ -37,11 +37,12 @@ namespace CORE { /// BigIntValue - BigInt BigIntValue(const BigRat& br) { - BigInt r, rem; - divide_qr(numerator(br), denominator(br), r, rem); - return r; - } +inline BigInt BigIntValue(const BigRat& br) +{ + BigInt r, rem; + divide_qr(numerator(br), denominator(br), r, rem); + return r; +} } // namespace CORE From d498154b5f8fcc692f97fb06901763fbdece9a26 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 6 Feb 2023 14:02:51 +0000 Subject: [PATCH 036/139] Remove #if 0'ed code --- CGAL_Core/include/CGAL/CORE/BigInt.h | 559 ---------------------- CGAL_Core/include/CGAL/CORE/BigRat.h | 464 ------------------ CGAL_Core/include/CGAL/CORE/CoreIO_impl.h | 119 ----- CGAL_Core/include/CGAL/CORE/Promote.h | 6 +- 4 files changed, 3 insertions(+), 1145 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 84dfb62950eb..d93530b59b46 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -30,7 +30,6 @@ #include #include -#if 1 #if !(BOOST_VERSION > 107900 && defined(CGAL_USE_BOOST_MP)) #define CGAL_CORE_USE_GMP_BACKEND 1 @@ -201,564 +200,6 @@ inline void power(BigInt& c, const BigInt& a, unsigned long ul) { } // namespace CORE -#else - - -namespace CORE { - -#ifdef CGAL_CORE_USE_GMP_BACKEND - typedef boost::multiprecision::mpz_int Z; -#else - typedef boost::multiprecision::cpp_int Z; -#endif - - - - class BigIntRep : public RCRepImpl { -public: - BigIntRep() - : mp() - {} - - // Note : should the copy-ctor be allowed at all ? [Sylvain Pion] - BigIntRep(const BigIntRep& z) : RCRepImpl(), mp(z.mp) - {} - - template - BigIntRep(T c) - : mp(c) - {} - - BigIntRep(const std::string& s) - : mp(s) - {} - - - explicit BigIntRep(const Z& z) - : mp(z) - {} - /* - ~BigIntRep() { - mpz_clear(mp); - } - */ - - //CGAL_CORE_EXPORT CORE_NEW(BigIntRep) - //CGAL_CORE_EXPORT CORE_DELETE(BigIntRep) - - const Z& get_mp() const { - return mp; - } - Z& get_mp() { - return mp; - } -private: - Z mp; -}; - - //typedef RCImpl RCBigInt; - -class CGAL_CORE_EXPORT BigInt : public RCImpl { -public: - - typedef RCImpl RCBigInt; - - /// \name Constructors - //@{ - /// default constructor - BigInt() : RCBigInt(new BigIntRep()) {} - BigInt(const Z& z) : RCBigInt(new BigIntRep(z)) {} - /// constructor for signed char - BigInt(signed char x) : RCBigInt(new BigIntRep(x)) {} - /// constructor for unsigned char - BigInt(unsigned char x) : RCBigInt(new BigIntRep(x)) {} - /// constructor for signed short int - BigInt(signed short int x) : RCBigInt(new BigIntRep(x)) {} - /// constructor for unsigned short int - BigInt(unsigned short int x) : RCBigInt(new BigIntRep(x)) {} - /// constructor for signed int - BigInt(signed int x) : RCBigInt(new BigIntRep(x)) {} - /// constructor for unsigned int - BigInt(unsigned int x) : RCBigInt(new BigIntRep(x)) {} - /// constructor for signed long int - BigInt(signed long int x) : RCBigInt(new BigIntRep(x)) {} - /// constructor for unsigned long int - BigInt(unsigned long int x) : RCBigInt(new BigIntRep(x)) {} - /// constructor for float - BigInt(float x) : RCBigInt(new BigIntRep(x)) {} - /// constructor for double - BigInt(double x) : RCBigInt(new BigIntRep(x)) {} - - /// constructor for std::string - BigInt(const std::string& s) : RCBigInt(new BigIntRep(s)) {} - - /// constructor for mpz_srcptr - // explicit BigInt(mpz_srcptr z) : RCBigInt(new BigIntRep(z)) {} - //@} - - /// \name Copy-Assignment-Destructor - //@{ - /// copy constructor - BigInt(const BigInt& rhs) : RCBigInt(rhs) { - rep->incRef(); - } - /// assignment operator - BigInt& operator=(const BigInt& rhs) { - if (this != &rhs) { - rep->decRef(); - rep = rhs.rep; - rep->incRef(); - } - return *this; - } - /// destructor - ~BigInt() { - rep->decRef(); - } - //@} - - /// \name Overloaded operators - //@{ - BigInt& operator +=(const BigInt& rhs) { - makeCopy(); - get_mp() += rhs.get_mp(); - return *this; - } - - BigInt& operator -=(const BigInt& rhs) { - makeCopy(); - get_mp() -= rhs.get_mp(); - return *this; - } - BigInt& operator *=(const BigInt& rhs) { - makeCopy(); - get_mp() *= rhs.get_mp(); - return *this; - } - BigInt& operator /=(const BigInt& rhs) { - makeCopy(); - get_mp() /= rhs.get_mp(); - return *this; - } - BigInt& operator %=(const BigInt& rhs) { - makeCopy(); - get_mp() %= rhs.get_mp(); - return *this; - } - BigInt& operator &=(const BigInt& rhs) { - makeCopy(); - get_mp() &= rhs.get_mp(); - return *this; - } - BigInt& operator |=(const BigInt& rhs) { - makeCopy(); - get_mp() |= rhs.get_mp(); - return *this; - } - BigInt& operator ^=(const BigInt& rhs) { - makeCopy(); - get_mp() ^= rhs.get_mp(); - return *this; - } - BigInt& operator <<=(unsigned long ul) { - makeCopy(); - get_mp() <<= ul; - return *this; - } - BigInt& operator >>=(unsigned long ul) { - makeCopy(); - get_mp() >>= ul; - return *this; - } - //@} - - /// \name unary, increment, decrement operators - //@{ - BigInt operator+() const { - return BigInt(*this); - } - BigInt operator-() const { - BigInt r; - r.get_mp() = -get_mp(); - return r; - } - BigInt& operator++() { - makeCopy(); - ++get_mp(); - return *this; - } - BigInt& operator--() { - makeCopy(); - --get_mp(); - return *this; - } - BigInt operator++(int) { - BigInt r(*this); - ++(*this); - return r; - } - BigInt operator--(int) { - BigInt r(*this); - --(*this); - return r; - } - //@} - - /// \name Helper Functions - //@{ - /// Has Exact Division - static bool hasExactDivision() { - return false; - } - /// get mpz pointer (const) - const Z& get_mp() const { - return rep->get_mp(); - } - /// get mpz pointer - Z& get_mp() { - return rep->get_mp(); - } - //@} - - /// \name String Conversion Functions - //@{ - /// set value from const char* - int set_str(const char* s) { - makeCopy(); - get_mp() = Z(s); - return 0; // should be -1 if not correct in the base (we ignore) - } - /// convert to std::string - std::string get_str() const { - return get_mp().convert_to(); - } - //@} - - /// \name Conversion Functions - //@{ - /// intValue - int intValue() const { - return get_mp().convert_to(); - } - /// longValue - long longValue() const { - return get_mp().convert_to(); - } - /// ulongValue - unsigned long ulongValue() const { - return get_mp().convert_to(); - } - /// doubleValue - double doubleValue() const { - return get_mp().convert_to(); - } - //@} -}; - -inline BigInt operator+(const BigInt& a, const BigInt& b) { - BigInt r; - r.get_mp() = a.get_mp() + b.get_mp(); - return r; -} - -inline BigInt operator-(const BigInt& a, const BigInt& b) { - BigInt r; - r.get_mp() = a.get_mp() - b.get_mp(); - return r; -} - -inline BigInt operator*(const BigInt& a, const BigInt& b) { - BigInt r; - r.get_mp() = a.get_mp() * b.get_mp(); - return r; -} - -inline BigInt operator/(const BigInt& a, const BigInt& b) { - BigInt r; - r.get_mp() = a.get_mp() / b.get_mp(); - return r; -} - -inline BigInt operator%(const BigInt& a, const BigInt& b) { - BigInt r; - r.get_mp() = a.get_mp() % b.get_mp(); - return r; -} - -inline BigInt operator&(const BigInt& a, const BigInt& b) { - BigInt r; - r.get_mp() = a.get_mp() & b.get_mp(); - return r; -} - -inline BigInt operator|(const BigInt& a, const BigInt& b) { - BigInt r; - r.get_mp() = a.get_mp()| b.get_mp(); - return r; -} - -inline BigInt operator^(const BigInt& a, const BigInt& b) { - BigInt r; - r.get_mp() = a.get_mp() ^ b.get_mp(); - return r; -} - -inline BigInt operator<<(const BigInt& a, unsigned long ul) { - BigInt r; - r.get_mp() = a.get_mp() << ul; - return r; -} - -inline BigInt operator>>(const BigInt& a, unsigned long ul) { - BigInt r; - r.get_mp() = a.get_mp() >> ul; - return r; -} - - -inline int cmp(const BigInt& x, const BigInt& y) { - return x.get_mp().compare(y.get_mp()); -} - - -inline bool operator==(const BigInt& a, const BigInt& b) { - return cmp(a, b) == 0; -} - -inline bool operator!=(const BigInt& a, const BigInt& b) { - return cmp(a, b) != 0; -} - -inline bool operator>=(const BigInt& a, const BigInt& b) { - return cmp(a, b) >= 0; -} - -inline bool operator>(const BigInt& a, const BigInt& b) { - return cmp(a, b) > 0; -} - -inline bool operator<=(const BigInt& a, const BigInt& b) { - return cmp(a, b) <= 0; -} - -inline bool operator<(const BigInt& a, const BigInt& b) { - return cmp(a, b) < 0; -} - -inline std::ostream& operator<<(std::ostream& o, const BigInt& x) { - return o <>(std::istream& i, BigInt& x) { - x.makeCopy(); - return i >> x.get_mp(); -} - -/// sign -inline int sign(const BigInt& a) { - return sign(a.get_mp()); -} - -/// abs -inline BigInt abs(const BigInt& a) { - BigInt r; - r.get_mp() = abs(a.get_mp()); - return r; -} - -/// neg -inline BigInt neg(const BigInt& a) { - BigInt r; - r.get_mp() = - a.get_mp(); - return r; -} - -/// negate -inline void negate(BigInt& a) { - a.makeCopy(); - a.get_mp() = - a.get_mp(); -} -/// cmpabs -inline int cmpabs(const BigInt& a, const BigInt& b) { - return cmp(abs(a), abs(b)); - return 0; -} - -/// \name Conversion Functions -//@{ -/// longValue -inline long longValue(const BigInt& a) { - return a.longValue(); -} - -/// ulongValue -inline unsigned long ulongValue(const BigInt& a) { - assert(a >= BigInt(0)); - return a.ulongValue(); -} - -/// doubleValue -inline double doubleValue(const BigInt& a) { - return a.doubleValue(); -} -//@} - -/* - -/// \name File I/O Functions -//@{ -/// read from file - -void readFromFile(BigInt& z, std::istream& in, long maxLength = 0); -/// write to file -void writeToFile(const BigInt& z, std::ostream& in, int charsPerLine=80); -//@} -*/ - - -/// \name Misc Functions -//@{ -/// isEven -inline bool isEven(const BigInt& z) { - return bit_test(z.get_mp(),0) == 0; -} -/// isOdd -inline bool isOdd(const BigInt& z) { - return bit_test(z.get_mp(),0) == 1; -} - -/// get exponent of power 2 -inline unsigned long getBinExpo(const BigInt& z) { - if (z.get_mp().is_zero()) { - return (std::numeric_limits::max)(); - } - return lsb(abs(z.get_mp())); -} - -/// get exponent of power k -inline void getKaryExpo(const BigInt& z, BigInt& m, int& e, unsigned long uk) { - BigInt k(uk), q, r; - e = 0; - m = z; - m.makeCopy(); - for(;;) { - divide_qr(m.get_mp(), k.get_mp(), q.get_mp(), r.get_mp()); - if (!r.get_mp().is_zero()) break; - m.get_mp() = q.get_mp(); - ++e; - } -} - -/// divisible(x,y) = "x | y" -inline bool isDivisible(const BigInt& x, const BigInt& y) { - BigInt q, r; - divide_qr(x.get_mp(), y.get_mp(), q.get_mp(), r.get_mp()); - return r.get_mp().is_zero(); -} - -inline bool isDivisible(int x, int y) { - return x % y == 0; -} - -inline bool isDivisible(long x, long y) { - return x % y == 0; - -} -/// exact div -inline void divexact(BigInt& z, const BigInt& x, const BigInt& y) { - z.makeCopy(); - BigInt r; - divide_qr(x.get_mp(), y.get_mp(), z.get_mp(), r.get_mp() ); // was void mpz_divexact (mpz_t q, const mpz_t n, const mpz_t d) Is this faster? - assert(r.get_mp().is_zero()); -} - -// Chee (1/12/2004) The definition of div_exact(x,y) next -// ensure that in Polynomials works with both NT=BigInt and NT=int: -inline BigInt div_exact(const BigInt& x, const BigInt& y) { - BigInt z; // precodition: isDivisible(x,y) - divexact(z, x, y); // z is set to x/y; - return z; -} - -inline int div_exact(int x, int y) { - return x/y; // precondition: isDivisible(x,y) -} - -inline long div_exact(long x, long y) { - return x/y; // precondition: isDivisible(x,y) -} - - -/// gcd -inline BigInt gcd(const BigInt& a, const BigInt& b) { - BigInt r; - r.get_mp() = gcd(a.get_mp(), b.get_mp()); - return r; -} - -/// div_rem -inline void div_rem(BigInt& q, BigInt& r, const BigInt& a, const BigInt& b) { - q.makeCopy(); - r.makeCopy(); - divide_qr(a.get_mp(), b.get_mp(), q.get_mp(), r.get_mp()); -} - -/// power -inline void power(BigInt& c, const BigInt& a, unsigned long ul) { - c.makeCopy(); - //c.get_mp() = pow(a.get_mp(), ul); -} - -// pow -inline BigInt pow(const BigInt& a, unsigned long ui) { - BigInt r; - power(r, a, ui); - return r; -} - -// bit length -inline int bitLength(const BigInt& a) { - if (a.get_mp().is_zero()) { - return 0; - } - return msb(abs(a.get_mp()))+1; -} - -/// floorLg -- floor of log_2(a) -/** Convention: a=0, floorLg(a) returns -1. - * This makes sense for integer a. - */ -inline long floorLg(const BigInt& a) { - return (sign(a) == 0) ? (-1) : (bitLength(a)-1); -} - -/// ceilLg -- ceiling of log_2(a) where a=BigInt, int or long -/** Convention: a=0, ceilLg(a) returns -1. - * This makes sense for integer a. - */ -inline long ceilLg(const BigInt& a) { - if (sign(a) == 0) - return -1; - unsigned long len = bitLength(a); - - return (lsb(abs(a.get_mp())) == len - 1) ? (len - 1) : len; -} - -inline long ceilLg(long a) { // need this for Polynomial - return ceilLg(BigInt(a)); -} - -inline long ceilLg(int a) { // need this for Polynomial - return ceilLg(BigInt(a)); -} - -//@} - - - -} //namespace CORE - -#endif #endif // _CORE_BIGINT_H_ diff --git a/CGAL_Core/include/CGAL/CORE/BigRat.h b/CGAL_Core/include/CGAL/CORE/BigRat.h index a616523ff119..7234d1ba0ec0 100644 --- a/CGAL_Core/include/CGAL/CORE/BigRat.h +++ b/CGAL_Core/include/CGAL/CORE/BigRat.h @@ -27,7 +27,6 @@ #include -#if 1 namespace CORE { #ifdef CGAL_CORE_USE_GMP_BACKEND typedef boost::multiprecision::mpq_rational BigRat; @@ -46,468 +45,5 @@ inline BigInt BigIntValue(const BigRat& br) } // namespace CORE -#else - -namespace CORE { - -#ifdef CGAL_CORE_USE_GMP_BACKEND - typedef boost::multiprecision::mpq_rational Q; -#else - typedef boost::multiprecision::cpp_rational Q; -#endif - -class BigRatRep : public RCRepImpl { -public: - BigRatRep() - : mp() - {} - - // Note : should the copy-ctor be alloed at all ? [Sylvain Pion] - BigRatRep(const BigRatRep& z) : RCRepImpl(), mp(z.mp) - {} - - - BigRatRep(signed char c) - : mp(c) - {} - - BigRatRep(unsigned char c) - : mp(c) - {} - - BigRatRep(signed int i) - : mp(i) - {} - - BigRatRep(unsigned int i) - : mp(i) - {} - - BigRatRep(signed short int s) - : mp(s) - {} - - BigRatRep(unsigned short int s) - : mp(s) - {} - - BigRatRep(signed long int l) - : mp(l) - {} - - BigRatRep(unsigned long int l) - : mp(l) - {} - - BigRatRep(float f) - : mp(f) - {} - - BigRatRep(double d) - : mp(d) - {} - - BigRatRep(const char* s) - : mp(s) - {} - - BigRatRep(const std::string& s) - : mp(s) - {} - - explicit BigRatRep(const Z& q) - : mp(q) - {} - - BigRatRep(const Z& n, const Z& d) - : mp(n,d) - {} - - - //CGAL_CORE_EXPORT CORE_NEW(BigRatRep) -// CGAL_CORE_EXPORT CORE_DELETE(BigRatRep) - - const Q& get_mp() const { - return mp; - } - Q& get_mp() { - return mp; - } -private: - Q mp; -}; //BigRatRep - -class BigFloat; - -typedef RCImpl RCBigRat; -class BigRat : public RCBigRat { -public: - /// \name Constructors - //@{ - /// default constructor - BigRat() : RCBigRat(new BigRatRep()) {} - /// constructor for signed char - BigRat(signed char x) : RCBigRat(new BigRatRep(x)) {} - /// constructor for unsigned char - BigRat(unsigned char x) : RCBigRat(new BigRatRep(x)) {} - /// constructor for signed short int - BigRat(signed short int x) : RCBigRat(new BigRatRep(x)) {} - /// constructor for unsigned short int - BigRat(unsigned short int x) : RCBigRat(new BigRatRep(x)) {} - /// constructor for signed int - BigRat(signed int x) : RCBigRat(new BigRatRep(x)) {} - /// constructor for unsigned int - BigRat(unsigned int x) : RCBigRat(new BigRatRep(x)) {} - /// constructor for signed long int - BigRat(signed long int x) : RCBigRat(new BigRatRep(x)) {} - /// constructor for unsigned long int - BigRat(unsigned long int x) : RCBigRat(new BigRatRep(x)) {} - /// constructor for float - BigRat(float x) : RCBigRat(new BigRatRep(x)) {} - /// constructor for double - BigRat(double x) : RCBigRat(new BigRatRep(x)) {} - /// constructor for const char* with base - BigRat(const char* s) : RCBigRat(new BigRatRep(s)) {} - /// constructor for std::string with base - BigRat(const std::string& s) : RCBigRat(new BigRatRep(s)) {} - /// constructor for mpq_srcptr - explicit BigRat(const Z& z) : RCBigRat(new BigRatRep(z)) {} - /// constructor for BigInt - BigRat(const BigInt& z) : RCBigRat(new BigRatRep(z.get_mp())) {} - /// constructor for two BigInts - BigRat(const BigInt& n, const BigInt& d) - : RCBigRat(new BigRatRep(n.get_mp(), d.get_mp())) {} - /// constructor for BigFloat - BigRat(const BigFloat&); - //@} - - /// \name Copy-Assignment-Destructor - //@{ - /// copy constructor - BigRat(const BigRat& rhs) : RCBigRat(rhs) { - rep->incRef(); - } - /// assignment operator - BigRat& operator=(const BigRat& rhs) { - if (this != &rhs) { - rep->decRef(); - rep = rhs.rep; - rep->incRef(); - } - return *this; - } - /// destructor - ~BigRat() { - rep->decRef(); - } - //@} - - /// \name Overloaded operators - //@{ - BigRat& operator +=(const BigRat& rhs) { - makeCopy(); - get_mp() += rhs.get_mp(); - return *this; - } - BigRat& operator -=(const BigRat& rhs) { - makeCopy(); - get_mp() -= rhs.get_mp(); - return *this; - } - BigRat& operator *=(const BigRat& rhs) { - makeCopy(); - get_mp() *= rhs.get_mp(); - return *this; - } - BigRat& operator /=(const BigRat& rhs) { - makeCopy(); - get_mp() /= rhs.get_mp(); - return *this; - } - - /* - BigRat& operator <<=(unsigned long ul) { - makeCopy(); - assert(false); - // AF no shift for Q get_mp() <<= ul; - return *this; - } - BigRat& operator >>=(unsigned long ul) { - makeCopy(); - assert(false); - // AF no >> for Q get_mp() >>= ul; - return *this; - } - */ - //@} - - /// \name div2, unary, increment, decrement operators - //@{ - - /// exact division by 2 (this method is provided for compatibility) - BigRat div2() const { - BigRat r; BigRat t(2); // probably not most efficient way - r.get_mp() = get_mp() / t.get_mp(); - return r; - } - BigRat operator+() const { - return BigRat(*this); - } - BigRat operator-() const { - BigRat r; - r.get_mp() = - get_mp(); - return r; - } - BigRat& operator++() { - makeCopy(); - ++get_mp(); - return *this; - } - BigRat& operator--() { - makeCopy(); - --get_mp(); - return *this; - } - BigRat operator++(int) { - BigRat r(*this); - ++(*this); - return r; - } - BigRat operator--(int) { - BigRat r(*this); - --(*this); - return r; - } - //@} - - /// \name Helper Functions - //@{ - /// Canonicalize - - /* - void canonicalize() { - makeCopy(); - assert(false); - // AF todo mpq_canonicalize(get_mp()); - } - */ - - /// Has Exact Division - static bool hasExactDivision() { - return true; - } - - /// return mpz pointer of numerator (const) - Z get_num_mp() const { - return numerator(get_mp()); - } - /// return mpz pointer of numerator // no references as numerator() returns a copy - Z get_num_mp() { - return numerator(get_mp()); - } - /// return mpz pointer of denominator - Z get_den_mp() const { - return denominator(get_mp()); - } - /// return mpz pointer of denominator - Z get_den_mp() { - return denominator(get_mp()); - } - - /// get mpq pointer (const) - const Q& get_mp() const { - return rep->get_mp(); - } - /// get mpq pointer - Q& get_mp() { - return rep->get_mp(); - } - //@} - - /// \name String Conversion Functions - //@{ - /// set value from const char* - int set_str(const char* s, int base = 0) { - makeCopy(); - get_mp() = Q(s); - return 0; - } - /// convert to std::string - std::string get_str(int base = 10) const { - return get_mp().convert_to(); - } - //@} - - /// \name Conversion Functions - //@{ - /// intValue - int intValue() const { - return get_mp().convert_to(); - } - /// longValue - long longValue() const { - return get_mp().convert_to(); - } - - /// doubleValue - double doubleValue() const { - return get_mp().convert_to(); - } - /// BigIntValue - BigInt BigIntValue() const { - BigInt r; - Z rem; - divide_qr(get_num_mp(),get_den_mp(), r.get_mp(), rem); - return r; - } - //@} -}; //BigRat class - -inline BigRat operator+(const BigRat& a, const BigRat& b) { - BigRat r; - r.get_mp() = a.get_mp() + b.get_mp(); - return r; -} -inline BigRat operator-(const BigRat& a, const BigRat& b) { - BigRat r; - r.get_mp() = a.get_mp() - b.get_mp(); - return r; -} -inline BigRat operator*(const BigRat& a, const BigRat& b) { - BigRat r; - r.get_mp() = a.get_mp() * b.get_mp(); - return r; -} -inline BigRat operator/(const BigRat& a, const BigRat& b) { - BigRat r; - r.get_mp() = a.get_mp() / b.get_mp(); - return r; -} -// Chee (3/19/2004): -// The following definitions of div_exact(x,y) and gcd(x,y) -// ensures that in Polynomial -/// divisible(x,y) = "x | y" -inline BigRat div_exact(const BigRat& x, const BigRat& y) { - BigRat z; - z.get_mp() = x.get_mp() / y.get_mp(); - return z; -} -/// numerator -inline BigInt numerator(const BigRat& a) { - return BigInt(a.get_num_mp()); -} -/// denominator -inline BigInt denominator(const BigRat& a) { - return BigInt(a.get_den_mp()); -} - -inline BigRat gcd(const BigRat& x, const BigRat& y) { - // return BigRat(1); // Remark: we may want replace this by - // the definition of gcd of a quotient field - // of a UFD [Yap's book, Chap.3] - //Here is one possible definition: gcd of x and y is just the - //gcd of the numerators of x and y divided by the gcd of the - //denominators of x and y. - BigInt n = gcd(numerator(x), numerator(y)); - BigInt d = gcd(denominator(x), denominator(y)); - return BigRat(n,d); - -} -// Chee: 8/8/2004: need isDivisible to compile Polynomial -// A trivial implementation is to return true always. But this -// caused tPolyRat to fail. -// So we follow the definition of -// Expr::isDivisible(e1, e2) which checks if e1/e2 is an integer. -inline bool isInteger(const BigRat& x) { - return BigInt(x.get_den_mp()) == 1; -} -inline bool isDivisible(const BigRat& x, const BigRat& y) { - BigRat r; - r.get_mp() = x.get_mp() / y.get_mp(); - return isInteger(r); -} - - /* -inline BigRat operator<<(const BigRat& a, unsigned long ul) { - BigRat r; - assert(false); - //AF todo no << for Q r.get_mp() = a.get_mp() << int(ul) ; - return r; -} -inline BigRat operator>>(const BigRat& a, unsigned long ul) { - BigRat r; - assert(false); - // AF todo no >> for Q r.get_mp() = a.get_mp() >> ul; - return r; -} - */ -inline int cmp(const BigRat& x, const BigRat& y) { - return x.get_mp().compare(y.get_mp()); -} -inline bool operator==(const BigRat& a, const BigRat& b) { - return cmp(a, b) == 0; -} -inline bool operator!=(const BigRat& a, const BigRat& b) { - return cmp(a, b) != 0; -} -inline bool operator>=(const BigRat& a, const BigRat& b) { - return cmp(a, b) >= 0; -} -inline bool operator>(const BigRat& a, const BigRat& b) { - return cmp(a, b) > 0; -} -inline bool operator<=(const BigRat& a, const BigRat& b) { - return cmp(a, b) <= 0; -} -inline bool operator<(const BigRat& a, const BigRat& b) { - return cmp(a, b) < 0; -} - -inline std::ostream& operator<<(std::ostream& o, const BigRat& x) { - return o << x.get_mp(); -} -inline std::istream& operator>>(std::istream& i, BigRat& x) { - x.makeCopy(); - return i >> x.get_mp(); -} - -/// sign -inline int sign(const BigRat& a) { - return sign(a.get_mp()); -} -/// abs -inline BigRat abs(const BigRat& a) { - BigRat r; - r.get_mp() = abs( a.get_mp()); - return r; -} -/// neg -inline BigRat neg(const BigRat& a) { - BigRat r; - r.get_mp() = - a.get_mp(); - return r; -} -/// div2 -inline BigRat div2(const BigRat& a) { - BigRat r(a); - return r.div2(); -} -/// longValue -inline long longValue(const BigRat& a) { - return a.longValue(); -} -/// doubleValue -inline double doubleValue(const BigRat& a) { - return a.doubleValue(); -} -/// return BigInt value -inline BigInt BigIntValue(const BigRat& a) { - return a.BigIntValue(); -} - - -} //namespace CORE - -#endif #endif // _CORE_BIGRAT_H_ diff --git a/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h b/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h index df803aee9b8e..f6108f950ae1 100644 --- a/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h +++ b/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h @@ -143,78 +143,6 @@ void read_string(std::istream& in, char* &buffer, int sz) { append_char(buffer, sz, pos, '\0'); } -CGAL_INLINE_FUNCTION -void read_base_number(std::istream& in, BigInt& m, long length, long maxBits) { - char *buffer; - int size, offset; - int base; - bool is_negate; - - char c; - int pos = 0; - skip_comment_line(in); - - // read sign - in.get(c); - if (c == '-') { - is_negate = true; - in.get(c); - } else - is_negate = false; - - // read base and compute digits - if (c == '0') { - assert(false); // no longer supported - in.get(c); - if (c == 'b') { - base = 2; - size = (maxBits == 0 || maxBits > length) ? length : maxBits; - offset = length - size; - } else if (c == 'x') { - base = 16; - size = (maxBits == 0) ? length : (maxBits+3) >> 2; - size = (size > length) ? length : size; - offset = (length - size) << 2; - } else { - base = 8; - size = (maxBits == 0) ? length : (maxBits+2) / 3; - size = (size > length) ? length : size; - offset = (length - size) * 3; - in.putback(c); - } - } else { - base = 10; - size = (maxBits == 0) ? length : (int)std::ceil(maxBits*std::log(2.0)/std::log(10.0)); - size = (size > length) ? length : size; - offset = length - size; - in.putback(c); - } - - buffer = new char[size+2]; - // read digits - for (int i=0; (i 0 && base != 10) { - m <<= offset; - } - - if (is_negate) - negate(m); -} CGAL_INLINE_FUNCTION @@ -245,53 +173,6 @@ void write_base_number(std::ostream& out, char* buffer, std::size_t length, int } } -CGAL_INLINE_FUNCTION -void readFromFile(BigInt& z, std::istream& in, long maxLength) { - char *buffer; - long length; - - // check type name whether it is Integer or not. - buffer = new char[8]; - read_string(in, buffer, sizeof(buffer)); - if ( std::strcmp(buffer, "Integer") != 0) - core_io_error_handler("BigInt::read_from_file()","type name expected."); - delete[] buffer; - - // read the bit length field. - buffer = new char[100]; - read_string(in, buffer, sizeof(buffer)); - length = std::atol(buffer); - delete[] buffer; - - // read bigint - read_base_number(in, z, length, maxLength); -} - -CGAL_INLINE_FUNCTION -void writeToFile(const BigInt& z, std::ostream& out, int base, int charsPerLine) { - - assert(false); - /* - BigInt c = abs(z); - - // get the absoulte value string - char* buffer = new char[mpz_sizeinbase(c.get_mp(), base) + 2]; - mpz_get_str(buffer, base, c.get_mp()); - std::size_t length = std::strlen(buffer); - - // write type name of big number and length - //out << "# This is an experimental big number format.\n"; - out << "Integer " << length << "\n"; - - // if bigint is negative, then write an sign '-'. - if ( sign(z) < 0 ) - out << '-'; - - write_base_number(out, buffer, length, base, charsPerLine); - out << "\n"; - delete[] buffer; - */ -} CGAL_INLINE_FUNCTION void readFromFile(BigFloat& bf, std::istream& in, long maxLength) { diff --git a/CGAL_Core/include/CGAL/CORE/Promote.h b/CGAL_Core/include/CGAL/CORE/Promote.h index b084026e72ea..8e309a63c372 100644 --- a/CGAL_Core/include/CGAL/CORE/Promote.h +++ b/CGAL_Core/include/CGAL/CORE/Promote.h @@ -26,8 +26,8 @@ * SPDX-License-Identifier: LGPL-3.0-or-later ***************************************************************************/ -#ifndef __PROMOTE_H__ -#define __PROMOTE_H__ +#ifndef _CORE_PROMOTE_H__ +#define _COEE_PROMOTE_H__ #include #include @@ -147,4 +147,4 @@ CORE_DEFINE_MAX_TYPE(BigRat, Expr, Expr) } //namespace CORE -#endif //__PROMOTE_H__ +#endif //_CORE_PROMOTE_H__ From 47414fb62899bb487f9950e55b5b1d959a8abfde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 7 Feb 2023 13:13:29 +0100 Subject: [PATCH 037/139] add missing include --- Arithmetic_kernel/include/CGAL/CORE_arithmetic_kernel.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Arithmetic_kernel/include/CGAL/CORE_arithmetic_kernel.h b/Arithmetic_kernel/include/CGAL/CORE_arithmetic_kernel.h index 418165e1676a..67586065fa5f 100644 --- a/Arithmetic_kernel/include/CGAL/CORE_arithmetic_kernel.h +++ b/Arithmetic_kernel/include/CGAL/CORE_arithmetic_kernel.h @@ -66,6 +66,7 @@ struct Get_arithmetic_kernel{ } //namespace CGAL +#include #endif // CGAL_USE_CORE From 2ca5d6bfb158025bc9bb4d38fbc843cb0a43293a Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 7 Feb 2023 14:26:13 +0000 Subject: [PATCH 038/139] Fix typo --- Algebraic_foundations/include/CGAL/Rational_traits.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Algebraic_foundations/include/CGAL/Rational_traits.h b/Algebraic_foundations/include/CGAL/Rational_traits.h index a2ac5f1016c5..7fcf808e43b1 100644 --- a/Algebraic_foundations/include/CGAL/Rational_traits.h +++ b/Algebraic_foundations/include/CGAL/Rational_traits.h @@ -53,7 +53,7 @@ struct Rational_traits_base { private: typedef Fraction_traits FT; - typedef typename FT::Decompose Decomose; + typedef typename FT::Decompose Decompose; typedef typename FT::Compose Compose; public: @@ -61,13 +61,13 @@ struct Rational_traits_base RT numerator (const Rational& r) const { RT num,den; - Decomose()(r,num,den); + Decompose()(r,num,den); return num; } RT denominator (const Rational& r) const { RT num,den; - Decomose()(r,num,den); + Decompose()(r,num,den); return den; } From fb71e3937eb754ad8c2b311822827e9a739ddd85 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 7 Feb 2023 15:42:49 +0000 Subject: [PATCH 039/139] Add numerator() and denominator() --- .../include/CGAL/CORE_algebraic_number_traits.h | 8 ++++---- CGAL_Core/include/CGAL/CORE/BigRat.h | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Arrangement_on_surface_2/include/CGAL/CORE_algebraic_number_traits.h b/Arrangement_on_surface_2/include/CGAL/CORE_algebraic_number_traits.h index c3fd592a7d66..a35bc24144c8 100644 --- a/Arrangement_on_surface_2/include/CGAL/CORE_algebraic_number_traits.h +++ b/Arrangement_on_surface_2/include/CGAL/CORE_algebraic_number_traits.h @@ -106,7 +106,7 @@ class CORE_algebraic_number_traits ix1 = scaled_x1.BigIntValue(); ix2 = scaled_x2.BigIntValue(); - if (CORE::abs (ix2 - ix1) > one) + if (CGAL::abs (ix2 - ix1) > one) break; // Scale the values by a factor of 2. @@ -179,9 +179,9 @@ class CORE_algebraic_number_traits temp_gcd = numer_gcd; denom_lcm *= denom; - denom_lcm /= CORE::gcd (temp_lcm, denom); + denom_lcm /= CGAL::gcd (temp_lcm, denom); - numer_gcd = CORE::gcd (temp_gcd, numer); + numer_gcd = CGAL::gcd (temp_gcd, numer); } ++q_iter; @@ -334,7 +334,7 @@ class CORE_algebraic_number_traits temp_lcm = denom_lcm; denom_lcm *= denom; - denom_lcm /= CORE::gcd (temp_lcm, denom); + denom_lcm /= CGAL::gcd (temp_lcm, denom); } index--; diff --git a/CGAL_Core/include/CGAL/CORE/BigRat.h b/CGAL_Core/include/CGAL/CORE/BigRat.h index 4de07c5e44ef..3de5f13d156c 100644 --- a/CGAL_Core/include/CGAL/CORE/BigRat.h +++ b/CGAL_Core/include/CGAL/CORE/BigRat.h @@ -35,6 +35,15 @@ namespace CORE { #endif + BigInt numerator(const BigRat& q) + { + return boost::multiprecision::numerator(q); + } + + BigInt denominator(const BigRat& q) + { + return boost::multiprecision::denominator(q); + } /// BigIntValue inline BigInt BigIntValue(const BigRat& br) { From 2184d22c5289a55535cd0830f180fe2d6d8f6293 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 7 Feb 2023 21:18:31 +0000 Subject: [PATCH 040/139] WIP [scip ci] --- .../Bitstream_descartes_rndl_tree_traits.h | 2 +- .../CGAL/Arr_geometry_traits/Conic_arc_2.h | 32 ++++++++-------- .../Conic_intersections_2.h | 5 ++- .../CGAL/Arr_rat_arc/Algebraic_point_2.h | 7 +++- .../CGAL/CORE_algebraic_number_traits.h | 6 +-- CGAL_Core/include/CGAL/CORE/BigFloat.h | 5 ++- CGAL_Core/include/CGAL/CORE/BigInt.h | 3 ++ CGAL_Core/include/CGAL/CORE/BigRat.h | 37 +++++++++++++++++++ CGAL_Core/include/CGAL/CORE/poly/Poly.h | 1 + CGAL_Core/include/CGAL/CORE/poly/Poly.tcc | 12 +++--- 10 files changed, 79 insertions(+), 31 deletions(-) diff --git a/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Bitstream_descartes_rndl_tree_traits.h b/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Bitstream_descartes_rndl_tree_traits.h index 155cfbffc68d..a18814f88705 100644 --- a/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Bitstream_descartes_rndl_tree_traits.h +++ b/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Bitstream_descartes_rndl_tree_traits.h @@ -28,7 +28,7 @@ #include #if CGAL_USE_CORE -namespace CORE { class BigInt; } +#include #endif namespace CGAL { diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_arc_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_arc_2.h index cbff44dbe247..9f19658b1e16 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_arc_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_arc_2.h @@ -1389,9 +1389,9 @@ class _Conic_arc_2 // Nt_traits nt_traits; const int or_fact = (_orient == CLOCKWISE) ? -1 : 1; - const Algebraic r = nt_traits.convert (or_fact * _r); - const Algebraic s = nt_traits.convert (or_fact * _s); - const Algebraic t = nt_traits.convert (or_fact * _t); + const Algebraic r = nt_traits.convert (Integer(or_fact * _r)); + const Algebraic s = nt_traits.convert (Integer(or_fact * _s)); + const Algebraic t = nt_traits.convert (Integer(or_fact * _t)); const Algebraic cos_2phi = (r - s) / nt_traits.sqrt((r-s)*(r-s) + t*t); const Algebraic _zero = 0; const Algebraic _one = 1; @@ -1441,8 +1441,8 @@ class _Conic_arc_2 // 4*r*s - t^2 4*r*s - t^2 // // The denominator (4*r*s - t^2) must be negative for hyperbolas. - const Algebraic u = nt_traits.convert (or_fact * _u); - const Algebraic v = nt_traits.convert (or_fact * _v); + const Algebraic u = nt_traits.convert (Integer(or_fact * _u)); + const Algebraic v = nt_traits.convert (Integer(or_fact * _v)); const Algebraic det = 4*r*s - t*t; Algebraic x0, y0; @@ -1650,9 +1650,9 @@ class _Conic_arc_2 int n_xs; Nt_traits nt_traits; - xs_end = nt_traits.solve_quadratic_equation (_t*_t - _four*_r*_s, - _two*_t*_v - _four*_s*_u, - _v*_v - _four*_s*_w, + xs_end = nt_traits.solve_quadratic_equation (Integer(_t*_t - _four*_r*_s), + Integer(_two*_t*_v - _four*_s*_u), + Integer(_v*_v - _four*_s*_w), xs); n_xs = static_cast(xs_end - xs); @@ -1664,15 +1664,15 @@ class _Conic_arc_2 if (CGAL::sign (_t) == ZERO) { // The two vertical tangency points have the same y coordinate: - ys[0] = nt_traits.convert (-_v) /nt_traits.convert (_two*_s); + ys[0] = nt_traits.convert (Integer(-_v)) /nt_traits.convert (Integer(_two*_s)); n_ys = 1; } else { ys_end = - nt_traits.solve_quadratic_equation (_four*_r*_s*_s - _s*_t*_t, - _four*_r*_s*_v - _two*_s*_t*_u, - _r*_v*_v - _t*_u*_v + _t*_t*_w, + nt_traits.solve_quadratic_equation (Integer(_four*_r*_s*_s - _s*_t*_t), + Integer(_four*_r*_s*_v - _two*_s*_t*_u), + Integer(_r*_v*_v - _t*_u*_v + _t*_t*_w), ys); n_ys = static_cast(ys_end - ys); } @@ -1692,7 +1692,7 @@ class _Conic_arc_2 { for (j = 0; j < n_ys; j++) { - if (CGAL::compare (nt_traits.convert(_two*_s) * ys[j], + if (CGAL::compare (nt_traits.convert(Integer(_two*_s)) * ys[j], -(nt_traits.convert(_t) * xs[i] + nt_traits.convert(_v))) == EQUAL) { @@ -1735,9 +1735,9 @@ class _Conic_arc_2 Algebraic *ys_end; Nt_traits nt_traits; - ys_end = nt_traits.solve_quadratic_equation (_t*_t - _four*_r*_s, - _two*_t*_u - _four*_r*_v, - _u*_u - _four*_r*_w, + ys_end = nt_traits.solve_quadratic_equation (Integer(_t*_t - _four*_r*_s), + Integer(_two*_t*_u - _four*_r*_v), + Integer(_u*_u - _four*_r*_w), ys); n = static_cast(ys_end - ys); diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_intersections_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_intersections_2.h index 79049ca39770..264ff9a92f24 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_intersections_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_intersections_2.h @@ -72,13 +72,14 @@ int unsigned int degree = 4; typename Nt_traits::Algebraic *xs_end; + typedef typename Nt_traits::Integer Integer; if (deg1 == 1) { // The first curve has no quadratic coefficients, and represents a line. if (CGAL::sign (v1) == ZERO) { // The first line is u1*x + w1 = 0, therefore: - xs[0] = nt_traits.convert(-w1) / nt_traits.convert(u1); + xs[0] = nt_traits.convert(Integer(-w1)) / nt_traits.convert(u1); return (1); } @@ -94,7 +95,7 @@ int // The two lines are parallel: return (0); - xs[0] = nt_traits.convert(-c[0]) / nt_traits.convert(c[1]); + xs[0] = nt_traits.convert(Integer(-c[0])) / nt_traits.convert(c[1]); return (1); } diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_rat_arc/Algebraic_point_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_rat_arc/Algebraic_point_2.h index 460bbe432a7a..e32073e417a3 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_rat_arc/Algebraic_point_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_rat_arc/Algebraic_point_2.h @@ -225,10 +225,11 @@ class Algebraic_point_2_rep : public Base_rational_arc_ds_1 if (CGAL::compare( CGAL::width(y_bfi), CGAL::lower(CGAL::abs(y_bfi)) * eps) - == SMALLER) + == SMALLER){ return std::make_pair( Bound(CGAL::lower(y_bfi)), Bound(CGAL::upper(y_bfi))); + } } else precision*=2; } @@ -287,10 +288,12 @@ class Algebraic_point_2_rep : public Base_rational_arc_ds_1 if (CGAL::zero_in(y_denom_bfi) == false) { BFI y_bfi(y_numer_bfi/y_denom_bfi); - if (CGAL::width(y_bfi) < eps ) + if (CGAL::width(y_bfi) < eps ){ + assert(false) ; // AF fix return std::make_pair( Bound(CGAL::lower(y_bfi)), Bound(CGAL::upper(y_bfi))); + } } else precision*=2; diff --git a/Arrangement_on_surface_2/include/CGAL/CORE_algebraic_number_traits.h b/Arrangement_on_surface_2/include/CGAL/CORE_algebraic_number_traits.h index a35bc24144c8..c3e941fdab8e 100644 --- a/Arrangement_on_surface_2/include/CGAL/CORE_algebraic_number_traits.h +++ b/Arrangement_on_surface_2/include/CGAL/CORE_algebraic_number_traits.h @@ -246,8 +246,8 @@ class CORE_algebraic_number_traits if (sign_disc == ZERO) { - // We have one real root with mutliplicity 2. - *oi = -Algebraic (b) / Algebraic (2*a); + // We have one real root with multiplicity 2. + *oi = -Algebraic (b) / Algebraic (NT(2*a)); ++oi; } else if (sign_disc == POSITIVE) @@ -255,7 +255,7 @@ class CORE_algebraic_number_traits // We have two distinct real roots. We return them in ascending order. const Algebraic sqrt_disc = CGAL::sqrt (Algebraic (disc)); const Algebraic alg_b = b; - const Algebraic alg_2a = 2*a; + const Algebraic alg_2a = NT(2*a); if (sign_a == POSITIVE) { diff --git a/CGAL_Core/include/CGAL/CORE/BigFloat.h b/CGAL_Core/include/CGAL/CORE/BigFloat.h index 77ed3414b54b..81d49f97d954 100644 --- a/CGAL_Core/include/CGAL/CORE/BigFloat.h +++ b/CGAL_Core/include/CGAL/CORE/BigFloat.h @@ -614,7 +614,10 @@ inline BigFloat gcd(const BigFloat& a, const BigFloat& b) { //mpz_tdiv_qr(q.get_mp(), r.get_mp(), a.get_mp(), b.get_mp()); //}// -/* AF +/* + +// AF: As BigRat is just a boost::mp type we cannot have this +// constructor // constructor BigRat from BigFloat inline BigRat::BigRat(const BigFloat& f) : RCBigRat(new BigRatRep()){ *this = f.BigRatValue(); diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 0b01f233cf8f..73bc7cdba2e1 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -151,6 +151,9 @@ inline long div_exact(long x, long y) { return x/y; // precondition: isDivisible(x,y) } +inline BigInt gcd(const BigInt& a, const BigInt& b){ + return boost::multiprecision::gcd(a,b); +} /// ceilLg -- ceiling of log_2(a) where a=BigInt, int or long /** Convention: a=0, ceilLg(a) returns -1. diff --git a/CGAL_Core/include/CGAL/CORE/BigRat.h b/CGAL_Core/include/CGAL/CORE/BigRat.h index 3de5f13d156c..2df59b537626 100644 --- a/CGAL_Core/include/CGAL/CORE/BigRat.h +++ b/CGAL_Core/include/CGAL/CORE/BigRat.h @@ -44,6 +44,43 @@ namespace CORE { { return boost::multiprecision::denominator(q); } + + // Chee (3/19/2004): +// The following definitions of div_exact(x,y) and gcd(x,y) +// ensures that in Polynomial +/// divisible(x,y) = "x | y" + inline BigRat div_exact(const BigRat& x, const BigRat& y) { + BigRat z = x / y; + return z; + } + + inline BigRat gcd(const BigRat& x , const BigRat& y) + { + // return BigRat(1); // Remark: we may want replace this by + // the definition of gcd of a quotient field + // of a UFD [Yap's book, Chap.3] + //Here is one possible definition: gcd of x and y is just the + //gcd of the numerators of x and y divided by the gcd of the + //denominators of x and y. + BigInt n = gcd(numerator(x), numerator(y)); + BigInt d = gcd(denominator(x), denominator(y)); + return BigRat(n,d); + } + + // Chee: 8/8/2004: need isDivisible to compile Polynomial + // A trivial implementation is to return true always. But this + // caused tPolyRat to fail. + // So we follow the definition of + // Expr::isDivisible(e1, e2) which checks if e1/e2 is an integer. + inline bool isInteger(const BigRat& x) { + return denominator(x) == 1; // AF: does that need canonicalize? + } + inline bool isDivisible(const BigRat& x, const BigRat& y) { + BigRat r; + r = x/y; + return isInteger(r); + } + /// BigIntValue inline BigInt BigIntValue(const BigRat& br) { diff --git a/CGAL_Core/include/CGAL/CORE/poly/Poly.h b/CGAL_Core/include/CGAL/CORE/poly/Poly.h index 54b026b60a02..5734ec73c12f 100644 --- a/CGAL_Core/include/CGAL/CORE/poly/Poly.h +++ b/CGAL_Core/include/CGAL/CORE/poly/Poly.h @@ -48,6 +48,7 @@ #define CORE_POLY_H #include +#include #include #include #include diff --git a/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc b/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc index 467231a4b8e8..fd0cc8df94b1 100644 --- a/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc +++ b/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc @@ -892,10 +892,10 @@ BigFloat Polynomial::CauchyUpperBound() const { NT mx = 0; int deg = getTrueDegree(); for (int i = 0; i < deg; ++i) { - mx = core_max(mx, abs(coeff[i])); + mx = core_max(mx, NT(abs(coeff[i]))); } Expr e = mx; - e /= Expr(abs(coeff[deg])); + e /= Expr(NT(abs(coeff[deg]))); e.approx(CORE_INFTY, 2); // get an absolute approximate value with error < 1/4 return (e.BigFloatValue().makeExact() + 2); @@ -975,9 +975,9 @@ BigFloat Polynomial::CauchyLowerBound() const { NT mx = 0; int deg = getTrueDegree(); for (int i = 1; i <= deg; ++i) { - mx = core_max(mx, abs(coeff[i])); + mx = core_max(mx, NT(abs(coeff[i]))); } - Expr e = Expr(abs(coeff[0]))/ Expr(abs(coeff[0]) + mx); + Expr e = Expr(NT(abs(coeff[0])))/ Expr(NT(abs(coeff[0])) + mx); e.approx(2, CORE_INFTY); // get an relative approximate value with error < 1/4 return (e.BigFloatValue().makeExact().div2()); @@ -1018,8 +1018,8 @@ BigFloat Polynomial::height() const { int deg = getTrueDegree(); NT ht = 0; for (int i = 0; i< deg; i++) - if (ht < abs(coeff[i])) - ht = abs(coeff[i]); + if (ht < NT(abs(coeff[i]))) + ht = NT(abs(coeff[i])); return BigFloat(ht); } From 7879e2180dd3a4da49a47225d7f571231f0a81fe Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 8 Feb 2023 07:12:34 +0000 Subject: [PATCH 041/139] Replace constructor by conversion operator --- CGAL_Core/include/CGAL/CORE/BigFloat.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigFloat.h b/CGAL_Core/include/CGAL/CORE/BigFloat.h index 81d49f97d954..ccecb2e782e8 100644 --- a/CGAL_Core/include/CGAL/CORE/BigFloat.h +++ b/CGAL_Core/include/CGAL/CORE/BigFloat.h @@ -106,6 +106,9 @@ class CGAL_CORE_EXPORT BigFloat : public RCBigFloat { explicit BigFloat(BigFloatRep* r, bool) : RCBigFloat(r) { } + operator BigRat() const { + return this->BigRatValue(); + } //@} @@ -614,15 +617,6 @@ inline BigFloat gcd(const BigFloat& a, const BigFloat& b) { //mpz_tdiv_qr(q.get_mp(), r.get_mp(), a.get_mp(), b.get_mp()); //}// -/* - -// AF: As BigRat is just a boost::mp type we cannot have this -// constructor -// constructor BigRat from BigFloat -inline BigRat::BigRat(const BigFloat& f) : RCBigRat(new BigRatRep()){ - *this = f.BigRatValue(); -} -*/ inline double doubleValue(const BigFloat& bf) { From 3c763fd33a7c04dd2afad6b9e51e923fac13c9e1 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 9 Feb 2023 11:54:14 +0000 Subject: [PATCH 042/139] Remove CoreIO_impl.h --- CGAL_Core/include/CGAL/CORE/BigFloat.h | 1 - CGAL_Core/include/CGAL/CORE/CoreIO_impl.h | 369 ---------------------- 2 files changed, 370 deletions(-) delete mode 100644 CGAL_Core/include/CGAL/CORE/CoreIO_impl.h diff --git a/CGAL_Core/include/CGAL/CORE/BigFloat.h b/CGAL_Core/include/CGAL/CORE/BigFloat.h index ccecb2e782e8..5969c1b5e286 100644 --- a/CGAL_Core/include/CGAL/CORE/BigFloat.h +++ b/CGAL_Core/include/CGAL/CORE/BigFloat.h @@ -632,7 +632,6 @@ inline long longValue(const BigFloat& bf) #ifdef CGAL_HEADER_ONLY #include -#include #endif // CGAL_HEADER_ONLY #include diff --git a/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h b/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h deleted file mode 100644 index 02c97c66eb6e..000000000000 --- a/CGAL_Core/include/CGAL/CORE/CoreIO_impl.h +++ /dev/null @@ -1,369 +0,0 @@ -/**************************************************************************** - * Core Library Version 1.7, August 2004 - * Copyright (c) 1995-2004 Exact Computation Project - * All rights reserved. - * - * This file is part of CGAL (www.cgal.org). - * - * File: CoreIO.cpp - * - * Written by - * Zilin Du - * Chee Yap - * - * WWW URL: https://cs.nyu.edu/exact/ - * Email: exact@cs.nyu.edu - * - * $URL$ - * $Id$ - * SPDX-License-Identifier: LGPL-3.0-or-later - ***************************************************************************/ - -#ifndef _COREIO_IMPL_H_ -#define _COREIO_IMPL_H_ - -#ifdef CGAL_HEADER_ONLY -#define CGAL_INLINE_FUNCTION inline -#else -#define CGAL_INLINE_FUNCTION -#endif - -#include -#include -#include - -namespace CORE { - -CGAL_INLINE_FUNCTION -void core_io_error_handler(const char *f, const char *m) { - std::cout << "\n error_handler"; - std::cout << "::" << f << "::" << m << "\n"; - std::cout.flush(); - std::abort(); -} - -CGAL_INLINE_FUNCTION -void core_io_memory_handler(char *t, const char *f, const char *m) { - if (t == nullptr) { - std::cout << "\n memory_handler"; - std::cout << "::" << f << "::" << m; - std::cout << "memory exhausted\n"; - std::cout.flush(); - std::abort(); - } -} - -// s has size old_size and will be resized to new_size. -CGAL_INLINE_FUNCTION -void allocate (char * &s, int old_size, int new_size) { - if (old_size > new_size) - old_size = new_size; - - if (s == nullptr) - old_size = 0; - - char *t = new char[new_size]; - core_io_memory_handler(t, "CoreIO", "allocate::out of memory error"); - - int i; - for (i = 0; i < old_size; i++) - t[i] = s[i]; - - delete[] s; - s = t; -} - -// appends c to s at position pos. -// sz is the size of s -CGAL_INLINE_FUNCTION -void append_char (char * &s, int & sz, int pos, char c) { - if (pos > sz) - core_io_error_handler("CoreIO", "append_char::invalid argument"); - - if (pos == sz) { - allocate(s, sz, 2*sz); - sz *= 2; - } - - s[pos] = c; -} - -// skip blanks, tabs, line breaks and comment lines -CGAL_INLINE_FUNCTION -int skip_comment_line (std::istream & in) { - char c; - - do { - in.get(c); - while ( c == '#' ) { - do { - in.get(c); - } while ( c != '\n' ); - in.get(c); - } - } while (c == ' ' || c == '\t' || c == '\n'); - - if (in.eof()) - core_io_error_handler("CoreIO::read_from_file()","unexpected end of file."); - - in.putback(c); - return c; -} - -// skips '\\' followed by '\n' -CGAL_INLINE_FUNCTION -char skip_backslash_new_line (std::istream & in) { - char c; - in.get(c); - - while (c == '\\') { - in.get(c); - - if (c == '\n') - in.get(c); - else - core_io_error_handler("CoreIO::operator>>", "\\ must be immediately followed by new line."); - } - - return c; -} - -CGAL_INLINE_FUNCTION -void read_string(std::istream& in, char* &buffer, int sz) { - char c; - int pos=0; - skip_comment_line(in); - - while ( in.get(c) ) { - if ( c == ' ' || c == '\t' || c == '\n' || c == '#') - break; - else - append_char(buffer, sz, pos++, c); - } - append_char(buffer, sz, pos, '\0'); -} - - - -CGAL_INLINE_FUNCTION -void write_base_number(std::ostream& out, char* buffer, std::size_t length, int base, int charsPerLine) { - // write big number in a format that gmp's mpz_set_str() can - // automatically recognize with argument base = 0. - if (base == 2) - out << "0b"; - else if (base == 16) - out << "0x"; - else if (base == 8) - out << '0'; - - // write big number in charsPerLine. - char* start, *end, c; - for (std::size_t i=0; i= length) - out << start; - else { - end = start + charsPerLine; - c = *end; - *end = '\0'; - - out << start << "\\\n"; - *end = c; - } - } -} - - -CGAL_INLINE_FUNCTION -void readFromFile(BigFloat& bf, std::istream& in, long maxLength) { - - assert(false); - /* - char *buffer; - long length; - long exponent; - BigInt mantissa; - - // check type name whether it is Float - buffer = new char[6]; - read_string(in, buffer, sizeof(buffer)); - if (std::strcmp(buffer, "Float") != 0) - core_io_error_handler("BigFloat::read_from_file()", "type name expected"); - delete[] buffer; - - // read base (default is 16384) - buffer = new char[8]; - read_string(in, buffer, sizeof(buffer)); - if (std::strcmp(buffer, "(16384)") != 0) - core_io_error_handler("BigFloat::read_from_file()", "base expected"); - delete[] buffer; - - // read the bit length field. - buffer = new char[100]; - read_string(in, buffer, sizeof(buffer)); - length = std::atol(buffer); - delete[] buffer; - - // read exponent - buffer = new char[100]; - read_string(in, buffer, sizeof(buffer)); - exponent = std::atol(buffer); - delete[] buffer; - - // read mantissa - read_base_number(in, mantissa, length, maxLength); - - // construct BigFloat - bf = BigFloat(mantissa, 0, exponent); - */ -} - -CGAL_INLINE_FUNCTION -void writeToFile(const BigFloat& bf, std::ostream& out, int base, int charsPerLine) { - - assert(false); - /* - BigInt c(CORE::abs(bf.m())); - - // get the absolute value string - char* buffer = new char[mpz_sizeinbase(c.get_mp(), base) + 2]; - mpz_get_str(buffer, base, c.get_mp()); - std::size_t length = std::strlen(buffer); - - - // write type name, base, length - //out << "# This is an experimental Big Float format." << std::endl; - out << "Float (16384) " << length << std::endl; - // write exponent - out << bf.exp() << std::endl; - - // write mantissa - if ( CORE::sign(bf.m()) < 0 ) - out << '-'; - - write_base_number(out, buffer, length, base, charsPerLine); - out << '\n'; - delete[] buffer; - */ -} - -/* Underconstruction ---- -void BigFloat::read_from_file2(std::istream& in, long maxLength) { - long length = 1024; - char *buffer; - - // check type name whether it is Float - buffer = new char[7]; - BigInt::read_string(in, buffer, sizeof(buffer)); - if (strcmp(buffer, "NFloat") != 0) - core_io_error_handler("BigFloat::read_from_file2()", "type name expected"); - delete[] buffer; - - // read base (default is 16) - buffer = new char[5]; - BigInt::read_string(in, buffer, sizeof(buffer)); - if (strcmp(buffer, "(16)") != 0) - core_io_error_handler("BigFloat::read_from_file2()", "base expected"); - delete[] buffer; - - // read length field - buffer = new char[100]; - BigInt::read_string(in, buffer, sizeof(buffer)); - - // get the length field if it is not null. - if (buffer[0] != '\0') { - length = atol(buffer); - if (maxLength > 0 && length >= maxLength) - length = maxLength; - } - delete[] buffer; - - // read exponent - buffer = new char[100]; - BigInt::read_string(in, buffer, sizeof(buffer)); - long exp16 = atol(buffer); - delete[] buffer; - - // read mantissa - buffer = new char[length+2]; - //BigInt::read_base_number(in, buffer, length); - - BigInt m16(buffer); - delete[] buffer; - - // convert to base CHUNK_BIT - exp16 = exp16 - length + 1; - if ( m16.is_negative() ) - exp16 ++; - - long tmp_exp = exp16 * 4; - long q = tmp_exp / CHUNK_BIT; - long r = tmp_exp % CHUNK_BIT; - if ( r < 0 ) { - r += CHUNK_BIT; - q --; - } - - BigInt mantissa = m16 << r; - long exponent = q; - - // construct BigFloat - if (--rep->refCount == 0) - delete rep; - - rep = new BigFloatRep(mantissa, 0, exponent); - rep->refCount++; - -} - -// write normal float -// now it assumed to write in hex base, i.e. B=2^4=16 -// (note: our default base B=2^(CHUNK_BIT)=2^14=16384 -void BigFloat::write_to_file2(std::ostream& out, int base, int charsPerLine) { - // convert to base 16. - long new_base = 4; // 2^4 = 16 - long tmp_exp = (rep->exp) * CHUNK_BIT; - long q = tmp_exp / new_base; - long r = tmp_exp % new_base; - std::cout << "CORE_DEBUG: q=" << q << ", r=" << r << std::endl; - if ( r < 0 ) { - r += new_base; - q--; - } - std::cout << "CORE_DEBUG: q=" << q << ", r=" << r << std::endl; - - BigInt m16 = (rep->m) << r; - - int size = mpz_sizeinbase(m16.I, base) + 2; - std::cout << "size=" << size << std::endl; - char* buffer = new char[size]; - - int length = bigint_to_string(m16, buffer, base); - std::cout << "length=" << length << std::endl; - - long exp16 = q + length - 1; - if ( m16.is_negative() ) - exp16 --; - - // write type name, base, length - out << "# This is an experimental Big Float format." << std::endl; - out << "NFloat (16) " << length << std::endl; - - // write exponent - out << exp16 << std::endl; - - // write mantissa - if ( m16.is_negative() ) { - out << '-'; - buffer ++; - } - - BigInt::write_base_number(out, buffer, length, base, charsPerLine); - out << '\n'; - delete[] buffer; -} -*/ - -} //namespace CORE - -#endif // _COREIO_IMPL_H_ From c2fefe3147c768c1d5e9863edb248fa569865189 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 9 Feb 2023 12:01:17 +0000 Subject: [PATCH 043/139] remove debug output --- Number_types/test/Number_types/CORE_BigInt.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Number_types/test/Number_types/CORE_BigInt.cpp b/Number_types/test/Number_types/CORE_BigInt.cpp index d02fbb87f26a..79b207d2d87e 100644 --- a/Number_types/test/Number_types/CORE_BigInt.cpp +++ b/Number_types/test/Number_types/CORE_BigInt.cpp @@ -33,7 +33,6 @@ void test_io(){ std::stringstream ss; CGAL::IO::set_pretty_mode(ss); ss << CGAL::IO::oformat(NT(1), CGAL::Parens_as_product_tag()); - std::cout << ss.str() << std::endl; assert( ss.str() == "1"); }{ std::stringstream ss; @@ -73,4 +72,3 @@ int main() { return 0; } #endif // CGAL_USE_CORE //EOF - From 50621a4258de432b212342590ed7ae1a16e70154 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 10 Feb 2023 08:23:53 +0000 Subject: [PATCH 044/139] reactivate code --- .../CGAL/Arr_rat_arc/Algebraic_point_2.h | 1 - .../include/CGAL/CORE_coercion_traits.h | 37 +++++++++++-------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_rat_arc/Algebraic_point_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_rat_arc/Algebraic_point_2.h index e32073e417a3..c5b38c13a8c6 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_rat_arc/Algebraic_point_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_rat_arc/Algebraic_point_2.h @@ -289,7 +289,6 @@ class Algebraic_point_2_rep : public Base_rational_arc_ds_1 { BFI y_bfi(y_numer_bfi/y_denom_bfi); if (CGAL::width(y_bfi) < eps ){ - assert(false) ; // AF fix return std::make_pair( Bound(CGAL::lower(y_bfi)), Bound(CGAL::upper(y_bfi))); diff --git a/Number_types/include/CGAL/CORE_coercion_traits.h b/Number_types/include/CGAL/CORE_coercion_traits.h index ad8bd659e253..465b777658ea 100644 --- a/Number_types/include/CGAL/CORE_coercion_traits.h +++ b/Number_types/include/CGAL/CORE_coercion_traits.h @@ -57,12 +57,14 @@ struct Coercion_traits{ typedef Type result_type; Type operator()(const CORE::BigFloat& x) const { return x;} Type operator()(const ::CORE::BigInt x) const { - CORE::BigFloat result; - result.approx(x,CORE::get_static_defRelPrec().toLong(),LONG_MAX); - // Do not use MakeFloorExact as it changes the Bigfloat - // AF CGAL_postcondition( ::CORE::BigRat(::CORE::BigFloat(result.m()-result.err(),0,result.exp())) <= x ); - // AF CGAL_postcondition( ::CORE::BigRat(::CORE::BigFloat(result.m()+result.err(),0,result.exp())) >= x ); - return result; + CORE::BigFloat result; + result.approx(x,CORE::get_static_defRelPrec().toLong(),LONG_MAX); + // Do not use MakeFloorExact as it changes the Bigfloat + CGAL_postcondition_code(::CORE::BigRat r = ::CORE::BigFloat(result.m()-result.err(),0,result.exp())); + CGAL_postcondition( r <= x ); + CGAL_postcondition_code(r = ::CORE::BigFloat(result.m()+result.err(),0,result.exp())); + CGAL_postcondition( r >= x ); + return result; } }; }; @@ -77,12 +79,13 @@ struct Coercion_traits{ typedef Type result_type; Type operator()(const CORE::BigFloat& x) const { return x;} Type operator()(const ::CORE::BigRat x) const { - CORE::BigFloat result(x,CORE::get_static_defRelPrec().toLong(),LONG_MAX); - // Do not use MakeFloorExact as it changes the Bigfloat - // AF CGAL_postcondition( ::CORE::BigRat(::CORE::BigFloat(result.m()-result.err(),0,result.exp())) <= x ); - // AF CGAL_postcondition( ::CORE::BigRat(::CORE::BigFloat(result.m()+result.err(),0,result.exp())) >= x ); - return result; + // Do not use MakeFloorExact as it changes the Bigfloat + CGAL_postcondition_code(::CORE::BigRat r = ::CORE::BigFloat(result.m()-result.err(),0,result.exp())); + CGAL_postcondition( r <= x ); + CGAL_postcondition_code( r = ::CORE::BigFloat(result.m()+result.err(),0,result.exp())); + CGAL_postcondition( r >= x ); + return result; } }; }; @@ -97,11 +100,13 @@ struct Coercion_traits{ typedef Type result_type; Type operator()(const CORE::BigFloat& x) const { return x;} Type operator()(const ::CORE::Expr x) const { - CORE::BigFloat result(x, CORE::get_static_defRelPrec().toLong(),LONG_MAX); - // Do not use MakeFloorExact as it changes the Bigfloat - // AF CGAL_postcondition( ::CORE::BigRat(::CORE::BigFloat(result.m()-result.err(),0,result.exp())) <= x ); - // AF CGAL_postcondition( ::CORE::BigRat(::CORE::BigFloat(result.m()+result.err(),0,result.exp())) >= x ); - return result; + CORE::BigFloat result(x, CORE::get_static_defRelPrec().toLong(),LONG_MAX); + // Do not use MakeFloorExact as it changes the Bigfloat + CGAL_postcondition_code(::CORE::BigRat r = ::CORE::BigFloat(result.m()-result.err(),0,result.exp())); + CGAL_postcondition( r <= x ); + CGAL_postcondition_code( r = ::CORE::BigFloat(result.m()+result.err(),0,result.exp())); + CGAL_postcondition( r >= x ); + return result; } }; }; From 3446b03a22d7546ce8f42e3852fbc656f2fa55b7 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 10 Feb 2023 08:25:33 +0000 Subject: [PATCH 045/139] inline --- CGAL_Core/include/CGAL/CORE/BigRat.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigRat.h b/CGAL_Core/include/CGAL/CORE/BigRat.h index 2df59b537626..df60c54b9bfd 100644 --- a/CGAL_Core/include/CGAL/CORE/BigRat.h +++ b/CGAL_Core/include/CGAL/CORE/BigRat.h @@ -35,12 +35,12 @@ namespace CORE { #endif - BigInt numerator(const BigRat& q) + inline BigInt numerator(const BigRat& q) { return boost::multiprecision::numerator(q); } - BigInt denominator(const BigRat& q) + inline BigInt denominator(const BigRat& q) { return boost::multiprecision::denominator(q); } From 872e7b9b7934325fd1ab9e1a7aff7902ef226a18 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 10 Feb 2023 11:11:40 +0000 Subject: [PATCH 046/139] fixes --- Number_types/include/CGAL/CORE_coercion_traits.h | 12 ++++++------ Number_types/include/CGAL/Root_of_traits.h | 4 +++- Number_types/test/Number_types/ioformat.cpp | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Number_types/include/CGAL/CORE_coercion_traits.h b/Number_types/include/CGAL/CORE_coercion_traits.h index 465b777658ea..f5426e10cb3f 100644 --- a/Number_types/include/CGAL/CORE_coercion_traits.h +++ b/Number_types/include/CGAL/CORE_coercion_traits.h @@ -62,8 +62,8 @@ struct Coercion_traits{ // Do not use MakeFloorExact as it changes the Bigfloat CGAL_postcondition_code(::CORE::BigRat r = ::CORE::BigFloat(result.m()-result.err(),0,result.exp())); CGAL_postcondition( r <= x ); - CGAL_postcondition_code(r = ::CORE::BigFloat(result.m()+result.err(),0,result.exp())); - CGAL_postcondition( r >= x ); + CGAL_postcondition_code(::CORE::BigRat r2 = ::CORE::BigFloat(result.m()+result.err(),0,result.exp())); + CGAL_postcondition( r2 >= x ); return result; } }; @@ -83,8 +83,8 @@ struct Coercion_traits{ // Do not use MakeFloorExact as it changes the Bigfloat CGAL_postcondition_code(::CORE::BigRat r = ::CORE::BigFloat(result.m()-result.err(),0,result.exp())); CGAL_postcondition( r <= x ); - CGAL_postcondition_code( r = ::CORE::BigFloat(result.m()+result.err(),0,result.exp())); - CGAL_postcondition( r >= x ); + CGAL_postcondition_code(::CORE::BigRat r2 = ::CORE::BigFloat(result.m()+result.err(),0,result.exp())); + CGAL_postcondition( r2 >= x ); return result; } }; @@ -104,8 +104,8 @@ struct Coercion_traits{ // Do not use MakeFloorExact as it changes the Bigfloat CGAL_postcondition_code(::CORE::BigRat r = ::CORE::BigFloat(result.m()-result.err(),0,result.exp())); CGAL_postcondition( r <= x ); - CGAL_postcondition_code( r = ::CORE::BigFloat(result.m()+result.err(),0,result.exp())); - CGAL_postcondition( r >= x ); + CGAL_postcondition_code(::CORE::BigRat r2 = ::CORE::BigFloat(result.m()+result.err(),0,result.exp())); + CGAL_postcondition( r2 >= x ); return result; } }; diff --git a/Number_types/include/CGAL/Root_of_traits.h b/Number_types/include/CGAL/Root_of_traits.h index a1a941277bc2..ab15aae3905a 100644 --- a/Number_types/include/CGAL/Root_of_traits.h +++ b/Number_types/include/CGAL/Root_of_traits.h @@ -76,7 +76,9 @@ compute_roots_of_2(const NT &a_, const NT &b_, const NT &c_, OutputIterator oit) } } else { - *oit++ = -c/b; return oit; + assert(false); + // *oit++ = - c / b; // AF: HELP + return oit; } } diff --git a/Number_types/test/Number_types/ioformat.cpp b/Number_types/test/Number_types/ioformat.cpp index 4d9a66563211..fd171f201249 100644 --- a/Number_types/test/Number_types/ioformat.cpp +++ b/Number_types/test/Number_types/ioformat.cpp @@ -106,7 +106,7 @@ int main() // CORE #ifdef CGAL_USE_CORE - CGAL_static_assertion(CGAL::Output_rep::is_specialized == true); + // AF CGAL_static_assertion(CGAL::Output_rep::is_specialized == true); //bug in io for CORE. test_it("CORE::BigInt"); test_it("CORE::BigRat"); From f38116272eb8a3e10637cf7adae04728cf405b0b Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 17 Feb 2023 08:34:44 +0000 Subject: [PATCH 047/139] Fix Root_of_traits --- Number_types/include/CGAL/Root_of_traits.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Number_types/include/CGAL/Root_of_traits.h b/Number_types/include/CGAL/Root_of_traits.h index ab15aae3905a..d2aca814a785 100644 --- a/Number_types/include/CGAL/Root_of_traits.h +++ b/Number_types/include/CGAL/Root_of_traits.h @@ -75,10 +75,10 @@ compute_roots_of_2(const NT &a_, const NT &b_, const NT &c_, OutputIterator oit) return oit; } } - else { - assert(false); - // *oit++ = - c / b; // AF: HELP - return oit; + else { + Root_of_1 cb = -c / b; + *oit++ = Root_of_2(cb); + return oit; } } From 535045a527cfd3c9c0110ba2b4dbe7da3acd979c Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 17 Feb 2023 08:46:44 +0000 Subject: [PATCH 048/139] trailing whitespace --- Number_types/include/CGAL/Root_of_traits.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Number_types/include/CGAL/Root_of_traits.h b/Number_types/include/CGAL/Root_of_traits.h index d2aca814a785..3056663b0352 100644 --- a/Number_types/include/CGAL/Root_of_traits.h +++ b/Number_types/include/CGAL/Root_of_traits.h @@ -75,9 +75,9 @@ compute_roots_of_2(const NT &a_, const NT &b_, const NT &c_, OutputIterator oit) return oit; } } - else { + else { Root_of_1 cb = -c / b; - *oit++ = Root_of_2(cb); + *oit++ = Root_of_2(cb); return oit; } } From 258d96fdf2738c517393445e7897ff38eaba0f2d Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 17 Feb 2023 11:59:49 +0000 Subject: [PATCH 049/139] No need for an overload --- .../Bitstream_descartes_rndl_tree_traits.h | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Bitstream_descartes_rndl_tree_traits.h b/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Bitstream_descartes_rndl_tree_traits.h index a18814f88705..8ed8fa5ae0c1 100644 --- a/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Bitstream_descartes_rndl_tree_traits.h +++ b/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Bitstream_descartes_rndl_tree_traits.h @@ -27,31 +27,10 @@ #include -#if CGAL_USE_CORE -#include -#endif - namespace CGAL { namespace internal { -#if CGAL_USE_CORE -// bugfix for CORE by Michael Kerber -// why is there a specialized function for CORE? -inline CORE::BigInt shift_integer_by(CORE::BigInt x, long shift){ - if( shift > 0 ){ - while(shift>63) { - x = (x >> 63); - shift-=63; - } - x = (x >> shift); - }else{ - // add 0 bits - x = (x << -shift); - } - return x; -} -#endif template Shiftable shift_integer_by(Shiftable x, long shift){ From 8611d167b459847600130f561103797151f276c8 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 17 Feb 2023 13:38:48 +0000 Subject: [PATCH 050/139] reduce package dependencies --- Arithmetic_kernel/include/CGAL/BOOST_MP_arithmetic_kernel.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Arithmetic_kernel/include/CGAL/BOOST_MP_arithmetic_kernel.h b/Arithmetic_kernel/include/CGAL/BOOST_MP_arithmetic_kernel.h index 641642b32375..1ac38a242340 100644 --- a/Arithmetic_kernel/include/CGAL/BOOST_MP_arithmetic_kernel.h +++ b/Arithmetic_kernel/include/CGAL/BOOST_MP_arithmetic_kernel.h @@ -19,8 +19,9 @@ #ifdef CGAL_USE_BOOST_MP -// already protected by CGAL_USE_CORE macro +#ifdef CGAL_USE_CORE #include +#endif //Currently already included in boost_mp.h //#include From c9c82b9a33481aa027dbbc057ab36a4837126351 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 17 Feb 2023 13:55:15 +0000 Subject: [PATCH 051/139] Remove the #if 0'ed code --- CGAL_Core/include/CGAL/CORE/BigInt.h | 7 - Number_types/include/CGAL/CORE_BigInt.h | 195 -------------------- Number_types/include/CGAL/CORE_BigRat.h | 235 ------------------------ 3 files changed, 437 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 73bc7cdba2e1..84cc0c6a880d 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -50,7 +50,6 @@ inline int cmp(const BigInt& x, const BigInt& y) { inline int set_str(BigInt& a, const char* s) { - // AF makeCopy(); a = BigInt(s); return 0; // should be -1 if not correct in the base (we ignore) } @@ -115,8 +114,6 @@ inline long floorLg(const BigInt& a) { /// div_rem inline void div_rem(BigInt& q, BigInt& r, const BigInt& a, const BigInt& b) { - // AF q.makeCopy(); - // AF r.makeCopy(); divide_qr(a, b, q, r); } @@ -129,7 +126,6 @@ inline unsigned long ulongValue(const BigInt& a) { /// exact div inline void divexact(BigInt& z, const BigInt& x, const BigInt& y) { - // AF z.makeCopy(); BigInt r; divide_qr(x, y, z, r ); // was void mpz_divexact (mpz_t q, const mpz_t n, const mpz_t d) Is this faster? assert(r.is_zero()); @@ -178,7 +174,6 @@ inline long ceilLg(int a) { // need this for Polynomial /// negate inline void negate(BigInt& a) { - // AF a.makeCopy(); a= - a; } @@ -187,7 +182,6 @@ inline void getKaryExpo(const BigInt& z, BigInt& m, int& e, unsigned long uk) { BigInt k(uk), q, r; e = 0; m = z; - // AF m.makeCopy(); for(;;) { divide_qr(m, k, q, r); if (!r.is_zero()) break; @@ -197,7 +191,6 @@ inline void getKaryExpo(const BigInt& z, BigInt& m, int& e, unsigned long uk) { } inline void power(BigInt& c, const BigInt& a, unsigned long ul) { - // AF c.makeCopy(); c = pow(a, ul); } diff --git a/Number_types/include/CGAL/CORE_BigInt.h b/Number_types/include/CGAL/CORE_BigInt.h index d9d2b09f6bbb..d9be3a695d21 100644 --- a/Number_types/include/CGAL/CORE_BigInt.h +++ b/Number_types/include/CGAL/CORE_BigInt.h @@ -23,201 +23,6 @@ #include #include -#if 0 - -namespace CGAL { - -// -// Algebraic structure traits -// -template <> class Algebraic_structure_traits< CORE::BigInt > - : public Algebraic_structure_traits_base< CORE::BigInt, - Euclidean_ring_tag > { - public: - typedef Tag_true Is_exact; - typedef Tag_false Is_numerical_sensitive; - - typedef INTERN_AST::Is_square_per_sqrt< Type > - Is_square; - - typedef INTERN_AST::Div_per_operator< Type > Div; - typedef INTERN_AST::Mod_per_operator< Type > Mod; - - class Sqrt - : public CGAL::cpp98::unary_function< Type, Type > { - public: - //! computes the largest NT not larger than the square root of \a a. - Type operator()( const Type& x) const { - Type result; - result.get_mp() = sqrt( x.get_mp()); - return result; - } - }; - - - class Gcd - : public CGAL::cpp98::binary_function< Type, Type, - Type > { - public: - Type operator()( const Type& x, - const Type& y) const { - if ( x == Type(0) && y == Type(0) ) - return Type(0); - Type result; - result.get_mp() = gcd( x.get_mp(), y.get_mp()); - return result; - } - }; -}; - -// -// Real embeddable traits -// -template <> class Real_embeddable_traits< CORE::BigInt > - : public INTERN_RET::Real_embeddable_traits_base< CORE::BigInt , CGAL::Tag_true > { - - public: - - class Abs - : public CGAL::cpp98::unary_function< Type, Type > { - public: - Type operator()( const Type& x ) const { - return CORE::abs( x ); - } - }; - - class Sgn - : public CGAL::cpp98::unary_function< Type, ::CGAL::Sign > { - public: - ::CGAL::Sign operator()( const Type& x ) const { - return (::CGAL::Sign) CORE::sign( x ); - } - }; - - class Compare - : public CGAL::cpp98::binary_function< Type, Type, - Comparison_result > { - public: - Comparison_result operator()( const Type& x, - const Type& y ) const { - return CGAL::sign(::CORE::cmp(x,y)); - } - }; - - class To_double - : public CGAL::cpp98::unary_function< Type, double > { - public: - double operator()( const Type& x ) const { - // this call is required to get reasonable values for the double - // approximation - return x.doubleValue(); - } - }; - - class To_interval - : public CGAL::cpp98::unary_function< Type, std::pair< double, double > > { - public: - std::pair operator()( const Type& x_ ) const { - CORE::Expr x(x_); - std::pair result; - x.doubleInterval(result.first, result.second); - CGAL_expensive_assertion(result.first <= x); - CGAL_expensive_assertion(result.second >= x); - return result; - } - }; -}; - -/*! \ingroup NiX_Modular_traits_spec - * \brief a model of concept ModularTraits, - * specialization of NiX::Modular_traits. - */ -template<> -class Modular_traits< ::CORE::BigInt > { - typedef Residue RES; - public: - typedef ::CORE::BigInt NT; - typedef CGAL::Tag_true Is_modularizable; - typedef Residue Residue_type; - - struct Modular_image{ - Residue_type operator()(const NT& a){ - NT tmp = a % NT(RES::get_current_prime()); -// TODO: reactivate this assertion -// it fails with core_v1.6x_20040329 -// NiX_assert(tmp.isInt()); - int mi(tmp.longValue()); - if (mi < 0) mi += RES::get_current_prime(); - return Residue_type(mi); - } - }; - struct Modular_image_representative{ - NT operator()(const Residue_type& x){ - return NT(x.get_value()); - } - }; -}; - - -template<> -struct Needs_parens_as_product{ - bool operator()(const CORE::BigInt& x){ - return CGAL_NTS is_negative(x); - } -}; - -// Benchmark_rep specialization -template<> -class Benchmark_rep< CORE::BigInt > { - const CORE::BigInt& t; -public: - //! initialize with a const reference to \a t. - Benchmark_rep( const CORE::BigInt& tt) : t(tt) {} - //! perform the output, calls \c operator\<\< by default. - std::ostream& operator()( std::ostream& out) const { - out << t; - return out; - } - - static std::string get_benchmark_name() { - return "Integer"; - } -}; - - -} //namespace CGAL - -//since types are included by CORE_coercion_traits.h: -#include -#include -#include -#include - -namespace Eigen { - template struct NumTraits; - template<> struct NumTraits - { - typedef CORE::BigInt Real; - typedef CORE::BigRat NonInteger; - typedef CORE::BigInt Nested; - typedef CORE::BigInt Literal; - - static inline Real epsilon() { return 0; } - static inline Real dummy_precision() { return 0; } - - enum { - IsInteger = 1, - IsSigned = 1, - IsComplex = 0, - RequireInitialization = 1, - ReadCost = 6, - AddCost = 30, - MulCost = 50 - }; - }; -} -#endif - #include #endif // CGAL_CORE_BIGINT_H diff --git a/Number_types/include/CGAL/CORE_BigRat.h b/Number_types/include/CGAL/CORE_BigRat.h index c69b610673e7..48d8e950db23 100644 --- a/Number_types/include/CGAL/CORE_BigRat.h +++ b/Number_types/include/CGAL/CORE_BigRat.h @@ -20,241 +20,6 @@ #include #include // used for To_interval-functor -#if 0 - -//#if defined(CGAL_CORE_BIGRAT_NUMER_DENOM_ARE_MEMBERS) -// #define CGAL_CORE_NUMERATOR(X) ((X).numerator()) -// #define CGAL_CORE_DENOMINATOR(X) ((X).denominator()) -//#elif defined(CGAL_CORE_BIGRAT_NUMER_DENOM_ARE_NONMEMBERS) - #define CGAL_CORE_NUMERATOR(X) (numerator((X))) - #define CGAL_CORE_DENOMINATOR(X) (denominator((X))) -//#else - -namespace CGAL { - -// -// Algebraic structure traits -// -template <> class Algebraic_structure_traits< CORE::BigRat > - : public Algebraic_structure_traits_base< CORE::BigRat, - Field_tag > { - public: - typedef Tag_true Is_exact; - typedef Tag_false Is_numerical_sensitive; - - // BigRat are always normalized, so no special simplify-functor is needed - - // Nothing new... -}; - - - - -// -// Real embeddable traits -// -template <> class Real_embeddable_traits< CORE::BigRat > - : public INTERN_RET::Real_embeddable_traits_base< CORE::BigRat , CGAL::Tag_true > { - public: - - class Abs - : public CGAL::cpp98::unary_function< Type, Type > { - public: - Type operator()( const Type& x ) const { - return CORE::abs( x ); - } - }; - - class Sgn - : public CGAL::cpp98::unary_function< Type, ::CGAL::Sign > { - public: - ::CGAL::Sign operator()( const Type& x ) const { - return (::CGAL::Sign) CORE::sign( x ); - } - }; - - class Compare - : public CGAL::cpp98::binary_function< Type, Type, - Comparison_result > { - public: - Comparison_result operator()( const Type& x, - const Type& y ) const { - return CGAL::sign( ::CORE::cmp(x,y)); - } - CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT(Type,Comparison_result) - }; - - class To_double - : public CGAL::cpp98::unary_function< Type, double > { - public: - double operator()( const Type& x ) const { - // this call is required to get reasonable values for the double - // approximation - return x.doubleValue(); - } - }; - - class To_interval - : public CGAL::cpp98::unary_function< Type, std::pair< double, double > > { - public: - std::pair operator()( const Type& x_ ) const { - CORE::Expr x(x_); - std::pair result; - x.doubleInterval(result.first, result.second); - CGAL_expensive_assertion(result.first <= x); - CGAL_expensive_assertion(result.second >= x); - return result; - } - }; -}; - -/*! \ingroup NiX_Fraction_traits_spec - * \brief Specialization of Fraction_traits for ::leda::rational - */ -template <> -class Fraction_traits< CORE::BigRat > { -public: - typedef CORE::BigRat Type; - typedef ::CGAL::Tag_true Is_fraction; - typedef CORE::BigInt Numerator_type; - typedef Numerator_type Denominator_type; - - typedef Algebraic_structure_traits< Numerator_type >::Gcd Common_factor; - - class Decompose { - public: - typedef Type first_argument_type; - typedef Numerator_type& second_argument_type; - typedef Numerator_type& third_argument_type; - void operator () ( - const Type& rat, - Numerator_type& num, - Numerator_type& den) { - num = CGAL_CORE_NUMERATOR(rat); - den = CGAL_CORE_DENOMINATOR(rat); - } - }; - - class Compose { - public: - typedef Numerator_type first_argument_type; - typedef Numerator_type second_argument_type; - typedef Type result_type; - Type operator ()( - const Numerator_type& num , - const Numerator_type& den ) { - return Type(num, den); - } - }; -}; - -template -class Output_rep< ::CORE::BigRat, F> : public IO_rep_is_specialized { - const ::CORE::BigRat& t; -public: - //! initialize with a const reference to \a t. - Output_rep( const ::CORE::BigRat& tt) : t(tt) {} - //! perform the output, calls \c operator\<\< by default. - std::ostream& operator()( std::ostream& out) const { - switch (IO::get_mode(out)) { - case IO::PRETTY:{ - if(CGAL_CORE_DENOMINATOR(t) == ::CORE::BigRat(1)) - return out < -struct Needs_parens_as_product< ::CORE::BigRat >{ - bool operator()( ::CORE::BigRat t){ - if (CGAL_CORE_DENOMINATOR(t) != 1 ) - return true; - else - return needs_parens_as_product(CGAL_CORE_NUMERATOR(t)) ; - } -}; - -template <> -class Output_rep< ::CORE::BigRat, Parens_as_product_tag > - : public IO_rep_is_specialized -{ - const ::CORE::BigRat& t; -public: - // Constructor - Output_rep( const ::CORE::BigRat& tt) : t(tt) {} - // operator - std::ostream& operator()( std::ostream& out) const { - Needs_parens_as_product< ::CORE::BigRat > needs_parens_as_product; - if (needs_parens_as_product(t)) - return out <<"("<< IO::oformat(t) <<")"; - else - return out << IO::oformat(t); - } -}; - -// Benchmark_rep specialization -template<> -class Benchmark_rep< CORE::BigRat > { - const CORE::BigRat& t; -public: - //! initialize with a const reference to \a t. - Benchmark_rep( const CORE::BigRat& tt) : t(tt) {} - //! perform the output, calls \c operator\<\< by default. - std::ostream& operator()( std::ostream& out) const { - out << "Rational(" << numerator(t) << "," << denominator(t) << ")"; - return out; - } - - static std::string get_benchmark_name() { - return "Rational"; - } -}; - -} //namespace CGAL - -//since types are included by CORE_coercion_traits.h: -#include -#include -#include -#include - -namespace Eigen { - template struct NumTraits; - template<> struct NumTraits - { - typedef CORE::BigRat Real; - typedef CORE::BigRat NonInteger; - typedef CORE::BigRat Nested; - typedef CORE::BigRat Literal; - - static inline Real epsilon() { return 0; } - static inline Real dummy_precision() { return 0; } - - enum { - IsInteger = 0, - IsSigned = 1, - IsComplex = 0, - RequireInitialization = 1, - ReadCost = 6, - AddCost = 150, - MulCost = 100 - }; - }; -} - -#endif - #include #endif // CGAL_CORE_BIGRAT_H From acbe714a140516c0bc0b02f4ac58b9609c9ff5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 20 Feb 2023 13:56:21 +0100 Subject: [PATCH 052/139] update rules for using/finding core --- Installation/CMakeLists.txt | 2 +- .../modules/CGAL_SetupCGAL_CoreDependencies.cmake | 14 ++++---------- .../cmake/modules/CGAL_SetupDependencies.cmake | 13 ------------- .../internal/enable_third_party_libraries.h | 6 ------ 4 files changed, 5 insertions(+), 30 deletions(-) delete mode 100644 Installation/cmake/modules/CGAL_SetupDependencies.cmake diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 8d48e93b39f9..e028db7e38fc 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -941,7 +941,7 @@ if(CGAL_BRANCH_BUILD) set(compile_options "\ -${CMAKE_CXX_FLAGS} -DCGAL_EIGEN3_ENABLED -DCGAL_PROFILE \ +${CMAKE_CXX_FLAGS} -DCGAL_EIGEN3_ENABLED -DCGAL_PROFILE -DCGAL_USE_CORE \ ${Qt5Widgets_DEFINITIONS} ${Qt5OpenGL_DEFINITIONS} ${Qt5Gui_DEFINITIONS} \ ${Qt5OpenGL_EXECUTABLE_COMPILE_FLAGS} -fPIC \ ${Qt5Gui_EXECUTABLE_COMPILE_FLAGS} \ diff --git a/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake b/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake index 0b1eee31681c..44be800f9c01 100644 --- a/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake +++ b/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake @@ -18,9 +18,6 @@ endif() set(CGAL_SetupCGAL_CoreDependencies_included TRUE) #.rst: -# Used Modules -# ^^^^^^^^^^^^ -# - :module:`CGAL_SetupGMP` # # Result Variables # ^^^^^^^^^^^^^^^^ @@ -29,13 +26,10 @@ set(CGAL_SetupCGAL_CoreDependencies_included TRUE) # # Set to `TRUE` if the dependencies of `CGAL_Core` were found. -if(NOT CGAL_DISABLE_GMP) - include(${CMAKE_CURRENT_LIST_DIR}/CGAL_SetupGMP.cmake) - if(GMP_FOUND) - set(CGAL_Core_FOUND TRUE) - set_property(GLOBAL PROPERTY CGAL_Core_FOUND TRUE) - endif() -endif() + +# always found as it requires the minimal version of boost required by CGAL +set(CGAL_Core_FOUND TRUE) +set_property(GLOBAL PROPERTY CGAL_Core_FOUND TRUE) #.rst: # diff --git a/Installation/cmake/modules/CGAL_SetupDependencies.cmake b/Installation/cmake/modules/CGAL_SetupDependencies.cmake deleted file mode 100644 index 6051c7d3ce47..000000000000 --- a/Installation/cmake/modules/CGAL_SetupDependencies.cmake +++ /dev/null @@ -1,13 +0,0 @@ -include(${CMAKE_CURRENT_LIST_DIR}/CGAL_Macros.cmake) - -if( (GMP_FOUND AND NOT MPFR_FOUND) OR (NOT GMP_FOUND AND MPFR_FOUND) ) - message( FATAL_ERROR "CGAL needs for its full functionality both GMP and MPFR.") -endif() - -if( NOT GMP_FOUND ) - set(CGAL_NO_CORE ON) - message( STATUS "CGAL_Core needs GMP, cannot be configured.") -endif( NOT GMP_FOUND ) - -# finally setup Boost -include(${CMAKE_CURRENT_LIST_DIR}/CGAL_SetupBoost.cmake) diff --git a/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h b/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h index 2df627952a34..374a09b26334 100644 --- a/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h +++ b/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h @@ -27,18 +27,12 @@ #if defined(__has_include) && ( ! defined _MSC_VER || _MSC_VER > 1900) # if CGAL_USE_GMP && ! __has_include() -# pragma CGAL_WARNING(" cannot be found. Less efficient number types will be used instead. Define CGAL_NO_GMP=1 if that is on purpose.") # undef CGAL_USE_GMP # undef CGAL_USE_MPFR # elif CGAL_USE_MPFR && ! __has_include() -# pragma CGAL_WARNING(" cannot be found and the GMP support in CGAL requires it. Less efficient number types will be used instead. Define CGAL_NO_GMP=1 if that is on purpose.") # undef CGAL_USE_GMP # undef CGAL_USE_MPFR # endif // CGAL_USE_MPFR and no #endif // __has_include -#if CGAL_USE_GMP && CGAL_USE_MPFR && ! CGAL_NO_CORE -# define CGAL_USE_CORE 1 -#endif - #endif // CGAL_INTERNAL_ENABLE_THIRD_PARTY_LIBRARIES_H From 9e723615372cf947703d05c63783515191c5720e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 20 Feb 2023 15:23:40 +0100 Subject: [PATCH 053/139] All packages depends now on CGAL_Core (like Kernel) --- .../Advancing_front_surface_reconstruction/dependencies | 1 + Alpha_shapes_2/package_info/Alpha_shapes_2/dependencies | 1 + Alpha_shapes_3/package_info/Alpha_shapes_3/dependencies | 1 + Alpha_wrap_3/package_info/Alpha_wrap_3/dependencies | 1 + .../package_info/Barycentric_coordinates_2/dependencies | 1 + .../package_info/Boolean_set_operations_2/dependencies | 1 + Combinatorial_map/package_info/Combinatorial_map/dependencies | 1 + .../package_info/Convex_decomposition_3/dependencies | 1 + Convex_hull_3/package_info/Convex_hull_3/dependencies | 1 + Envelope_3/package_info/Envelope_3/dependencies | 1 + Filtered_kernel/package_info/Filtered_kernel/dependencies | 1 + Generalized_map/package_info/Generalized_map/dependencies | 1 + .../package_info/Linear_cell_complex/dependencies | 1 + Mesh_3/package_info/Mesh_3/dependencies | 1 + Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies | 1 + Minkowski_sum_3/package_info/Minkowski_sum_3/dependencies | 1 + Nef_3/package_info/Nef_3/dependencies | 1 + NewKernel_d/package_info/NewKernel_d/dependencies | 1 + .../package_info/Optimal_bounding_box/dependencies | 1 + Partition_2/package_info/Partition_2/dependencies | 1 + Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies | 1 + .../package_info/Periodic_3_triangulation_3/dependencies | 1 + .../package_info/Point_set_processing_3/dependencies | 1 + .../package_info/Poisson_surface_reconstruction_3/dependencies | 1 + .../package_info/Polygon_mesh_processing/dependencies | 1 + .../package_info/Polygonal_surface_reconstruction/dependencies | 1 + .../package_info/Polyline_simplification_2/dependencies | 1 + .../package_info/Polytope_distance_d/dependencies | 1 + SMDS_3/package_info/SMDS_3/dependencies | 1 + .../package_info/Scale_space_reconstruction_3/dependencies | 1 + .../package_info/Segment_Delaunay_graph_2/dependencies | 1 + .../package_info/Segment_Delaunay_graph_Linf_2/dependencies | 1 + Shape_detection/package_info/Shape_detection/dependencies | 1 + Skin_surface_3/package_info/Skin_surface_3/dependencies | 1 + Snap_rounding_2/package_info/Snap_rounding_2/dependencies | 1 + .../package_info/Surface_mesh_parameterization/dependencies | 1 + .../package_info/Surface_mesh_skeletonization/dependencies | 1 + .../package_info/Surface_mesh_topology/dependencies | 1 + Surface_mesher/package_info/Surface_mesher/dependencies | 1 + Surface_sweep_2/package_info/Surface_sweep_2/dependencies | 1 + .../package_info/Tetrahedral_remeshing/dependencies | 1 + Triangulation_2/package_info/Triangulation_2/dependencies | 1 + Triangulation_3/package_info/Triangulation_3/dependencies | 1 + Visibility_2/package_info/Visibility_2/dependencies | 1 + 44 files changed, 44 insertions(+) diff --git a/Advancing_front_surface_reconstruction/package_info/Advancing_front_surface_reconstruction/dependencies b/Advancing_front_surface_reconstruction/package_info/Advancing_front_surface_reconstruction/dependencies index fffe4db3c74c..d885997679a9 100644 --- a/Advancing_front_surface_reconstruction/package_info/Advancing_front_surface_reconstruction/dependencies +++ b/Advancing_front_surface_reconstruction/package_info/Advancing_front_surface_reconstruction/dependencies @@ -2,6 +2,7 @@ Advancing_front_surface_reconstruction Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Alpha_shapes_2/package_info/Alpha_shapes_2/dependencies b/Alpha_shapes_2/package_info/Alpha_shapes_2/dependencies index eee8e076278c..dc2861d15dfb 100644 --- a/Alpha_shapes_2/package_info/Alpha_shapes_2/dependencies +++ b/Alpha_shapes_2/package_info/Alpha_shapes_2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Alpha_shapes_2 Arithmetic_kernel +CGAL_Core Cartesian_kernel Filtered_kernel Hash_map diff --git a/Alpha_shapes_3/package_info/Alpha_shapes_3/dependencies b/Alpha_shapes_3/package_info/Alpha_shapes_3/dependencies index f0dc76c90d99..516a70a2bdeb 100644 --- a/Alpha_shapes_3/package_info/Alpha_shapes_3/dependencies +++ b/Alpha_shapes_3/package_info/Alpha_shapes_3/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Alpha_shapes_3 Arithmetic_kernel +CGAL_Core Cartesian_kernel Circulator Filtered_kernel diff --git a/Alpha_wrap_3/package_info/Alpha_wrap_3/dependencies b/Alpha_wrap_3/package_info/Alpha_wrap_3/dependencies index 7645e1ba53c5..a3f60578532c 100644 --- a/Alpha_wrap_3/package_info/Alpha_wrap_3/dependencies +++ b/Alpha_wrap_3/package_info/Alpha_wrap_3/dependencies @@ -4,6 +4,7 @@ Alpha_wrap_3 Arithmetic_kernel BGL Box_intersection_d +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/dependencies b/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/dependencies index ee1e1d6538ae..1ea1e70b883e 100644 --- a/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/dependencies +++ b/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Arithmetic_kernel BGL Barycentric_coordinates_2 +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Boolean_set_operations_2/package_info/Boolean_set_operations_2/dependencies b/Boolean_set_operations_2/package_info/Boolean_set_operations_2/dependencies index a4d2b53c7b30..c5720a8c2b1f 100644 --- a/Boolean_set_operations_2/package_info/Boolean_set_operations_2/dependencies +++ b/Boolean_set_operations_2/package_info/Boolean_set_operations_2/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Arithmetic_kernel Arrangement_on_surface_2 Boolean_set_operations_2 +CGAL_Core Cartesian_kernel Circular_kernel_2 Circulator diff --git a/Combinatorial_map/package_info/Combinatorial_map/dependencies b/Combinatorial_map/package_info/Combinatorial_map/dependencies index 279a01a72ae2..0902e1798f1a 100644 --- a/Combinatorial_map/package_info/Combinatorial_map/dependencies +++ b/Combinatorial_map/package_info/Combinatorial_map/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Combinatorial_map diff --git a/Convex_decomposition_3/package_info/Convex_decomposition_3/dependencies b/Convex_decomposition_3/package_info/Convex_decomposition_3/dependencies index fa1556add87e..09382985c877 100644 --- a/Convex_decomposition_3/package_info/Convex_decomposition_3/dependencies +++ b/Convex_decomposition_3/package_info/Convex_decomposition_3/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Arithmetic_kernel BGL Box_intersection_d +CGAL_Core Cartesian_kernel Circulator Convex_decomposition_3 diff --git a/Convex_hull_3/package_info/Convex_hull_3/dependencies b/Convex_hull_3/package_info/Convex_hull_3/dependencies index 406722ba9aff..bdd3aa15916c 100644 --- a/Convex_hull_3/package_info/Convex_hull_3/dependencies +++ b/Convex_hull_3/package_info/Convex_hull_3/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Envelope_3/package_info/Envelope_3/dependencies b/Envelope_3/package_info/Envelope_3/dependencies index 059d79cfb7d6..08c16e6cadf5 100644 --- a/Envelope_3/package_info/Envelope_3/dependencies +++ b/Envelope_3/package_info/Envelope_3/dependencies @@ -3,6 +3,7 @@ Apollonius_graph_2 Arithmetic_kernel Arrangement_on_surface_2 BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Filtered_kernel/package_info/Filtered_kernel/dependencies b/Filtered_kernel/package_info/Filtered_kernel/dependencies index 4b009ce54e47..5e320e639525 100644 --- a/Filtered_kernel/package_info/Filtered_kernel/dependencies +++ b/Filtered_kernel/package_info/Filtered_kernel/dependencies @@ -1,5 +1,6 @@ Algebraic_foundations Arithmetic_kernel +CGAL_Core Cartesian_kernel Distance_2 Distance_3 diff --git a/Generalized_map/package_info/Generalized_map/dependencies b/Generalized_map/package_info/Generalized_map/dependencies index bf19ede8a16d..97e368892d5e 100644 --- a/Generalized_map/package_info/Generalized_map/dependencies +++ b/Generalized_map/package_info/Generalized_map/dependencies @@ -1,5 +1,6 @@ Algebraic_foundations Arithmetic_kernel +CGAL_Core Cartesian_kernel Circulator Combinatorial_map diff --git a/Linear_cell_complex/package_info/Linear_cell_complex/dependencies b/Linear_cell_complex/package_info/Linear_cell_complex/dependencies index 53e5ce3f1530..a3ecaf39ee28 100644 --- a/Linear_cell_complex/package_info/Linear_cell_complex/dependencies +++ b/Linear_cell_complex/package_info/Linear_cell_complex/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Combinatorial_map diff --git a/Mesh_3/package_info/Mesh_3/dependencies b/Mesh_3/package_info/Mesh_3/dependencies index 65eec56b3606..0f9c65cd105b 100644 --- a/Mesh_3/package_info/Mesh_3/dependencies +++ b/Mesh_3/package_info/Mesh_3/dependencies @@ -2,6 +2,7 @@ AABB_tree Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core CGAL_ImageIO Cartesian_kernel Circulator diff --git a/Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies b/Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies index 62f64c4bfd1c..a71a4c66f559 100644 --- a/Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies +++ b/Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies @@ -3,6 +3,7 @@ Algebraic_foundations Arithmetic_kernel Arrangement_on_surface_2 Boolean_set_operations_2 +CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Minkowski_sum_3/package_info/Minkowski_sum_3/dependencies b/Minkowski_sum_3/package_info/Minkowski_sum_3/dependencies index e2123abc9c96..b60f37e8338f 100644 --- a/Minkowski_sum_3/package_info/Minkowski_sum_3/dependencies +++ b/Minkowski_sum_3/package_info/Minkowski_sum_3/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Arithmetic_kernel BGL Box_intersection_d +CGAL_Core Cartesian_kernel Circulator Convex_decomposition_3 diff --git a/Nef_3/package_info/Nef_3/dependencies b/Nef_3/package_info/Nef_3/dependencies index 7fec88e23734..92337ba55f10 100644 --- a/Nef_3/package_info/Nef_3/dependencies +++ b/Nef_3/package_info/Nef_3/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Arithmetic_kernel BGL Box_intersection_d +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/NewKernel_d/package_info/NewKernel_d/dependencies b/NewKernel_d/package_info/NewKernel_d/dependencies index 04e1d32ff873..bfb2e6e60407 100644 --- a/NewKernel_d/package_info/NewKernel_d/dependencies +++ b/NewKernel_d/package_info/NewKernel_d/dependencies @@ -1,5 +1,6 @@ Algebraic_foundations Arithmetic_kernel +CGAL_Core Filtered_kernel Installation Interval_support diff --git a/Optimal_bounding_box/package_info/Optimal_bounding_box/dependencies b/Optimal_bounding_box/package_info/Optimal_bounding_box/dependencies index 249760e29284..37cb6893ab85 100644 --- a/Optimal_bounding_box/package_info/Optimal_bounding_box/dependencies +++ b/Optimal_bounding_box/package_info/Optimal_bounding_box/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Arithmetic_kernel BGL Bounding_volumes +CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Partition_2/package_info/Partition_2/dependencies b/Partition_2/package_info/Partition_2/dependencies index 0d4ee19ad2b1..2d383a64c885 100644 --- a/Partition_2/package_info/Partition_2/dependencies +++ b/Partition_2/package_info/Partition_2/dependencies @@ -1,5 +1,6 @@ Algebraic_foundations Arithmetic_kernel +CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies b/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies index eb2b8e24cc3a..bd1fc7bd057f 100644 --- a/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies +++ b/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Periodic_3_triangulation_3/package_info/Periodic_3_triangulation_3/dependencies b/Periodic_3_triangulation_3/package_info/Periodic_3_triangulation_3/dependencies index b31b936ff044..619cafd06060 100644 --- a/Periodic_3_triangulation_3/package_info/Periodic_3_triangulation_3/dependencies +++ b/Periodic_3_triangulation_3/package_info/Periodic_3_triangulation_3/dependencies @@ -1,5 +1,6 @@ Algebraic_foundations Arithmetic_kernel +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Point_set_processing_3/package_info/Point_set_processing_3/dependencies b/Point_set_processing_3/package_info/Point_set_processing_3/dependencies index dcdadf3e8dcc..3d33ad32a3e6 100644 --- a/Point_set_processing_3/package_info/Point_set_processing_3/dependencies +++ b/Point_set_processing_3/package_info/Point_set_processing_3/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Poisson_surface_reconstruction_3/package_info/Poisson_surface_reconstruction_3/dependencies b/Poisson_surface_reconstruction_3/package_info/Poisson_surface_reconstruction_3/dependencies index 5c532a3d624e..e8a4a934cd68 100644 --- a/Poisson_surface_reconstruction_3/package_info/Poisson_surface_reconstruction_3/dependencies +++ b/Poisson_surface_reconstruction_3/package_info/Poisson_surface_reconstruction_3/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Polygon_mesh_processing/package_info/Polygon_mesh_processing/dependencies b/Polygon_mesh_processing/package_info/Polygon_mesh_processing/dependencies index 6d471658093c..f44718e3c9bc 100644 --- a/Polygon_mesh_processing/package_info/Polygon_mesh_processing/dependencies +++ b/Polygon_mesh_processing/package_info/Polygon_mesh_processing/dependencies @@ -3,6 +3,7 @@ Algebraic_foundations Arithmetic_kernel BGL Box_intersection_d +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies b/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies index cf61d44e4ba4..48a6a2244aae 100644 --- a/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies +++ b/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Alpha_shapes_2 Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Polyline_simplification_2/package_info/Polyline_simplification_2/dependencies b/Polyline_simplification_2/package_info/Polyline_simplification_2/dependencies index 46b60927a441..b1e47ef32221 100644 --- a/Polyline_simplification_2/package_info/Polyline_simplification_2/dependencies +++ b/Polyline_simplification_2/package_info/Polyline_simplification_2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Polytope_distance_d/package_info/Polytope_distance_d/dependencies b/Polytope_distance_d/package_info/Polytope_distance_d/dependencies index 2ec81fe38f8a..4b0007880c16 100644 --- a/Polytope_distance_d/package_info/Polytope_distance_d/dependencies +++ b/Polytope_distance_d/package_info/Polytope_distance_d/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/SMDS_3/package_info/SMDS_3/dependencies b/SMDS_3/package_info/SMDS_3/dependencies index bebf22165bb0..749f4764b554 100644 --- a/SMDS_3/package_info/SMDS_3/dependencies +++ b/SMDS_3/package_info/SMDS_3/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Scale_space_reconstruction_3/package_info/Scale_space_reconstruction_3/dependencies b/Scale_space_reconstruction_3/package_info/Scale_space_reconstruction_3/dependencies index 114d4ba5acdb..4582cf68fe68 100644 --- a/Scale_space_reconstruction_3/package_info/Scale_space_reconstruction_3/dependencies +++ b/Scale_space_reconstruction_3/package_info/Scale_space_reconstruction_3/dependencies @@ -3,6 +3,7 @@ Algebraic_foundations Alpha_shapes_3 Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Segment_Delaunay_graph_2/package_info/Segment_Delaunay_graph_2/dependencies b/Segment_Delaunay_graph_2/package_info/Segment_Delaunay_graph_2/dependencies index c3083729fefd..62981bc0f230 100644 --- a/Segment_Delaunay_graph_2/package_info/Segment_Delaunay_graph_2/dependencies +++ b/Segment_Delaunay_graph_2/package_info/Segment_Delaunay_graph_2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Apollonius_graph_2 Arithmetic_kernel +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Segment_Delaunay_graph_Linf_2/package_info/Segment_Delaunay_graph_Linf_2/dependencies b/Segment_Delaunay_graph_Linf_2/package_info/Segment_Delaunay_graph_Linf_2/dependencies index 783d3ee4cb25..d680be9c38d5 100644 --- a/Segment_Delaunay_graph_Linf_2/package_info/Segment_Delaunay_graph_Linf_2/dependencies +++ b/Segment_Delaunay_graph_Linf_2/package_info/Segment_Delaunay_graph_Linf_2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Apollonius_graph_2 Arithmetic_kernel +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Shape_detection/package_info/Shape_detection/dependencies b/Shape_detection/package_info/Shape_detection/dependencies index 0e1d2b209850..36091d70ae16 100644 --- a/Shape_detection/package_info/Shape_detection/dependencies +++ b/Shape_detection/package_info/Shape_detection/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Skin_surface_3/package_info/Skin_surface_3/dependencies b/Skin_surface_3/package_info/Skin_surface_3/dependencies index fb635c6334cc..e04beb03945c 100644 --- a/Skin_surface_3/package_info/Skin_surface_3/dependencies +++ b/Skin_surface_3/package_info/Skin_surface_3/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Snap_rounding_2/package_info/Snap_rounding_2/dependencies b/Snap_rounding_2/package_info/Snap_rounding_2/dependencies index 2d53f573e0d6..9b654c5c0ccd 100644 --- a/Snap_rounding_2/package_info/Snap_rounding_2/dependencies +++ b/Snap_rounding_2/package_info/Snap_rounding_2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel Arrangement_on_surface_2 +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Surface_mesh_parameterization/package_info/Surface_mesh_parameterization/dependencies b/Surface_mesh_parameterization/package_info/Surface_mesh_parameterization/dependencies index e21fc4d23192..70e020320af3 100644 --- a/Surface_mesh_parameterization/package_info/Surface_mesh_parameterization/dependencies +++ b/Surface_mesh_parameterization/package_info/Surface_mesh_parameterization/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Arithmetic_kernel BGL Box_intersection_d +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Surface_mesh_skeletonization/package_info/Surface_mesh_skeletonization/dependencies b/Surface_mesh_skeletonization/package_info/Surface_mesh_skeletonization/dependencies index 93a216163663..cea4bd48a905 100644 --- a/Surface_mesh_skeletonization/package_info/Surface_mesh_skeletonization/dependencies +++ b/Surface_mesh_skeletonization/package_info/Surface_mesh_skeletonization/dependencies @@ -2,6 +2,7 @@ AABB_tree Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Surface_mesh_topology/package_info/Surface_mesh_topology/dependencies b/Surface_mesh_topology/package_info/Surface_mesh_topology/dependencies index dc2f511d1b24..91f6a41ad104 100644 --- a/Surface_mesh_topology/package_info/Surface_mesh_topology/dependencies +++ b/Surface_mesh_topology/package_info/Surface_mesh_topology/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Combinatorial_map diff --git a/Surface_mesher/package_info/Surface_mesher/dependencies b/Surface_mesher/package_info/Surface_mesher/dependencies index e6e8a3909664..bfe6c4d3548e 100644 --- a/Surface_mesher/package_info/Surface_mesher/dependencies +++ b/Surface_mesher/package_info/Surface_mesher/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core CGAL_ImageIO Cartesian_kernel Circulator diff --git a/Surface_sweep_2/package_info/Surface_sweep_2/dependencies b/Surface_sweep_2/package_info/Surface_sweep_2/dependencies index 09546686abf3..1a04d474a621 100644 --- a/Surface_sweep_2/package_info/Surface_sweep_2/dependencies +++ b/Surface_sweep_2/package_info/Surface_sweep_2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel Arrangement_on_surface_2 +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Tetrahedral_remeshing/package_info/Tetrahedral_remeshing/dependencies b/Tetrahedral_remeshing/package_info/Tetrahedral_remeshing/dependencies index d9c5098d64f6..f9c578d62a23 100644 --- a/Tetrahedral_remeshing/package_info/Tetrahedral_remeshing/dependencies +++ b/Tetrahedral_remeshing/package_info/Tetrahedral_remeshing/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Triangulation_2/package_info/Triangulation_2/dependencies b/Triangulation_2/package_info/Triangulation_2/dependencies index c8d90b721ca3..e5682c455234 100644 --- a/Triangulation_2/package_info/Triangulation_2/dependencies +++ b/Triangulation_2/package_info/Triangulation_2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Triangulation_3/package_info/Triangulation_3/dependencies b/Triangulation_3/package_info/Triangulation_3/dependencies index a68982ddaa59..15e6860497ea 100644 --- a/Triangulation_3/package_info/Triangulation_3/dependencies +++ b/Triangulation_3/package_info/Triangulation_3/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Visibility_2/package_info/Visibility_2/dependencies b/Visibility_2/package_info/Visibility_2/dependencies index e8367c224170..2199ba4f76d3 100644 --- a/Visibility_2/package_info/Visibility_2/dependencies +++ b/Visibility_2/package_info/Visibility_2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel Arrangement_on_surface_2 +CGAL_Core Cartesian_kernel Circulator Distance_2 From 996d173347cc671347745a31e45785879a9ccea8 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 7 Mar 2023 12:49:47 +0000 Subject: [PATCH 054/139] Fix Envelope_3 --- Envelope_3/include/CGAL/Env_sphere_traits_3.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Envelope_3/include/CGAL/Env_sphere_traits_3.h b/Envelope_3/include/CGAL/Env_sphere_traits_3.h index e36e284367fe..e38718cc5141 100644 --- a/Envelope_3/include/CGAL/Env_sphere_traits_3.h +++ b/Envelope_3/include/CGAL/Env_sphere_traits_3.h @@ -330,7 +330,7 @@ class Env_sphere_traits_3 : public ConicTraits_2 if (n_xs == 1) { // intersection is a point - Point_2 inter_point(xs[0], (-2*a_diff*xs[0] + m)/(2*b_diff) ); + Point_2 inter_point(xs[0], (Rational(- 2 * a_diff) * xs[0] + m) / Rational(2 * b_diff)); *o++ = make_object(inter_point); return o; } @@ -340,8 +340,8 @@ class Env_sphere_traits_3 : public ConicTraits_2 // so we construct a COLLINEAR conic (with equation as in (1)) // with 2 endpoints Algebraic ys[2]; - ys[0] = (-2*a_diff*xs[0] + m)/(2*b_diff); - ys[1] = (-2*a_diff*xs[1] + m)/(2*b_diff); + ys[0] = (Rational(-2*a_diff)*xs[0] + m)/Rational(2*b_diff); + ys[1] = (Rational(-2*a_diff)*xs[1] + m)/Rational(2*b_diff); Alg_point_2 end1(xs[0], ys[0]); Alg_point_2 end2(xs[1], ys[1]); @@ -969,8 +969,8 @@ class Env_sphere_traits_3 : public ConicTraits_2 // -m*x + n*y + (m*x0 -n*y0) = 0 (with integer coordinates) const Rational r = cv.r(), s = cv.s(), t = cv.t(), u = cv.u(), v = cv.v(), w = cv.w(); - Algebraic m = -1 * (2*r*x0 + t*y0 + u); - Algebraic n = 2*s*y0 + t*x0 + v; + Algebraic m = -1 * (Rational(2*r)*x0 + t*y0 + u); + Algebraic n = Rational(2*s)*y0 + t*x0 + v; // line coefficients: A3, B3, C3 Algebraic A3 = -1*m, B3 = n, C3 = m*x0 - n*y0; @@ -1081,7 +1081,7 @@ class Env_sphere_traits_3 : public ConicTraits_2 // the coefficients are: Algebraic A = 1, B = -2*c, - C = x_diff*x_diff + y_diff*y_diff + c*c - sqr_r; + C = x_diff*x_diff + y_diff*y_diff + Rational(c*c) - sqr_r; Algebraic zs[2]; Algebraic *zs_end; From a714a6f5db9458842e75175d856779137480deaa Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 7 Mar 2023 12:56:46 +0000 Subject: [PATCH 055/139] Fix Surface_sweep --- .../include/CGAL/Arr_geometry_traits/Conic_arc_2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_arc_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_arc_2.h index 9f19658b1e16..4b4d223557ab 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_arc_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_arc_2.h @@ -1750,7 +1750,7 @@ class _Conic_arc_2 // Having computed y, x is the single solution to the quadratic equation // above, and since its discriminant is 0, x is simply given by: x = -(nt_traits.convert(_t)*ys[i] + nt_traits.convert(_u)) / - nt_traits.convert(_two*_r); + nt_traits.convert(Integer(_two * _r)); ps[i] = Point_2 (x, ys[i]); } From ba6893b23911abe100d0e606343ab1b321d96573 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 7 Mar 2023 13:05:03 +0000 Subject: [PATCH 056/139] debug output, as I cannot reproduce locally --- Polynomial/test/Polynomial/test_polynomial.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polynomial/test/Polynomial/test_polynomial.h b/Polynomial/test/Polynomial/test_polynomial.h index 5637578e945b..4b6982b30006 100644 --- a/Polynomial/test/Polynomial/test_polynomial.h +++ b/Polynomial/test/Polynomial/test_polynomial.h @@ -307,7 +307,7 @@ void io() { std::ostringstream os; CGAL::IO::set_pretty_mode(os); os << CGAL::IO::oformat(POLY(NT(3))); - //std::cout < Date: Tue, 7 Mar 2023 13:13:30 +0000 Subject: [PATCH 057/139] Fix Polynomial --- .../CGAL/Algebraic_kernel_d/Bitstream_descartes_rndl_tree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Bitstream_descartes_rndl_tree.h b/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Bitstream_descartes_rndl_tree.h index cba01cdc9116..a76e1c6cecae 100644 --- a/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Bitstream_descartes_rndl_tree.h +++ b/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Bitstream_descartes_rndl_tree.h @@ -206,7 +206,7 @@ polynomial_power_to_bernstein_approx( std::vector f(n+1); polynomial_affine_transform_approx_log_denom( first, beyond, f.begin(), - upper_num - lower_num, lower_num, log_denom, + Integer(upper_num - lower_num), lower_num, log_denom, p+q, approx, log, logl ); From 8b200b25beefaa2a1081f1724feddf95bc08ef94 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 7 Mar 2023 13:20:18 +0000 Subject: [PATCH 058/139] debug output, as I cannot reproduce locally --- Number_types/test/Number_types/CORE_BigInt.cpp | 1 + Number_types/test/Number_types/CORE_BigRat.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/Number_types/test/Number_types/CORE_BigInt.cpp b/Number_types/test/Number_types/CORE_BigInt.cpp index 79b207d2d87e..4ef8f8c1e236 100644 --- a/Number_types/test/Number_types/CORE_BigInt.cpp +++ b/Number_types/test/Number_types/CORE_BigInt.cpp @@ -33,6 +33,7 @@ void test_io(){ std::stringstream ss; CGAL::IO::set_pretty_mode(ss); ss << CGAL::IO::oformat(NT(1), CGAL::Parens_as_product_tag()); + std::cout << "|" << ss.str() << "|" << std::endl; assert( ss.str() == "1"); }{ std::stringstream ss; diff --git a/Number_types/test/Number_types/CORE_BigRat.cpp b/Number_types/test/Number_types/CORE_BigRat.cpp index 491bf73ea0ec..566bc8c5358a 100644 --- a/Number_types/test/Number_types/CORE_BigRat.cpp +++ b/Number_types/test/Number_types/CORE_BigRat.cpp @@ -37,6 +37,7 @@ void test_io(){ std::stringstream ss; CGAL::IO::set_pretty_mode(ss); ss << CGAL::IO::oformat(NT(2), CGAL::Parens_as_product_tag()); + std::cout << "|" << ss.str() << "|" << std::endl; assert( ss.str() == "2"); }{ std::stringstream ss; From d0ad8e03bd0938fbb58bd8b39a01cb1887403a31 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 7 Mar 2023 13:30:40 +0000 Subject: [PATCH 059/139] Fix include guard --- CGAL_Core/include/CGAL/CORE/Promote.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CGAL_Core/include/CGAL/CORE/Promote.h b/CGAL_Core/include/CGAL/CORE/Promote.h index fa2b9e79b88a..2bc334c959ad 100644 --- a/CGAL_Core/include/CGAL/CORE/Promote.h +++ b/CGAL_Core/include/CGAL/CORE/Promote.h @@ -27,7 +27,7 @@ ***************************************************************************/ #ifndef _CORE_PROMOTE_H__ -#define _COEE_PROMOTE_H__ +#define _CORE_PROMOTE_H__ #include #include From cb9c99592110706ac4d99ef3fc457d59c87d9598 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 8 Mar 2023 09:48:15 +0000 Subject: [PATCH 060/139] Fix for Envelope_3 --- Envelope_3/include/CGAL/Env_sphere_traits_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Envelope_3/include/CGAL/Env_sphere_traits_3.h b/Envelope_3/include/CGAL/Env_sphere_traits_3.h index e38718cc5141..dd6193cab4db 100644 --- a/Envelope_3/include/CGAL/Env_sphere_traits_3.h +++ b/Envelope_3/include/CGAL/Env_sphere_traits_3.h @@ -248,7 +248,7 @@ class Env_sphere_traits_3 : public ConicTraits_2 } // the x coordinate of the solution points - Algebraic xs = m / (2*a_diff); + Algebraic xs = Rational(m / (2*a_diff)); if (n_ys == 1) { From ca477995c9d52c1580b714032947a99b7f42364d Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 8 Mar 2023 11:14:02 +0000 Subject: [PATCH 061/139] Add Need_parens_as_product for the GMP backend --- Number_types/include/CGAL/boost_mp_type.h | 19 +++++++++++++++++++ .../test/Number_types/CORE_BigInt.cpp | 1 - Polynomial/test/Polynomial/test_polynomial.h | 1 - 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Number_types/include/CGAL/boost_mp_type.h b/Number_types/include/CGAL/boost_mp_type.h index d8f77fbbcba5..731364b43c76 100644 --- a/Number_types/include/CGAL/boost_mp_type.h +++ b/Number_types/include/CGAL/boost_mp_type.h @@ -75,6 +75,25 @@ struct Needs_parens_as_product{ }; +template<> +struct Needs_parens_as_product{ + bool operator()(const typename boost::multiprecision::mpz_int& x){ + return x < 0; + } +}; + +template<> +struct Needs_parens_as_product{ + bool operator()(const typename boost::multiprecision::mpq_rational& x){ + if (denominator(x) != 1 ) + return true; + else + return needs_parens_as_product(numerator(x)) ; + } + +}; + + // Algebraic_structure_traits diff --git a/Number_types/test/Number_types/CORE_BigInt.cpp b/Number_types/test/Number_types/CORE_BigInt.cpp index 4ef8f8c1e236..79b207d2d87e 100644 --- a/Number_types/test/Number_types/CORE_BigInt.cpp +++ b/Number_types/test/Number_types/CORE_BigInt.cpp @@ -33,7 +33,6 @@ void test_io(){ std::stringstream ss; CGAL::IO::set_pretty_mode(ss); ss << CGAL::IO::oformat(NT(1), CGAL::Parens_as_product_tag()); - std::cout << "|" << ss.str() << "|" << std::endl; assert( ss.str() == "1"); }{ std::stringstream ss; diff --git a/Polynomial/test/Polynomial/test_polynomial.h b/Polynomial/test/Polynomial/test_polynomial.h index 4b6982b30006..2ab2964df16c 100644 --- a/Polynomial/test/Polynomial/test_polynomial.h +++ b/Polynomial/test/Polynomial/test_polynomial.h @@ -307,7 +307,6 @@ void io() { std::ostringstream os; CGAL::IO::set_pretty_mode(os); os << CGAL::IO::oformat(POLY(NT(3))); - std::cout << "|" << os.str() << "|" < Date: Thu, 9 Mar 2023 13:12:32 +0000 Subject: [PATCH 062/139] Use the CGAL assertions/warnings/errors in Core --- CGAL_Core/include/CGAL/CORE/BigFloat_impl.h | 20 +++++++------------- CGAL_Core/include/CGAL/CORE/CoreAux_impl.h | 2 +- CGAL_Core/include/CGAL/CORE/Expr.h | 20 +++++--------------- CGAL_Core/include/CGAL/CORE/ExprRep.h | 20 ++++++-------------- CGAL_Core/include/CGAL/CORE/Expr_impl.h | 15 ++++++--------- CGAL_Core/include/CGAL/CORE/Filter.h | 8 ++++---- CGAL_Core/include/CGAL/CORE/extLong.h | 3 +-- CGAL_Core/include/CGAL/CORE/extLong_impl.h | 12 ++++++------ CGAL_Core/include/CGAL/CORE/poly/Curves.tcc | 3 +-- CGAL_Core/include/CGAL/CORE/poly/Poly.tcc | 2 +- CGAL_Core/include/CGAL/CORE/poly/Sturm.h | 6 ++---- 11 files changed, 40 insertions(+), 71 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h b/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h index f5b4ad353e93..32683de7a2c7 100644 --- a/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h +++ b/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h @@ -194,8 +194,7 @@ void BigFloatRep :: truncM(const BigFloatRep& B, const extLong& r, const extLong err = 2; exp = B.exp + t; } else // t < chunkCeil(clLg(B.err)) - core_error(std::string("BigFloat error: truncM called with stricter") - + "precision than current error.", __FILE__, __LINE__, true); + CGAL_error_msg("BigFloat error: truncM called with stricter precision than current error."); } else {// B.m == 0 long t = chunkFloor(- a.asLong()) - B.exp; @@ -204,8 +203,7 @@ void BigFloatRep :: truncM(const BigFloatRep& B, const extLong& r, const extLong err = 1; exp = B.exp + t; } else // t < chunkCeil(clLg(B.err)) - core_error(std::string("BigFloat error: truncM called with stricter") - + "precision than current error.", __FILE__, __LINE__, true); + CGAL_error_msg("BigFloat error: truncM called with stricter precision than current error."); } } @@ -258,7 +256,7 @@ void BigFloatRep::div(const BigInt& N, const BigInt& D, exp = 0; } } else // D == 0 - core_error( "BigFloat error: zero divisor.", __FILE__, __LINE__, true); + CGAL_error_msg( "BigFloat error: zero divisor."); // Call normalization globally -- IP 10/9/98 normal(); @@ -539,8 +537,7 @@ void BigFloatRep :: div(const BigFloatRep& x, const BigFloatRep& y, bigNormal(bigErr); } } else {// y.m <= y.err - core_error("BigFloat error: possible zero divisor.", - __FILE__, __LINE__, true); + CGAL_error_msg("BigFloat error: possible zero divisor."); } // Call normalization globally -- IP 10/9/98 @@ -735,8 +732,7 @@ void BigFloatRep::sqrt(const BigFloatRep& x, const extLong& a, const BigFloat& A } // end of case with error in mantissa }//else } else - core_error("BigFloat error: squareroot called with negative operand.", - __FILE__, __LINE__, true); + CGAL_error_msg("BigFloat error: squareroot called with negative operand."); } //sqrt with initial approximation // compareMExp(x) @@ -823,8 +819,7 @@ BigFloatRep::toDecimal(unsigned int width, bool Scientific) const { if (err > 0 && err >= abs(m)) { // if err is larger than mantissa, sign and significant values // can not be determined. - core_error("BigFloat error: Error is too big!", - __FILE__, __LINE__, false); + CGAL_warning_msg(true, "BigFloat error: Error is too big!"); decOut.rep = "0.0e0"; // error is too big decOut.isScientific = false; decOut.noSignificant = 0; @@ -1004,8 +999,7 @@ void BigFloatRep :: fromString(const char *str, extLong prec ) { // NOTE: prec defaults to get_static_defBigFloatInputDigits() (see BigFloat.h) // check that prec is not INFTY if (prec.isInfty()) - core_error("BigFloat error: infinite precision not allowed", - __FILE__, __LINE__, true); + CGAL_error_msg("BigFloat error: infinite precision not allowed"); const char *e = strchr(str, 'e'); int dot = 0; diff --git a/CGAL_Core/include/CGAL/CORE/CoreAux_impl.h b/CGAL_Core/include/CGAL/CORE/CoreAux_impl.h index 9b335c393b27..b5bd45f13fe5 100644 --- a/CGAL_Core/include/CGAL/CORE/CoreAux_impl.h +++ b/CGAL_Core/include/CGAL/CORE/CoreAux_impl.h @@ -176,7 +176,7 @@ void core_error(std::string msg, std::string file, int lineno, bool err) { << msg << std::endl; outFile.close(); if (err) { - std::cerr << (std::string("CORE ERROR") + " (file " + file + ", line " + (std::string("CORE ERROR") + " (file " + file + ", line " + std::to_string(lineno) +"):" + msg + "\n").c_str(); std::exit(1); //Note: do not call abort() } diff --git a/CGAL_Core/include/CGAL/CORE/Expr.h b/CGAL_Core/include/CGAL/CORE/Expr.h index 39c1fb84a4c7..7c8f348fa502 100644 --- a/CGAL_Core/include/CGAL/CORE/Expr.h +++ b/CGAL_Core/include/CGAL/CORE/Expr.h @@ -72,9 +72,7 @@ class Expr : public RCExpr { Expr(float f) : RCExpr(nullptr) { // check for valid numbers // (i.e., not infinite and not NaN) if (! CGAL_CORE_finite(f)) { - core_error(" ERROR : constructed an invalid float! ", __FILE__, __LINE__, false); - if (get_static_AbortFlag()) - abort(); + CGAL_error_msg("ERROR : constructed an invalid float! "); get_static_InvalidFlag() = -1; } rep = new ConstDoubleRep(f); @@ -83,9 +81,7 @@ class Expr : public RCExpr { Expr(double d) : RCExpr(nullptr) { // check for valid numbers // (i.e., not infinite and not NaN) if (! CGAL_CORE_finite(d)) { - core_error(" ERROR : constructed an invalid double! ", __FILE__, __LINE__, false); - if (get_static_AbortFlag()) - abort(); + CGAL_error_msg("ERROR : constructed an invalid double! "); get_static_InvalidFlag() = -2; } rep = new ConstDoubleRep(d); @@ -173,9 +169,7 @@ class Expr : public RCExpr { /// /= operator Expr& operator/=(const Expr& e) { if ((e.rep)->getSign() == 0) { - core_error(" ERROR : division by zero ! ",__FILE__, __LINE__, false); - if (get_static_AbortFlag()) - abort(); + CGAL_error_msg("ERROR : division by zero ! "); get_static_InvalidFlag() = -3; } *this = new DivRep(rep, e.rep); @@ -376,9 +370,7 @@ inline Expr operator*(const Expr& e1, const Expr& e2) { /// division inline Expr operator/(const Expr& e1, const Expr& e2) { if (e2.sign() == 0) { - core_error(" ERROR : division by zero ! ", __FILE__, __LINE__, false); - if (get_static_AbortFlag()) - abort(); + CGAL_error_msg("ERROR : division by zero ! "); get_static_InvalidFlag() = -4; } return Expr(new DivRep(e1.Rep(), e2.Rep())); @@ -479,9 +471,7 @@ inline bool isDivisible(const Expr& e1, const Expr& e2) { /// square root inline Expr sqrt(const Expr& e) { if (e.sign() < 0) { - core_error(" ERROR : sqrt of negative value ! ", __FILE__, __LINE__, false); - if (get_static_AbortFlag()) - abort(); + CGAL_error_msg("ERROR : sqrt of negative value ! "); get_static_InvalidFlag() = -5; } return Expr(new SqrtRep(e.Rep())); diff --git a/CGAL_Core/include/CGAL/CORE/ExprRep.h b/CGAL_Core/include/CGAL/CORE/ExprRep.h index 7e4b56557ec4..a8f8c0aea37a 100644 --- a/CGAL_Core/include/CGAL/CORE/ExprRep.h +++ b/CGAL_Core/include/CGAL/CORE/ExprRep.h @@ -564,9 +564,7 @@ class CGAL_CORE_EXPORT ConstPolyRep : public ConstRep { I = ss.isolateRoot(n); // check whether n-th root exists if (I.first == 1 && I.second == 0) { - core_error("CORE ERROR! root index out of bound", - __FILE__, __LINE__, true); - abort(); + CGAL_error_msg("CORE ERROR! root index out of bound"); } // test if the root isolated in I is 0: if ((I.first == 0)&&(I.second == 0)) @@ -583,9 +581,7 @@ class CGAL_CORE_EXPORT ConstPolyRep : public ConstRep { ss.isolateRoots(I.first, I.second, v); I = v.front(); if (v.size() != 1) { - core_error("CORE ERROR! non-isolating interval", - __FILE__, __LINE__, true); - abort(); + CGAL_error_msg("CORE ERROR! non-isolating interval"); } ffVal = computeFilteredValue(); // Chee: this line seems unnecessary } @@ -1092,8 +1088,7 @@ void AddSubRep::computeExactFlags() { uMSB() = newValue.uMSB(); // chen: to get tighers value. sign() = newValue.sign(); } else if (lowBound.isInfty()) {//check if rootbound is too big - core_error("AddSubRep:root bound has exceeded the maximum size\n \ - but we still cannot decide zero.\n", __FILE__, __LINE__, false); + CGAL_warning_msg(false, "AddSubRep:root bound has exceeded the maximum size but we still cannot decide zero."); } else { // Op(first, second) == 0 lMSB() = CORE_negInfty; sign() = 0; @@ -1186,8 +1181,7 @@ void AddSubRep::computeExactFlags() { //8/9/01, Chee: implement escape precision here: if (i> get_static_EscapePrec()) { get_static_EscapePrecFlag() = -i.asLong();//negative means EscapePrec is used - core_error("Escape precision triggered at", - __FILE__, __LINE__, false); + CGAL_warning_msg(false, "Escape precision triggered"); if (get_static_EscapePrecWarning()) std::cout<< "Escape Precision triggered at " << get_static_EscapePrec() << " bits" << std::endl; @@ -1204,8 +1198,7 @@ void AddSubRep::computeExactFlags() { #endif if (sign() == 0 && ua .isInfty()) { - core_error("AddSubRep: root bound has exceeded the maximum size\n \ - but we still cannot decide zero.\n", __FILE__, __LINE__, true); + CGAL_error_msg("AddSubRep: root bound has exceeded the maximum size but we still cannot decide zero."); } // if (sign == 0 && ua .isInfty()) }// else do progressive } @@ -1236,8 +1229,7 @@ void AddSubRep::computeApproxValue(const extLong& relPrec, { std::ostringstream oss; oss << "CORE WARNING: a huge lMSB in AddSubRep: " << lMSB(); - core_error(oss.str(), - __FILE__, __LINE__, false); + CGAL_warning_msg(false, oss.str().c_str()); } extLong rf = first->uMSB()-lMSB()+relPrec+EXTLONG_FOUR; // 2 better diff --git a/CGAL_Core/include/CGAL/CORE/Expr_impl.h b/CGAL_Core/include/CGAL/CORE/Expr_impl.h index 43b854d561b6..aeae1ef1ea0e 100644 --- a/CGAL_Core/include/CGAL/CORE/Expr_impl.h +++ b/CGAL_Core/include/CGAL/CORE/Expr_impl.h @@ -702,7 +702,7 @@ void computeExactFlags_temp(ConstRep* t, const Real &value) { } else { t->uMSB() = value.uMSB(); t->lMSB() = value.lMSB(); - core_error("Leaves in DAG is not exact!", __FILE__, __LINE__, true); + CGAL_error_msg("Leafs in DAG is not exact!"); } t->sign() = value.sign(); @@ -809,8 +809,7 @@ void SqrtRep::computeExactFlags() { sign() = child->sign(); if (sign() < 0) - core_error("squareroot is called with negative operand.", - __FILE__, __LINE__, true); + CGAL_error_msg("square root is called with negative operand."); uMSB() = child->uMSB() / EXTLONG_TWO; lMSB() = child->lMSB() / EXTLONG_TWO; @@ -928,7 +927,7 @@ void DivRep::computeExactFlags() { second->computeExactFlags(); if (!second->sign()) - core_error("zero divisor.", __FILE__, __LINE__, true); + CGAL_error_msg("zero divisor."); if (!first->sign()) {// value must be exactly zero. reduceToZero(); @@ -1025,8 +1024,7 @@ void MultRep::computeApproxValue(const extLong& relPrec, { std::ostringstream oss; oss << "CORE WARNING: a huge lMSB in AddSubRep " << lMSB(); - core_error(oss.str(), - __FILE__, __LINE__, false); + CGAL_warning_msg(false, oss.str().c_str()); } extLong r = relPrec + EXTLONG_FOUR; @@ -1048,8 +1046,7 @@ void DivRep::computeApproxValue(const extLong& relPrec, { std::ostringstream oss; oss << "CORE WARNING: a huge lMSB in AddSubRep " << lMSB(); - core_error(oss.str(), - __FILE__, __LINE__, false); + CGAL_warning_msg(false, oss.str().c_str()); } extLong rr = relPrec + EXTLONG_SEVEN; // These rules come from @@ -1082,7 +1079,7 @@ void Expr::debug(int mode, int level, int depthLimit) const { else if (mode == Expr::TREE_MODE) rep->debugTree(level, 0, depthLimit); else - core_error("unknown debugging mode", __FILE__, __LINE__, false); + CGAL_warning_msg(false, "unknown debugging mode"); std::cout << "---- End Expr debug(): " << std::endl; } diff --git a/CGAL_Core/include/CGAL/CORE/Filter.h b/CGAL_Core/include/CGAL/CORE/Filter.h index 56649b80c864..c59e69fe1eb8 100644 --- a/CGAL_Core/include/CGAL/CORE/Filter.h +++ b/CGAL_Core/include/CGAL/CORE/Filter.h @@ -137,8 +137,8 @@ class filteredFp { } /// division filteredFp operator/ (const filteredFp& x) const { - if (x.fpVal == 0.0) - core_error("possible zero divisor!", __FILE__, __LINE__, false); + CGAL_warning_msg(x.fpVal != 0.0, "possible zero divisor!"); + double xxx = core_abs(x.fpVal) / x.maxAbs - (x.ind+1)*CORE_EPS + DBL_MIN; if (xxx > 0) { double val = fpVal / x.fpVal; @@ -149,8 +149,8 @@ class filteredFp { } /// square root filteredFp sqrt () const { - if (fpVal < 0.0) - core_error("possible negative sqrt!", __FILE__, __LINE__, false); + + CGAL_warning_msg( !(fpVal < 0.0), "possible negative sqrt!"); if (fpVal > 0.0) { double val = std::sqrt(fpVal); return filteredFp(val, ( maxAbs / fpVal ) * val, 1 + ind); diff --git a/CGAL_Core/include/CGAL/CORE/extLong.h b/CGAL_Core/include/CGAL/CORE/extLong.h index 52ba91e321ae..7f01e4e167a8 100644 --- a/CGAL_Core/include/CGAL/CORE/extLong.h +++ b/CGAL_Core/include/CGAL/CORE/extLong.h @@ -149,8 +149,7 @@ const extLong EXTLONG_EIGHT(8); // private comparison function inline int extLong::cmp(const extLong& x) const { if (isNaN() || x.isNaN()) { - core_error("Two extLong NaN's cannot be compared!", - __FILE__, __LINE__, false); + CGAL_warning_msg(false, "Two extLong NaN's cannot be compared!"); } return (val == x.val) ? 0 : ((val > x.val) ? 1 : -1); } diff --git a/CGAL_Core/include/CGAL/CORE/extLong_impl.h b/CGAL_Core/include/CGAL/CORE/extLong_impl.h index 24c2bab879d4..c881bb74b51c 100644 --- a/CGAL_Core/include/CGAL/CORE/extLong_impl.h +++ b/CGAL_Core/include/CGAL/CORE/extLong_impl.h @@ -77,7 +77,7 @@ extLong& extLong::operator+= (const extLong& y) { if (flag == 2 || y.flag == 2 || (flag * y.flag < 0)) { #ifdef CORE_DEBUG if (flag * y.flag < 0) //want a message at the first creation of NaN - core_error("extLong NaN Error in addition.", __FILE__, __LINE__, false); + CGAL_warning_msg(false, "extLong NaN Error in addition."); #endif *this = CORE_NaNLong; @@ -96,7 +96,7 @@ extLong& extLong::operator-= (const extLong& y) { if (flag == 2 || y.flag == 2 || (flag * y.flag > 0)) { #ifdef CORE_DEBUG if (flag * y.flag > 0) //want a message at the first creation of NaN - core_error("extLong NaN Error in subtraction.", __FILE__, __LINE__, false); + CGAL_warning_msg(false, "extLong NaN Error in subtraction."); #endif *this = CORE_NaNLong; @@ -131,7 +131,7 @@ extLong& extLong::operator*= (const extLong& y) { *this = CORE_negInfty; } else { #ifdef CORE_DEBUG - core_error("extLong NaN Error in multiplication.",__FILE__,__LINE__,false); + CGAL_warning_msg(false, "extLong NaN Error in multiplication."); #endif *this = CORE_NaNLong; } @@ -144,9 +144,9 @@ extLong& extLong::operator/= (const extLong& y) { if (flag==2 || y.flag==2 || ((flag != 0) && (y.flag != 0)) || (y.val == 0)) { #ifdef CORE_DEBUG if (y.val == 0) - core_error("extLong NaN Error, Divide by Zero.", __FILE__, __LINE__, false); + CGAL_warning_msg(false, "extLong NaN Error, Divide by Zero."); else if ((flag !=0) && (y.flag !=0)) - core_error("extLong NaN Error, +/-Inf/Inf.", __FILE__, __LINE__, false); + CGAL_warning_msg(false, "extLong NaN Error, +/-Inf/Inf."); #endif *this = CORE_NaNLong; @@ -181,7 +181,7 @@ extLong extLong::operator- () const { CGAL_INLINE_FUNCTION int extLong::sign() const { if (flag == 2) - core_error("NaN Sign can not be determined!", __FILE__, __LINE__, false); + CGAL_warning_msg(false, "NaN Sign can not be determined!"); return ((val == 0) ? 0 : ((val > 0) ? 1 : -1)); } diff --git a/CGAL_Core/include/CGAL/CORE/poly/Curves.tcc b/CGAL_Core/include/CGAL/CORE/poly/Curves.tcc index 4a9c8fb905c0..0fffb4ae470a 100644 --- a/CGAL_Core/include/CGAL/CORE/poly/Curves.tcc +++ b/CGAL_Core/include/CGAL/CORE/poly/Curves.tcc @@ -1336,7 +1336,7 @@ cout <<"Number of roots at " << xCurr << " are " << numRoots<::pseudoRemainder :\n -- divide by zero polynomial", __FILE__, __LINE__, false); + CGAL_warning_msg(false, "ERROR in Polynomial::pseudoRemainder :\n -- divide by zero polynomial"); return Polynomial(0); // Unit Polynomial (arbitrary!) } if (bTrueDegree > degree) { diff --git a/CGAL_Core/include/CGAL/CORE/poly/Sturm.h b/CGAL_Core/include/CGAL/CORE/poly/Sturm.h index d044b124c1f2..76f99848ce99 100644 --- a/CGAL_Core/include/CGAL/CORE/poly/Sturm.h +++ b/CGAL_Core/include/CGAL/CORE/poly/Sturm.h @@ -607,8 +607,7 @@ class Sturm { if (ff == 0) { NEWTON_DIV_BY_ZERO = true; del = 0; - core_error("Zero divisor in Newton Iteration", - __FILE__, __LINE__, false); + CGAL_warning_msg(false, "Zero divisor in Newton Iteration"); return 0; } @@ -680,8 +679,7 @@ class Sturm { stepsize++; // heuristic } while ((del != 0) && ((del.uMSB() >= -prec) && (count >0))) ; - if (count == 0) core_error("newtonIterE: reached count=0", - __FILE__, __LINE__, true); + CGAL_assertion(count != 0, "newtonIterE: reached count=0"); del = BigFloat(core_abs(del.m()), err, del.exp() ); del.makeCeilExact(); return val; From 89c9f902ff974fccefca87bcd52bab8d73bcc4c8 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 9 Mar 2023 14:14:37 +0000 Subject: [PATCH 063/139] Use CGAL_assertion_msg --- CGAL_Core/include/CGAL/CORE/poly/Sturm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CGAL_Core/include/CGAL/CORE/poly/Sturm.h b/CGAL_Core/include/CGAL/CORE/poly/Sturm.h index 76f99848ce99..99e78d6a9300 100644 --- a/CGAL_Core/include/CGAL/CORE/poly/Sturm.h +++ b/CGAL_Core/include/CGAL/CORE/poly/Sturm.h @@ -679,7 +679,7 @@ class Sturm { stepsize++; // heuristic } while ((del != 0) && ((del.uMSB() >= -prec) && (count >0))) ; - CGAL_assertion(count != 0, "newtonIterE: reached count=0"); + CGAL_assertion_msg(count != 0, "newtonIterE: reached count=0"); del = BigFloat(core_abs(del.m()), err, del.exp() ); del.makeCeilExact(); return val; From 345e63921d8efcb6cc3a7c30ae13e9864a465748 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 10 Mar 2023 09:09:46 +0000 Subject: [PATCH 064/139] Remove function core_error() --- CGAL_Core/include/CGAL/CORE/CoreAux.h | 6 ------ CGAL_Core/include/CGAL/CORE/CoreAux_impl.h | 25 ---------------------- 2 files changed, 31 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/CoreAux.h b/CGAL_Core/include/CGAL/CORE/CoreAux.h index 8577514dac03..b90d25656bfa 100644 --- a/CGAL_Core/include/CGAL/CORE/CoreAux.h +++ b/CGAL_Core/include/CGAL/CORE/CoreAux.h @@ -156,12 +156,6 @@ CGAL_CORE_EXPORT double IntMantissa(double d); // (See CORE_PATH/progs/ieee/frexp.cpp for details) CGAL_CORE_EXPORT int IntExponent(double d); -/// Writes out an error or warning message in the local file CORE_DIAGFILE -/** If last argument (err) is TRUE, then this is considered an error - * (not just warning). In this case, the message is also printed in - * std::cerr, using std::perror(). - * */ -CGAL_CORE_EXPORT void core_error(std::string msg, std::string file, int lineno, bool err); /// This is for debugging messages inline void core_debug(std::string msg){ diff --git a/CGAL_Core/include/CGAL/CORE/CoreAux_impl.h b/CGAL_Core/include/CGAL/CORE/CoreAux_impl.h index b5bd45f13fe5..e1fa64e5330c 100644 --- a/CGAL_Core/include/CGAL/CORE/CoreAux_impl.h +++ b/CGAL_Core/include/CGAL/CORE/CoreAux_impl.h @@ -157,30 +157,5 @@ int IntExponent(double d) { return e-53; } -/// core_error is the method to write Core Library warning or error messages -/** Both warnings and errors are written to a file called CORE_DIAGFILE. - * But errors are also written on std::cerr (similar to std::perror()). - * */ -// Usage: core_error(message, file_with_error, line_number, err_type) -// where err_type=0 means WARNING, error_type=0 means ERROR -CGAL_INLINE_FUNCTION -void core_error(std::string msg, std::string file, int lineno, bool err) { - std::ofstream outFile(CORE_DIAGFILE, std::ios::app); // open to append - if (!outFile) { - // perror("CORE ERROR: cannot open Core Diagnostics file"); - std::cerr << "CORE ERROR: can't open Core Diagnostics file"< Date: Fri, 10 Mar 2023 10:04:33 +0000 Subject: [PATCH 065/139] Fix in Envelope_3 --- Envelope_3/include/CGAL/Env_sphere_traits_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Envelope_3/include/CGAL/Env_sphere_traits_3.h b/Envelope_3/include/CGAL/Env_sphere_traits_3.h index dd6193cab4db..5d265928cad5 100644 --- a/Envelope_3/include/CGAL/Env_sphere_traits_3.h +++ b/Envelope_3/include/CGAL/Env_sphere_traits_3.h @@ -1080,7 +1080,7 @@ class Env_sphere_traits_3 : public ConicTraits_2 Algebraic x_diff = x1 - a, y_diff = y1 - b; // the coefficients are: Algebraic A = 1, - B = -2*c, + B = Rational(-2*c), C = x_diff*x_diff + y_diff*y_diff + Rational(c*c) - sqr_r; Algebraic zs[2]; From 2de196ac3e246a21ee1ebf8a956b2f2b8de47dbf Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 10 Mar 2023 10:05:22 +0000 Subject: [PATCH 066/139] Add an expression to the CORE_Expr test that should be similiar to what we observe in Envelope_3 --- Number_types/test/Number_types/CORE_Expr.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Number_types/test/Number_types/CORE_Expr.cpp b/Number_types/test/Number_types/CORE_Expr.cpp index 74bb4b14350e..c9249217afd0 100644 --- a/Number_types/test/Number_types/CORE_Expr.cpp +++ b/Number_types/test/Number_types/CORE_Expr.cpp @@ -137,6 +137,10 @@ int main() { CGAL::test_real_embeddable(); + CORE::BigRat br(1,3); + + CORE::Expr exp = 2 * br; + return 0; } From 1c00c6490eb847a694e159abedfec6919f3bb4cc Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 10 Mar 2023 14:41:30 +0000 Subject: [PATCH 067/139] Fix arrangement demo --- .../demo/Arrangement_on_surface_2/Utils/Utils.cpp | 2 +- .../Curved_kernel_via_analysis_2/gfx/Curve_renderer_2.h | 2 +- .../gfx/Curve_renderer_internals.h | 4 ++-- .../gfx/Curve_renderer_traits.h | 8 +++----- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/Utils/Utils.cpp b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/Utils/Utils.cpp index 5fcdeb8fc3cb..38291f53170d 100644 --- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/Utils/Utils.cpp +++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/Utils/Utils.cpp @@ -210,7 +210,7 @@ operator()(const Point_2& p, const X_monotone_curve_2& curve) const auto points = painterOstream.getPointsList(curve); QPoint p_viewport = - view->mapFromScene(QPointF{p.x().doubleValue(), p.y().doubleValue()}); + view->mapFromScene(QPointF{CGAL::to_double(p.x()), CGAL::to_double(p.y())}); double minDist = (std::numeric_limits::max)(); for (auto& vec : points) diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_2.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_2.h index f9551ac46fab..c48274ec612b 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_2.h @@ -862,7 +862,7 @@ void draw(const Arc_2& arc, get_pixel_coords(l, y_clip, pix_beg); get_pixel_coords(ptmp->left, it->second ? engine.y_max_r : engine.y_min_r, pix_end); - if(CGAL_ABS(ptmp->left - l) <= engine.pixel_w_r*2) { + if(CGAL_ABS(Rational(ptmp->left - l)) <= engine.pixel_w_r*2) { Coordinate_2 xy(Coordinate_1(pt), *support, arc.arcno()); Rational _; diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_internals.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_internals.h index c0c62a2ad887..3fc8bef4d6eb 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_internals.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_internals.h @@ -694,7 +694,7 @@ bool get_range_QF_1(int var, const NT& l_, const NT& r_, const NT& key, while(der_it != der_begin) { --der_it; - e1 = xsum_abs * e1 + CGAL_ABS(x1 * z1); + e1 = xsum_abs * e1 + CGAL_ABS(NT(x1 * z1)); z1 = x0*z1 + x1*y1; y1 = y1*x0 + x1*y0; y0 = x0*y0 + extract(*cache_it)*(*der_it); @@ -725,7 +725,7 @@ bool get_range_QF_1(int var, const NT& l_, const NT& r_, const NT& key, NT y0 = extract(*cache_it), y1(0), z1(0), e1(0); while(cache_it != begin) { --cache_it; - e1 = xsum_abs * e1 + CGAL_ABS(x1*z1); + e1 = xsum_abs * e1 + CGAL_ABS(NT(x1*z1)); z1 = x0*z1 + x1*y1; y1 = y1*x0 + x1*y0; y0 = x0*y0 + extract(*cache_it); diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_traits.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_traits.h index 32e108b71c0b..e4fe14f5b146 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_traits.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_traits.h @@ -344,7 +344,7 @@ struct Curve_renderer_traits typedef Integer result_type; Integer operator()(const Rational& x) const { - return x.BigIntValue(); + return numerator(x)/denominator(x); } }; @@ -397,7 +397,7 @@ struct Curve_renderer_traits : typedef Integer result_type; Integer operator()(const Rational& x) const { - return x.BigIntValue(); + return numerator(x)/denominator(x); } }; @@ -406,9 +406,7 @@ struct Curve_renderer_traits : typedef std::size_t result_type; inline result_type operator()(const Float& key) const { - const CORE::BigRatRep& rep = key.getRep(); - std::size_t ret = reinterpret_cast(&rep); - return ret; + return std::hash()(key); } }; }; From b9a1e1866ed1c1504612306a58ad7b555ba25c18 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 14 Mar 2023 08:09:06 +0100 Subject: [PATCH 068/139] Remove expression where I wanted to see for which platforms it does not wor --- Number_types/test/Number_types/CORE_Expr.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Number_types/test/Number_types/CORE_Expr.cpp b/Number_types/test/Number_types/CORE_Expr.cpp index c9249217afd0..74bb4b14350e 100644 --- a/Number_types/test/Number_types/CORE_Expr.cpp +++ b/Number_types/test/Number_types/CORE_Expr.cpp @@ -137,10 +137,6 @@ int main() { CGAL::test_real_embeddable(); - CORE::BigRat br(1,3); - - CORE::Expr exp = 2 * br; - return 0; } From 01e2aef1d6ecaa2987a3cd95e44e13070ccec6d3 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 14 Mar 2023 17:54:50 +0100 Subject: [PATCH 069/139] Fix in Real.h --- CGAL_Core/include/CGAL/CORE/Real.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/Real.h b/CGAL_Core/include/CGAL/CORE/Real.h index 0ec028535a0d..968691d7d22c 100644 --- a/CGAL_Core/include/CGAL/CORE/Real.h +++ b/CGAL_Core/include/CGAL/CORE/Real.h @@ -478,11 +478,11 @@ inline Real sqrt(const Real& x) { // unary minus operator template inline Real Realbase_for::operator-() const { - return -T(ker); + return T(- T(ker)); } template <> inline Real RealLong::operator-() const { - return ker < -LONG_MAX ? -BigInt(ker) : -ker; + return ker < -LONG_MAX ? BigInt(- BigInt(ker)) : -ker; } inline void init_CORE() { From 7fe1f09212719ef348235bcf2451037f8e160ac1 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 14 Mar 2023 18:00:34 +0100 Subject: [PATCH 070/139] Fix in Poly.tcc --- CGAL_Core/include/CGAL/CORE/poly/Poly.tcc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc b/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc index 618e87d3241d..8dc8a8601b3b 100644 --- a/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc +++ b/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc @@ -977,7 +977,7 @@ BigFloat Polynomial::CauchyLowerBound() const { for (int i = 1; i <= deg; ++i) { mx = core_max(mx, NT(abs(coeff[i]))); } - Expr e = Expr(NT(abs(coeff[0])))/ Expr(NT(abs(coeff[0])) + mx); + Expr e = Expr(NT(abs(coeff[0])))/ Expr(NT(NT(abs(coeff[0])) + mx)); e.approx(2, CORE_INFTY); // get an relative approximate value with error < 1/4 return (e.BigFloatValue().makeExact().div2()); From e68cf6748005abc65ffb78fb1b158a8d477ef32a Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 14 Mar 2023 18:23:32 +0100 Subject: [PATCH 071/139] Fix in Env_sphere_traits_3 --- Envelope_3/include/CGAL/Env_sphere_traits_3.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Envelope_3/include/CGAL/Env_sphere_traits_3.h b/Envelope_3/include/CGAL/Env_sphere_traits_3.h index 5d265928cad5..22efc60c0817 100644 --- a/Envelope_3/include/CGAL/Env_sphere_traits_3.h +++ b/Envelope_3/include/CGAL/Env_sphere_traits_3.h @@ -456,8 +456,8 @@ class Env_sphere_traits_3 : public ConicTraits_2 envelope_coef = -1; Sign sign_c_diff = CGAL_NTS sign(c_diff); - Rational la = envelope_coef*2*a_diff*sign_c_diff; - Rational lb = envelope_coef*2*b_diff*sign_c_diff; + Rational la = a_diff * (envelope_coef*2*sign_c_diff); + Rational lb = b_diff * (envelope_coef*2*sign_c_diff); Rational lc = envelope_coef*sign_c_diff*(2*c_diff*z_plane - m); if (ellipse_is_point) From d02adec67df8b6c24e8f5c40189d19df12991fc0 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 17 Mar 2023 08:57:25 +0100 Subject: [PATCH 072/139] Fix Counted_number --- Number_types/include/CGAL/Counted_number.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Number_types/include/CGAL/Counted_number.h b/Number_types/include/CGAL/Counted_number.h index 87de07ebc343..60b854fdc8f0 100644 --- a/Number_types/include/CGAL/Counted_number.h +++ b/Number_types/include/CGAL/Counted_number.h @@ -356,7 +356,7 @@ Counted_number operator+(Counted_number const &n1, Counted_number const &n2) { Counted_number::inc_add_count(); - return Counted_number(n1.rep() + n2.rep()); + return Counted_number(NT(n1.rep() + n2.rep())); } template @@ -364,7 +364,7 @@ Counted_number operator-(Counted_number const &n1, Counted_number const &n2) { Counted_number::inc_sub_count(); - return Counted_number(n1.rep() - n2.rep()); + return Counted_number(NT(n1.rep() - n2.rep())); } template @@ -372,7 +372,7 @@ Counted_number operator*(Counted_number const &n1, Counted_number const &n2) { Counted_number::inc_mul_count(); - return Counted_number(n1.rep() * n2.rep()); + return Counted_number(NT(n1.rep() * n2.rep())); } template @@ -380,7 +380,7 @@ Counted_number operator/(Counted_number const &n1, Counted_number const &n2) { Counted_number::inc_div_count(); - return Counted_number(n1.rep() / n2.rep()); + return Counted_number(NT(n1.rep() / n2.rep())); } template< class NT > From bb944fbf47e5c3f950a9737129d115f03cafb23b Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 17 Mar 2023 11:53:40 +0100 Subject: [PATCH 073/139] Fix in Real.h --- CGAL_Core/include/CGAL/CORE/Real.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CGAL_Core/include/CGAL/CORE/Real.h b/CGAL_Core/include/CGAL/CORE/Real.h index 968691d7d22c..35ae40c04553 100644 --- a/CGAL_Core/include/CGAL/CORE/Real.h +++ b/CGAL_Core/include/CGAL/CORE/Real.h @@ -357,7 +357,7 @@ struct real_div { bf_a.approx(a.BigRatValue(), bf_b.MSB() - bf_b.flrLgErr() + 1, CORE_posInfty); return bf_a.div(bf_b, r); } else // both are BigRat - return a.BigRatValue()/b.BigRatValue(); + return BigRat(a.BigRatValue(), b.BigRatValue()); } else if (a.ID() == REAL_BIGFLOAT || b.ID() == REAL_BIGFLOAT || a.ID() == REAL_DOUBLE || b.ID() == REAL_DOUBLE) { return a.BigFloatValue().div(b.BigFloatValue(), r); From b66fd6943c9bdbe5540f87b435b4ce12fdf99a06 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 17 Mar 2023 14:14:54 +0100 Subject: [PATCH 074/139] Arrangement_2 --- .../CGAL/Algebraic_kernel_d/Bitstream_descartes_E08_tree.h | 2 +- .../include/CGAL/Algebraic_kernel_d/bound_between_1.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Bitstream_descartes_E08_tree.h b/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Bitstream_descartes_E08_tree.h index 2f7719bb3626..4e28b86ed6d5 100644 --- a/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Bitstream_descartes_E08_tree.h +++ b/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Bitstream_descartes_E08_tree.h @@ -303,7 +303,7 @@ class Convex_combinator_approx_Integer_log { Integer alpha_num = Integer(1), int log_denom = 1 ) : alpha_num_(alpha_num), beta_num_((Integer(1) << log_denom) - alpha_num), - half_((log_denom > 0) ? (Integer(1) << log_denom-1) : 0), + half_((log_denom > 0) ? Integer(Integer(1) << log_denom-1) : 0), log_denom_(log_denom) { CGAL_precondition(log_denom_ >= 0); diff --git a/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/bound_between_1.h b/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/bound_between_1.h index ade0be4a1a59..aaf9185350f6 100644 --- a/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/bound_between_1.h +++ b/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/bound_between_1.h @@ -220,7 +220,7 @@ simple_bound_between(const Algebraic_real& a, final_mantissa = final_mantissa << 1; final_mantissa++; y_log--; - x_m = x_m==0 ? 0 : x_m & ((Integer(1) << x_log) - 1); //x_m - CGAL::ipower(Integer(2),x_log); + x_m = x_m==0 ? 0 : Integer(x_m & ((Integer(1) << x_log) - 1)); //x_m - CGAL::ipower(Integer(2),x_log); x_log = x_m==0 ? -1 : CGAL::internal::floor_log2_abs(x_m); } final_mantissa = final_mantissa << 1; From 7a3c58c7cce4d4f1fb29625d4e1decdb16cf9ada Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 17 Mar 2023 15:08:58 +0100 Subject: [PATCH 075/139] Real.h --- CGAL_Core/include/CGAL/CORE/Real.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CGAL_Core/include/CGAL/CORE/Real.h b/CGAL_Core/include/CGAL/CORE/Real.h index 35ae40c04553..6ca51cbf4490 100644 --- a/CGAL_Core/include/CGAL/CORE/Real.h +++ b/CGAL_Core/include/CGAL/CORE/Real.h @@ -357,7 +357,7 @@ struct real_div { bf_a.approx(a.BigRatValue(), bf_b.MSB() - bf_b.flrLgErr() + 1, CORE_posInfty); return bf_a.div(bf_b, r); } else // both are BigRat - return BigRat(a.BigRatValue(), b.BigRatValue()); + return BigRat(a.BigRatValue() / b.BigRatValue()); } else if (a.ID() == REAL_BIGFLOAT || b.ID() == REAL_BIGFLOAT || a.ID() == REAL_DOUBLE || b.ID() == REAL_DOUBLE) { return a.BigFloatValue().div(b.BigFloatValue(), r); From ef54ecb82c2c860c7b10391f75fca4d12036f465 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 22 Mar 2023 15:28:15 +0100 Subject: [PATCH 076/139] Fix Minkowski_sum_2 --- .../Arr_geometry_traits/Circle_segment_2.h | 4 +- Number_types/test/Number_types/test_eigen.cpp | 169 ++++++++++-------- 2 files changed, 94 insertions(+), 79 deletions(-) diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Circle_segment_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Circle_segment_2.h index c6f11cc8a342..0dcc6741a265 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Circle_segment_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Circle_segment_2.h @@ -1433,8 +1433,8 @@ class _X_monotone_circle_segment_2 { { // Actually compare the slopes. const bool swap_res = (sign_denom1 != sign_denom2); - const CoordNT A = (cv.y0() - y0())*p.x() + (y0()*cv.x0() - cv.y0()*x0()); - const CoordNT B = (cv.x0() - x0())*p.y(); + const CoordNT A = NT(cv.y0() - y0())*p.x() + (y0()*cv.x0() - cv.y0()*x0()); + const CoordNT B = NT(cv.x0() - x0())*p.y(); slope_res = CGAL::compare (A, B); diff --git a/Number_types/test/Number_types/test_eigen.cpp b/Number_types/test/Number_types/test_eigen.cpp index 8e0dd9bf1947..fcc97710962c 100644 --- a/Number_types/test/Number_types/test_eigen.cpp +++ b/Number_types/test/Number_types/test_eigen.cpp @@ -1,84 +1,99 @@ -#include -#include -#include -#ifdef CGAL_USE_GMP -#include -#include -#include -#include -#endif -#ifdef CGAL_USE_MPFI -#include -#endif -#ifdef CGAL_USE_CORE -#include -#include -#include -#include -#endif -#include -#include -#include -#include - -#ifdef CGAL_EIGEN3_ENABLED +#include +#include #include -// Just check that it all compiles. -template -void check_(){ - Eigen::Matrix m(3,3); - m << 1, 2, 3, 4, 5, 6, 7, 8, 10; - NT d=(m+m).determinant(); - Eigen::Matrix v(3); - v << 1, 2, 3; - NT t=v.dot(v); - v+=d*m*(t*v); - std::ptrdiff_t si=v.size(); - CGAL_USE(si); -} -template -void check(){ - check_(); - check_(); +// Quotient +template +class Toto + : boost::additive2 < Toto, NT_ > +{ +public: + NT_ num, den; + + Toto() {} + Toto(const NT_& a) {} + + Toto(const NT_& a, const NT_& b) {} + + template + Toto operator+=(const T&) { return *this; } +}; + +// Sqrt_extension: +template +class Toto2 + : boost::additive2 < Toto2, NT_ > +{ +public: + NT_ num, den; + Toto2() {} + Toto2(const NT_& nt) + {} + + template + Toto2 operator+=(const T&) { return *this; } +}; + + + + +void toto(Toto& x) +{ + x.den; } -int main(){ - { - typedef CGAL::Interval_nt I1; - I1::Protector p1; - check(); - } - { - typedef CGAL::Interval_nt I2; - I2::Protector p2; - check(); - } - //check(); - //check >(); - //check > >(); - check >(); -#ifdef CGAL_USE_GMP -// check(); - check(); - check(); - check >(); - check >(); -#endif -#ifdef CGAL_USE_MPFI - check(); -#endif -#ifdef CGAL_USE_CORE -// check(); - check(); - check(); - check(); -#endif +// No idea if needed +namespace Eigen { + template struct NumTraits; + template struct NumTraits > + { + typedef Toto Real; + typedef Toto NonInteger; + typedef Toto Nested; + typedef Toto Literal; + + static inline Real epsilon() { return NumTraits::epsilon(); } + static inline Real dummy_precision() { return NumTraits::dummy_precision(); } + + enum { + IsInteger = 0, + IsSigned = 1, + IsComplex = 0, + RequireInitialization = NumTraits::RequireInitialization, + ReadCost = 2 * NumTraits::ReadCost, + AddCost = 150, + MulCost = 100 + }; + }; + + template struct NumTraits > + { + typedef Toto2 Real; + typedef Toto2 NonInteger; + typedef Toto2 Nested; + typedef Toto2 Literal; + + static inline Real epsilon() { return NumTraits::epsilon(); } + static inline Real dummy_precision() { return NumTraits::dummy_precision(); } + + enum { + IsInteger = 0, + IsSigned = 1, + IsComplex = 0, + RequireInitialization = NumTraits::RequireInitialization, + ReadCost = 2 * NumTraits::ReadCost, + AddCost = 150, + MulCost = 100 + }; + }; } -#else -#include -int main(){ - std::cerr << "Eigen is not configured!\n"; + +int main() { + typedef Toto2 NT; + Eigen::Matrix m(3, 3); + + m + m; + + return 0; } -#endif From 4a79ff4871d54f08803e7f680c54e78afd61ab17 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 23 Mar 2023 14:41:00 +0100 Subject: [PATCH 077/139] Restore the original test file --- Number_types/test/Number_types/test_eigen.cpp | 167 ++++++++---------- 1 file changed, 77 insertions(+), 90 deletions(-) diff --git a/Number_types/test/Number_types/test_eigen.cpp b/Number_types/test/Number_types/test_eigen.cpp index fcc97710962c..02151b80ec08 100644 --- a/Number_types/test/Number_types/test_eigen.cpp +++ b/Number_types/test/Number_types/test_eigen.cpp @@ -1,99 +1,86 @@ -#include -#include +#include +#include +#include +#ifdef CGAL_USE_GMP +#include +#include +#include +#include +#endif +#ifdef CGAL_USE_MPFI +#include +#endif +#ifdef CGAL_USE_CORE +#include +#include +#include +#include +#endif +#include +#include +#include +#include + +#ifdef CGAL_EIGEN3_ENABLED #include -// Quotient -template -class Toto - : boost::additive2 < Toto, NT_ > -{ -public: - NT_ num, den; - Toto() {} - Toto(const NT_& a) {} - Toto(const NT_& a, const NT_& b) {} - - template - Toto operator+=(const T&) { return *this; } -}; - -// Sqrt_extension: -template -class Toto2 - : boost::additive2 < Toto2, NT_ > -{ -public: - NT_ num, den; - Toto2() {} - Toto2(const NT_& nt) - {} - - template - Toto2 operator+=(const T&) { return *this; } -}; - - - - -void toto(Toto& x) -{ - x.den; +// Just check that it all compiles. +template +void check_(){ + Eigen::Matrix m(3,3); + m << 1, 2, 3, 4, 5, 6, 7, 8, 10; + NT d=(m+m).determinant(); + Eigen::Matrix v(3); + v << 1, 2, 3; + NT t=v.dot(v); + v+=d*Eigen::Matrix(m*(t*v)); + std::ptrdiff_t si=v.size(); + CGAL_USE(si); } - -// No idea if needed -namespace Eigen { - template struct NumTraits; - template struct NumTraits > - { - typedef Toto Real; - typedef Toto NonInteger; - typedef Toto Nested; - typedef Toto Literal; - - static inline Real epsilon() { return NumTraits::epsilon(); } - static inline Real dummy_precision() { return NumTraits::dummy_precision(); } - - enum { - IsInteger = 0, - IsSigned = 1, - IsComplex = 0, - RequireInitialization = NumTraits::RequireInitialization, - ReadCost = 2 * NumTraits::ReadCost, - AddCost = 150, - MulCost = 100 - }; - }; - - template struct NumTraits > - { - typedef Toto2 Real; - typedef Toto2 NonInteger; - typedef Toto2 Nested; - typedef Toto2 Literal; - - static inline Real epsilon() { return NumTraits::epsilon(); } - static inline Real dummy_precision() { return NumTraits::dummy_precision(); } - - enum { - IsInteger = 0, - IsSigned = 1, - IsComplex = 0, - RequireInitialization = NumTraits::RequireInitialization, - ReadCost = 2 * NumTraits::ReadCost, - AddCost = 150, - MulCost = 100 - }; - }; +template +void check(){ + check_(); + check_(); } +int main(){ + { + typedef CGAL::Interval_nt I1; + I1::Protector p1; + check(); + } + { + typedef CGAL::Interval_nt I2; + I2::Protector p2; + check(); + } + //check(); + //check >(); + //check > >(); + check >(); +#ifdef CGAL_USE_GMP +// check(); + check(); + check(); + check >(); + check >(); +#endif +#ifdef CGAL_USE_MPFI + check(); +#endif +#ifdef CGAL_USE_CORE +// check(); + check(); + check(); + check(); +#endif +} -int main() { - typedef Toto2 NT; - Eigen::Matrix m(3, 3); - - m + m; - - return 0; +#else +#include +int main(){ + std::cerr << "Eigen is not configured!\n"; } +#endif From 83b3c73d72ee542c18de2fd7c132051bef79f338 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 23 Mar 2023 14:41:46 +0100 Subject: [PATCH 078/139] Add partial specializations of boost::multiprecision::is_byte_container --- Installation/include/CGAL/config.h | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Installation/include/CGAL/config.h b/Installation/include/CGAL/config.h index 22fe30a18230..2149ea244cd0 100644 --- a/Installation/include/CGAL/config.h +++ b/Installation/include/CGAL/config.h @@ -597,4 +597,40 @@ inline std::string data_file_path(const std::string& filename) } // end namespace CGAL + +// Workaround for an accidental enable if of Eigen::Matrix in the +// boost::multiprecision::cpp_int constructor for some versions of +// boost + +namespace Eigen{ + template + class Matrix; + template + class Ref; + +} + +namespace boost { + namespace multiprecision { + namespace detail { + template + struct is_byte_container; + + + template + struct is_byte_container< Eigen::Matrix> + { + static const bool value = false; + }; + + template + struct is_byte_container< Eigen::Ref> + { + static const bool value = false; + }; + + } + } +} + #endif // CGAL_CONFIG_H From 5c6eda39fd95da1409c1d0524f6585244b1cb116 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 5 Apr 2023 11:34:27 +0100 Subject: [PATCH 079/139] WIP: Add a boost::mp based equivalent to Mpzf --- .../internal/Exact_type_selector.h | 3 +- Number_types/include/CGAL/cpp_float.h | 399 ++++++++++++++++++ 2 files changed, 401 insertions(+), 1 deletion(-) create mode 100644 Number_types/include/CGAL/cpp_float.h diff --git a/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h b/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h index b8263c891f6b..41bf8a6b1af7 100644 --- a/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h +++ b/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h @@ -25,6 +25,7 @@ #include #include +# include #ifdef CGAL_USE_GMP # include # include @@ -94,7 +95,7 @@ struct Exact_ring_selector : Exact_field_selector < T > { }; template <> struct Exact_ring_selector #ifdef CGAL_HAS_MPZF -{ typedef Mpzf Type; }; +{ typedef cpp_float Type; }; #elif defined(CGAL_HAS_THREADS) || !defined(CGAL_USE_GMP) { typedef MP_Float Type; }; #else diff --git a/Number_types/include/CGAL/cpp_float.h b/Number_types/include/CGAL/cpp_float.h new file mode 100644 index 000000000000..b3885c0e9229 --- /dev/null +++ b/Number_types/include/CGAL/cpp_float.h @@ -0,0 +1,399 @@ +// Copyright (c) 2023 GeometryFactory (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org) +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Andreas Fabri + +#ifndef CGAL_CPP_FLOAT_H +#define CGAL_CPP_FLOAT_H + + +#include +#include +#include +#include + +namespace CGAL { + + +namespace internal { + // Only used with an argument known not to be 0. + inline int low_bit (boost::uint64_t x) { +#if defined(_MSC_VER) + unsigned long ret; + _BitScanForward64(&ret, x); + return (int)ret; +#elif defined(__xlC__) + return __cnttz8 (x); +#else + // Assume long long is 64 bits + return __builtin_ctzll (x); +#endif + } + inline int high_bit (boost::uint64_t x) { +#if defined(_MSC_VER) + unsigned long ret; + _BitScanReverse64(&ret, x); + return (int)ret; // AF: was 63 - (int)ret; The others have to be changed too +#elif defined(__xlC__) + // Macro supposedly not defined on z/OS. + return __cntlz8 (x); +#else + return __builtin_clzll (x); +#endif + } + +} // namespace internal + +#if 0 // needs C++20 + template + void fmt(const T& t) + { + std::cout << std::format("{:b}", t) << std::endl; + } +#endif + +class cpp_float { + + boost::multiprecision::cpp_int man; + int exp; /* The number man (an integer) * 2 ^ exp */ + +public: + cpp_float() + : man(), exp() + {} + + cpp_float(int i) + : man(i),exp(0) + {} + + cpp_float(const boost::multiprecision::cpp_int& man, int exp) + : man(man),exp(exp) + {} + + + cpp_float(double d) + { + std::cout << "\ndouble = " << d << std::endl; + using boost::uint64_t; + union { +#ifdef CGAL_LITTLE_ENDIAN + struct { uint64_t man:52; uint64_t exp:11; uint64_t sig:1; } s; +#else /* CGAL_BIG_ENDIAN */ + //WARNING: untested! + struct { uint64_t sig:1; uint64_t exp:11; uint64_t man:52; } s; +#endif + double d; + } u; + u.d = d; + + uint64_t m; + uint64_t dexp = u.s.exp; + CGAL_assertion_msg(dexp != 2047, "Creating an cpp_float from infinity or NaN."); + if (dexp == 0) { + if (d == 0) { exp=0; return; } + else { // denormal number + m = u.s.man; + ++dexp; + } + } else { + m = (1LL << 52) | u.s.man; + } + + + int idexp = (int)dexp; + idexp -= 1023; + + std::cout << "m = " << m << std::endl; + std::cout << "idexp = " << idexp << std::endl; + + int shifted = internal::low_bit(m); + + m >>= shifted; + + int nbits = internal::high_bit(m); + std::cout << "nbits = " << nbits << std::endl; + + exp = idexp - nbits; + if(u.s.sig){ + m = -m; + } + std::cout << "m = " << m << " * 2^" << exp << std::endl; + // fmt(m); + man = boost::multiprecision::cpp_int(m); + } + + friend std::ostream& operator<<(std::ostream& os, const cpp_float& m) + { + return os << m.man << " * 2 ^ " << m.exp << " ( " << to_double(m) << ") "; + } + + friend cpp_float operator-(cpp_float const&x) + { + return cpp_float(-x.man,x.exp); + } + + cpp_float& operator*=(const cpp_float& other) + { + man *= other.man; + exp += other.exp; + return *this; + } + + cpp_float operator+=(const cpp_float& other) + { + int shift = exp - other.exp; + if(shift > 0){ + man <<= shift; + man += other.man; + exp = other.exp; + }else if(shift < 0){ + boost::multiprecision::cpp_int cpy(other.man); + cpy << shift; + man += cpy; + }else{ + man += other.man; + } + return *this; + } + + cpp_float operator-=(const cpp_float& other) + { + int shift = exp - other.exp; + if(shift > 0){ + man <<= shift; + man -= other.man; + exp = other.exp; + }else if(shift < 0){ + boost::multiprecision::cpp_int cpy(other.man); + cpy << shift; + man -= cpy; + }else{ + man -= other.man; + } + return *this; + } + + bool positive() const + { + return is_positive(man); + } + + + friend bool operator<(const cpp_float& a, const cpp_float& b) + { + cpp_float d(b); + d -= a; + return d.positive(); + } + + friend bool operator>(cpp_float const&a, cpp_float const&b){ + return b=(cpp_float const&a, cpp_float const&b){ + return !(ab); + } + + + friend bool operator==(cpp_float const&a, cpp_float const&b){ + int shift = a.exp - b.exp; + if(shift > 0){ + boost::multiprecision::cpp_int ac(a.man); + ac <<= shift; + return ac == b.man; + }else if(shift < 0){ + boost::multiprecision::cpp_int bc(b.man); + bc <<= shift; + return a.man == bc; + } + return a.man==b.man; + } + + Comparison_result compare(const cpp_float& other) const + { + if(*this < other) return SMALLER; + if(*this > other) return LARGER; + return EQUAL; + } + + friend bool operator!=(cpp_float const&a, cpp_float const&b){ + return !(a==b); + } + + friend double to_double(const cpp_float const&a) + { + if(a.exp == 0){ + return to_double(a.man); + } + if(a.exp > 0){ + boost::multiprecision::cpp_int as(a.man); + as <<= a.exp; + return to_double(as); + } + boost::multiprecision::cpp_int pow(1); + pow <<= -a.exp; + boost::multiprecision::cpp_rational rat(a.man, pow); + return to_double(rat); + } + + friend std::pair to_interval() + { + assert(false); + double zero(0); + return std::make_pair(zero,zero); + } + + + bool is_zero () const { + assert(false); + return man==0 && exp == 0; + } + + + bool is_one () const { + assert(false); + return true; + // return exp==0 && size==1 && data()[0]==1; + } + + + CGAL::Sign sign () const + { + return CGAL::sign(man); + } + +}; + + cpp_float operator+(const cpp_float& a, const cpp_float&b){ + cpp_float ret(a); + return ret += b; + } + + cpp_float operator-(const cpp_float& a, const cpp_float&b){ + cpp_float ret(a); + return ret -= b; + } + + cpp_float operator*(const cpp_float& a, const cpp_float&b){ + cpp_float ret(a); + return ret *= b; + } + + + template <> struct Algebraic_structure_traits< cpp_float > + : public Algebraic_structure_traits_base< cpp_float, Integral_domain_without_division_tag > { + typedef Tag_true Is_exact; + typedef Tag_false Is_numerical_sensitive; + + struct Is_zero + : public CGAL::cpp98::unary_function< Type, bool > { + bool operator()( const Type& x ) const { + return x.is_zero(); + } + }; + + struct Is_one + : public CGAL::cpp98::unary_function< Type, bool > { + bool operator()( const Type& x ) const { + assert(false); + return false; // x.is_one(); + } + }; + + struct Gcd + : public CGAL::cpp98::binary_function< Type, Type, Type > { + Type operator()( + const Type& x, + const Type& y ) const { + assert(false); + return Type(); // cpp_float_gcd(x, y); + } + }; + + struct Square + : public CGAL::cpp98::unary_function< Type, Type > { + Type operator()( const Type& x ) const { + return x*x ; // cpp_float_square(x); + } + }; + + struct Integral_division + : public CGAL::cpp98::binary_function< Type, Type, Type > { + Type operator()( + const Type& x, + const Type& y ) const { + assert(false); + return Type(); // x / y; + } + }; + + struct Sqrt + : public CGAL::cpp98::unary_function< Type, Type > { + Type operator()( const Type& x) const { + assert(false); + return Type(); // cpp_float_sqrt(x); + } + }; + + struct Is_square + : public CGAL::cpp98::binary_function< Type, Type&, bool > { + bool operator()( const Type& x, Type& y ) const { + // TODO: avoid doing 2 calls. + assert(false); + return true; + } + bool operator()( const Type& x) const { + assert(false); + return true; + } + }; + + }; + template <> struct Real_embeddable_traits< cpp_float > + : public INTERN_RET::Real_embeddable_traits_base< cpp_float , CGAL::Tag_true > { + struct Sgn + : public CGAL::cpp98::unary_function< Type, ::CGAL::Sign > { + ::CGAL::Sign operator()( const Type& x ) const { + return x.sign(); + } + }; + + struct To_double + : public CGAL::cpp98::unary_function< Type, double > { + double operator()( const Type& x ) const { + return x.to_double(); + } + }; + + struct Compare + : public CGAL::cpp98::binary_function< Type, Type, Comparison_result > { + Comparison_result operator()( + const Type& x, + const Type& y ) const { + return x.compare(y); + } + }; + + struct To_interval + : public CGAL::cpp98::unary_function< Type, std::pair< double, double > > { + std::pair operator()( const Type& x ) const { + return x.to_interval(); + } + }; + + }; + + + +} // namespace CGAL + + +#endif // CGAL_CPP_FLOAT_H From 6d7613f1e66c5397aacd2c814c3396ba5739d565 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 5 Apr 2023 11:42:21 +0100 Subject: [PATCH 080/139] fixes --- Number_types/include/CGAL/cpp_float.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Number_types/include/CGAL/cpp_float.h b/Number_types/include/CGAL/cpp_float.h index b3885c0e9229..8e2b4146cf79 100644 --- a/Number_types/include/CGAL/cpp_float.h +++ b/Number_types/include/CGAL/cpp_float.h @@ -1,3 +1,4 @@ + // Copyright (c) 2023 GeometryFactory (France). // All rights reserved. // @@ -130,7 +131,7 @@ class cpp_float { friend std::ostream& operator<<(std::ostream& os, const cpp_float& m) { - return os << m.man << " * 2 ^ " << m.exp << " ( " << to_double(m) << ") "; + return os << m.man << " * 2 ^ " << m.exp << " ( " << m.to_double() << ") "; } friend cpp_float operator-(cpp_float const&x) @@ -228,23 +229,23 @@ class cpp_float { return !(a==b); } - friend double to_double(const cpp_float const&a) + double to_double() const { - if(a.exp == 0){ - return to_double(a.man); + if(exp == 0){ + return to_double(man); } - if(a.exp > 0){ - boost::multiprecision::cpp_int as(a.man); - as <<= a.exp; + if(exp > 0){ + boost::multiprecision::cpp_int as(man); + as <<= exp; return to_double(as); } boost::multiprecision::cpp_int pow(1); - pow <<= -a.exp; - boost::multiprecision::cpp_rational rat(a.man, pow); + pow <<= -exp; + boost::multiprecision::cpp_rational rat(man, pow); return to_double(rat); } - friend std::pair to_interval() + std::pair to_interval() { assert(false); double zero(0); From 8ce49026a140493722896138e2a22b770657a34d Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 5 Apr 2023 11:50:04 +0100 Subject: [PATCH 081/139] The Kernel_23 testsuite compiles --- Number_types/include/CGAL/cpp_float.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Number_types/include/CGAL/cpp_float.h b/Number_types/include/CGAL/cpp_float.h index 8e2b4146cf79..bd98f62da268 100644 --- a/Number_types/include/CGAL/cpp_float.h +++ b/Number_types/include/CGAL/cpp_float.h @@ -232,20 +232,20 @@ class cpp_float { double to_double() const { if(exp == 0){ - return to_double(man); + return CGAL::to_double(man); } if(exp > 0){ boost::multiprecision::cpp_int as(man); as <<= exp; - return to_double(as); + return CGAL::to_double(as); } boost::multiprecision::cpp_int pow(1); pow <<= -exp; boost::multiprecision::cpp_rational rat(man, pow); - return to_double(rat); + return CGAL::to_double(rat); } - std::pair to_interval() + std::pair to_interval() const { assert(false); double zero(0); From caa9c4646d24bbec63b8195f2ceb3abca4dc2e30 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 5 Apr 2023 13:00:40 +0100 Subject: [PATCH 082/139] Polyhedron demo compiles --- Number_types/include/CGAL/cpp_float.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Number_types/include/CGAL/cpp_float.h b/Number_types/include/CGAL/cpp_float.h index bd98f62da268..e07a2c0d743d 100644 --- a/Number_types/include/CGAL/cpp_float.h +++ b/Number_types/include/CGAL/cpp_float.h @@ -273,16 +273,19 @@ class cpp_float { }; + inline cpp_float operator+(const cpp_float& a, const cpp_float&b){ cpp_float ret(a); return ret += b; } + inline cpp_float operator-(const cpp_float& a, const cpp_float&b){ cpp_float ret(a); return ret -= b; } + inline cpp_float operator*(const cpp_float& a, const cpp_float&b){ cpp_float ret(a); return ret *= b; @@ -393,6 +396,12 @@ class cpp_float { }; +CGAL_DEFINE_COERCION_TRAITS_FOR_SELF(cpp_float) +CGAL_DEFINE_COERCION_TRAITS_FROM_TO(short ,cpp_float) +CGAL_DEFINE_COERCION_TRAITS_FROM_TO(int ,cpp_float) +CGAL_DEFINE_COERCION_TRAITS_FROM_TO(long ,cpp_float) +CGAL_DEFINE_COERCION_TRAITS_FROM_TO(float ,cpp_float) +CGAL_DEFINE_COERCION_TRAITS_FROM_TO(double ,cpp_float) } // namespace CGAL From 10c45ef587cb945fa339871ec03d09a968e136ad Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 5 Apr 2023 13:44:49 +0100 Subject: [PATCH 083/139] Add constructors --- Number_types/include/CGAL/cpp_float.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Number_types/include/CGAL/cpp_float.h b/Number_types/include/CGAL/cpp_float.h index e07a2c0d743d..a527d158f3d4 100644 --- a/Number_types/include/CGAL/cpp_float.h +++ b/Number_types/include/CGAL/cpp_float.h @@ -69,10 +69,18 @@ class cpp_float { : man(), exp() {} + cpp_float(short i) + : man(i),exp(0) + {} + cpp_float(int i) : man(i),exp(0) {} + cpp_float(long i) + : man(i),exp(0) + {} + cpp_float(const boost::multiprecision::cpp_int& man, int exp) : man(man),exp(exp) {} @@ -80,7 +88,7 @@ class cpp_float { cpp_float(double d) { - std::cout << "\ndouble = " << d << std::endl; + //std::cout << "\ndouble = " << d << std::endl; using boost::uint64_t; union { #ifdef CGAL_LITTLE_ENDIAN @@ -110,21 +118,21 @@ class cpp_float { int idexp = (int)dexp; idexp -= 1023; - std::cout << "m = " << m << std::endl; - std::cout << "idexp = " << idexp << std::endl; + // std::cout << "m = " << m << std::endl; + // std::cout << "idexp = " << idexp << std::endl; int shifted = internal::low_bit(m); m >>= shifted; int nbits = internal::high_bit(m); - std::cout << "nbits = " << nbits << std::endl; + // std::cout << "nbits = " << nbits << std::endl; exp = idexp - nbits; if(u.s.sig){ m = -m; } - std::cout << "m = " << m << " * 2^" << exp << std::endl; + // std::cout << "m = " << m << " * 2^" << exp << std::endl; // fmt(m); man = boost::multiprecision::cpp_int(m); } From fafc4fd7ce1f76f1a120f13433a51ccd2655ab45 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 5 Apr 2023 14:10:12 +0100 Subject: [PATCH 084/139] Fix sign --- Number_types/include/CGAL/cpp_float.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Number_types/include/CGAL/cpp_float.h b/Number_types/include/CGAL/cpp_float.h index a527d158f3d4..599218e47eab 100644 --- a/Number_types/include/CGAL/cpp_float.h +++ b/Number_types/include/CGAL/cpp_float.h @@ -220,7 +220,7 @@ class cpp_float { return ac == b.man; }else if(shift < 0){ boost::multiprecision::cpp_int bc(b.man); - bc <<= shift; + bc <<= -shift; return a.man == bc; } return a.man==b.man; From 80eebff78d34be76e4782a0f044e50de34e00c11 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 5 Apr 2023 15:28:33 +0100 Subject: [PATCH 085/139] bug fix. todo: remove debug assertions --- Number_types/include/CGAL/cpp_float.h | 37 +++++++++++++------ Number_types/test/Number_types/CMakeLists.txt | 1 + .../benchmark/Triangulation_3/simple.cpp | 17 +++++---- 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/Number_types/include/CGAL/cpp_float.h b/Number_types/include/CGAL/cpp_float.h index 599218e47eab..f2e3a479893d 100644 --- a/Number_types/include/CGAL/cpp_float.h +++ b/Number_types/include/CGAL/cpp_float.h @@ -61,32 +61,34 @@ namespace internal { class cpp_float { + boost::multiprecision::cpp_rational rat; boost::multiprecision::cpp_int man; int exp; /* The number man (an integer) * 2 ^ exp */ public: cpp_float() - : man(), exp() + : rat(), man(), exp() {} cpp_float(short i) - : man(i),exp(0) + : rat(i), man(i),exp(0) {} cpp_float(int i) - : man(i),exp(0) + : rat(i),man(i),exp(0) {} cpp_float(long i) - : man(i),exp(0) + : rat(i),man(i),exp(0) {} - cpp_float(const boost::multiprecision::cpp_int& man, int exp) - : man(man),exp(exp) + cpp_float(const boost::multiprecision::cpp_int& man, int exp, const boost::multiprecision::cpp_rational& rat) + : rat(rat),man(man),exp(exp) {} cpp_float(double d) + : rat(d) { //std::cout << "\ndouble = " << d << std::endl; using boost::uint64_t; @@ -144,11 +146,12 @@ class cpp_float { friend cpp_float operator-(cpp_float const&x) { - return cpp_float(-x.man,x.exp); + return cpp_float(-x.man,x.exp, -x.rat); } cpp_float& operator*=(const cpp_float& other) { + rat *= other.rat; man *= other.man; exp += other.exp; return *this; @@ -156,6 +159,7 @@ class cpp_float { cpp_float operator+=(const cpp_float& other) { + rat += other.rat; int shift = exp - other.exp; if(shift > 0){ man <<= shift; @@ -163,7 +167,7 @@ class cpp_float { exp = other.exp; }else if(shift < 0){ boost::multiprecision::cpp_int cpy(other.man); - cpy << shift; + cpy <<= -shift; man += cpy; }else{ man += other.man; @@ -173,6 +177,9 @@ class cpp_float { cpp_float operator-=(const cpp_float& other) { + assert(is_positive(rat) == is_positive(man)); + assert(is_positive(other.rat) == is_positive(other.man)); + rat -= other.rat; int shift = exp - other.exp; if(shift > 0){ man <<= shift; @@ -180,25 +187,30 @@ class cpp_float { exp = other.exp; }else if(shift < 0){ boost::multiprecision::cpp_int cpy(other.man); - cpy << shift; + cpy <<= -shift; man -= cpy; }else{ man -= other.man; } + assert(is_positive(rat) == is_positive(man)); return *this; } bool positive() const { + assert(is_positive(rat) == is_positive(man)); return is_positive(man); } friend bool operator<(const cpp_float& a, const cpp_float& b) { + bool qres = a.rat < b.rat; cpp_float d(b); d -= a; - return d.positive(); + + assert(qres == ( (!d.is_zero()) && d.positive())); + return ( (!d.is_zero()) && d.positive()); } friend bool operator>(cpp_float const&a, cpp_float const&b){ @@ -213,16 +225,20 @@ class cpp_float { friend bool operator==(cpp_float const&a, cpp_float const&b){ + bool qres = a.rat == b.rat; int shift = a.exp - b.exp; if(shift > 0){ boost::multiprecision::cpp_int ac(a.man); ac <<= shift; + assert( qres == (ac == b.man)); return ac == b.man; }else if(shift < 0){ boost::multiprecision::cpp_int bc(b.man); bc <<= -shift; + assert(qres == (a.man == bc)); return a.man == bc; } + assert(qres == (a.man == b.man)); return a.man==b.man; } @@ -262,7 +278,6 @@ class cpp_float { bool is_zero () const { - assert(false); return man==0 && exp == 0; } diff --git a/Number_types/test/Number_types/CMakeLists.txt b/Number_types/test/Number_types/CMakeLists.txt index 1fb8b4aff34f..f1853f9b04a1 100644 --- a/Number_types/test/Number_types/CMakeLists.txt +++ b/Number_types/test/Number_types/CMakeLists.txt @@ -10,6 +10,7 @@ find_package(CGAL REQUIRED COMPONENTS Core) include_directories(BEFORE include) +create_single_source_cgal_program("cpp_float.cpp") create_single_source_cgal_program("bench_interval.cpp") create_single_source_cgal_program("constant.cpp") create_single_source_cgal_program("CORE_BigFloat.cpp") diff --git a/Triangulation_3/benchmark/Triangulation_3/simple.cpp b/Triangulation_3/benchmark/Triangulation_3/simple.cpp index d04d8d72fcbf..673a940218f3 100644 --- a/Triangulation_3/benchmark/Triangulation_3/simple.cpp +++ b/Triangulation_3/benchmark/Triangulation_3/simple.cpp @@ -1,6 +1,6 @@ //#define CGAL_PROFILE -#define CGAL_USE_SSE2_FABS -#define CGAL_USE_SSE2_MAX +//#define CGAL_USE_SSE2_FABS +//#define CGAL_USE_SSE2_MAX //#define CGAL_MSVC_USE_STD_FABS // use this one with precise #include @@ -11,25 +11,28 @@ #include #include +#include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Delaunay_triangulation_3 DT; typedef DT::Point Point_3; typedef CGAL::Timer Timer; -int main() +int main(int argc, char* argv[]) { - + const std::string filename = (argc > 1) ? argv[1] : CGAL::data_file_path("points_3/ocean_r.xyz"); + std::ifstream in(filename.c_str()); std::vector points; - Point_3 p; + Point_3 p, q; - while(std::cin >> p){ + while(in >> p ){ points.push_back(p); } Timer timer; timer.start(); size_t N = 0; - for(int i = 0; i < 5; i++){ + for(int i = 0; i < 1; i++){ DT dt; dt.insert(points.begin(), points.end()); N += dt.number_of_cells(); From 99000048606d856a8a420bc2eacb8dc426e5a617 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 6 Apr 2023 08:00:34 +0100 Subject: [PATCH 086/139] simplify expressions --- Number_types/include/CGAL/cpp_float.h | 129 ++++++++++++++++++-------- 1 file changed, 92 insertions(+), 37 deletions(-) diff --git a/Number_types/include/CGAL/cpp_float.h b/Number_types/include/CGAL/cpp_float.h index f2e3a479893d..eb9c37876738 100644 --- a/Number_types/include/CGAL/cpp_float.h +++ b/Number_types/include/CGAL/cpp_float.h @@ -60,35 +60,59 @@ namespace internal { #endif class cpp_float { - +#ifdef CGAL_CPPF boost::multiprecision::cpp_rational rat; +#endif boost::multiprecision::cpp_int man; int exp; /* The number man (an integer) * 2 ^ exp */ public: cpp_float() - : rat(), man(), exp() + : +#ifdef CGAL_CPPF + rat(), +#endif + man(), exp() {} cpp_float(short i) - : rat(i), man(i),exp(0) + : +#ifdef CGAL_CPPF + rat(i), +#endif + man(i),exp(0) {} cpp_float(int i) - : rat(i),man(i),exp(0) + : +#ifdef CGAL_CPPF + rat(i), +#endif + man(i),exp(0) {} cpp_float(long i) - : rat(i),man(i),exp(0) + : +#ifdef CGAL_CPPF + rat(i), +#endif + man(i),exp(0) {} - +#ifdef CGAL_CPPF cpp_float(const boost::multiprecision::cpp_int& man, int exp, const boost::multiprecision::cpp_rational& rat) - : rat(rat),man(man),exp(exp) + : rat(rat), man(man),exp(exp) {} +#else - + cpp_float(const boost::multiprecision::cpp_int& man, int exp) + : man(man), exp(exp) + {} +#endif cpp_float(double d) - : rat(d) + +#ifdef CGAL_CPPF + : rat(d) +#endif { //std::cout << "\ndouble = " << d << std::endl; using boost::uint64_t; @@ -146,70 +170,110 @@ class cpp_float { friend cpp_float operator-(cpp_float const&x) { +#ifdef CGAL_CPPF return cpp_float(-x.man,x.exp, -x.rat); +#else + return cpp_float(-x.man,x.exp); +#endif } cpp_float& operator*=(const cpp_float& other) { +#ifdef CGAL_CPPF rat *= other.rat; +#endif man *= other.man; exp += other.exp; return *this; } + + friend + cpp_float operator*(const cpp_float& a, const cpp_float&b){ + return cpp_float(a.man*b.man, a.exp+b.exp); + } + + cpp_float operator+=(const cpp_float& other) { +#ifdef CGAL_CPPF rat += other.rat; +#endif int shift = exp - other.exp; if(shift > 0){ man <<= shift; man += other.man; exp = other.exp; }else if(shift < 0){ - boost::multiprecision::cpp_int cpy(other.man); - cpy <<= -shift; - man += cpy; + man += (other.man << -shift); }else{ man += other.man; } return *this; } + + friend + cpp_float operator+(const cpp_float& a, const cpp_float&b){ + int shift = a.exp - b.exp; + if(shift > 0){ + return cpp_float((a.man << shift) + b.man, b.exp); + }else if(shift < 0){ + return cpp_float(a.man + (b.man << -shift), a.exp); + } + return cpp_float(a.man + b.man, a.exp); + } + + + cpp_float operator-=(const cpp_float& other) { - assert(is_positive(rat) == is_positive(man)); - assert(is_positive(other.rat) == is_positive(other.man)); + +#ifdef CGAL_CPPF rat -= other.rat; +#endif int shift = exp - other.exp; if(shift > 0){ man <<= shift; man -= other.man; exp = other.exp; }else if(shift < 0){ - boost::multiprecision::cpp_int cpy(other.man); - cpy <<= -shift; - man -= cpy; + man -= (other.man << -shift); }else{ man -= other.man; } - assert(is_positive(rat) == is_positive(man)); return *this; } + friend + cpp_float operator-(const cpp_float& a, const cpp_float&b){ + + int shift = a.exp - b.exp; + if(shift > 0){ + return cpp_float((a.man << shift) - b.man, b.exp); + }else if(shift < 0){ + return cpp_float(a.man - (b.man << -shift), a.exp); + } + return cpp_float(a.man - b.man, a.exp); + } + bool positive() const { - assert(is_positive(rat) == is_positive(man)); return is_positive(man); } friend bool operator<(const cpp_float& a, const cpp_float& b) { +#ifdef CGAL_CPPF bool qres = a.rat < b.rat; +#endif cpp_float d(b); d -= a; +#ifdef CGAL_CPPF assert(qres == ( (!d.is_zero()) && d.positive())); +#endif return ( (!d.is_zero()) && d.positive()); } @@ -225,20 +289,29 @@ class cpp_float { friend bool operator==(cpp_float const&a, cpp_float const&b){ + +#ifdef CGAL_CPPF bool qres = a.rat == b.rat; +#endif int shift = a.exp - b.exp; if(shift > 0){ boost::multiprecision::cpp_int ac(a.man); ac <<= shift; +#ifdef CGAL_CPPF assert( qres == (ac == b.man)); +#endif return ac == b.man; }else if(shift < 0){ boost::multiprecision::cpp_int bc(b.man); bc <<= -shift; +#ifdef CGAL_CPPF assert(qres == (a.man == bc)); +#endif return a.man == bc; } +#ifdef CGAL_CPPF assert(qres == (a.man == b.man)); +#endif return a.man==b.man; } @@ -296,24 +369,6 @@ class cpp_float { }; - inline - cpp_float operator+(const cpp_float& a, const cpp_float&b){ - cpp_float ret(a); - return ret += b; - } - - inline - cpp_float operator-(const cpp_float& a, const cpp_float&b){ - cpp_float ret(a); - return ret -= b; - } - - inline - cpp_float operator*(const cpp_float& a, const cpp_float&b){ - cpp_float ret(a); - return ret *= b; - } - template <> struct Algebraic_structure_traits< cpp_float > : public Algebraic_structure_traits_base< cpp_float, Integral_domain_without_division_tag > { From c114802df852c23e46394bbb4b54758daed48456 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 6 Apr 2023 11:26:34 +0100 Subject: [PATCH 087/139] Add constructor for expression --- Number_types/include/CGAL/cpp_float.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Number_types/include/CGAL/cpp_float.h b/Number_types/include/CGAL/cpp_float.h index eb9c37876738..92a96b1d292e 100644 --- a/Number_types/include/CGAL/cpp_float.h +++ b/Number_types/include/CGAL/cpp_float.h @@ -107,6 +107,13 @@ class cpp_float { cpp_float(const boost::multiprecision::cpp_int& man, int exp) : man(man), exp(exp) {} + + + template + cpp_float(const Expression& man, int exp) + : man(man), exp(exp) + {} + #endif cpp_float(double d) From b9b1be1503a0a0f76ffaf29855fda456eb07f044 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 6 Apr 2023 12:07:09 +0100 Subject: [PATCH 088/139] Set MinBits to 256 (as it is good for Dt3 --- Number_types/include/CGAL/cpp_float.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Number_types/include/CGAL/cpp_float.h b/Number_types/include/CGAL/cpp_float.h index 92a96b1d292e..102bf9ff2fd8 100644 --- a/Number_types/include/CGAL/cpp_float.h +++ b/Number_types/include/CGAL/cpp_float.h @@ -63,7 +63,9 @@ class cpp_float { #ifdef CGAL_CPPF boost::multiprecision::cpp_rational rat; #endif - boost::multiprecision::cpp_int man; + + typedef boost::multiprecision::number > Mantissa; + Mantissa man; int exp; /* The number man (an integer) * 2 ^ exp */ public: @@ -99,12 +101,12 @@ class cpp_float { man(i),exp(0) {} #ifdef CGAL_CPPF - cpp_float(const boost::multiprecision::cpp_int& man, int exp, const boost::multiprecision::cpp_rational& rat) + cpp_float(const Mantissa& man, int exp, const boost::multiprecision::cpp_rational& rat) : rat(rat), man(man),exp(exp) {} #else - cpp_float(const boost::multiprecision::cpp_int& man, int exp) + cpp_float(const Mantissa& man, int exp) : man(man), exp(exp) {} @@ -167,7 +169,7 @@ class cpp_float { } // std::cout << "m = " << m << " * 2^" << exp << std::endl; // fmt(m); - man = boost::multiprecision::cpp_int(m); + man = Mantissa(m); } friend std::ostream& operator<<(std::ostream& os, const cpp_float& m) @@ -302,14 +304,14 @@ class cpp_float { #endif int shift = a.exp - b.exp; if(shift > 0){ - boost::multiprecision::cpp_int ac(a.man); + Mantissa ac(a.man); ac <<= shift; #ifdef CGAL_CPPF assert( qres == (ac == b.man)); #endif return ac == b.man; }else if(shift < 0){ - boost::multiprecision::cpp_int bc(b.man); + Mantissa bc(b.man); bc <<= -shift; #ifdef CGAL_CPPF assert(qres == (a.man == bc)); @@ -339,11 +341,11 @@ class cpp_float { return CGAL::to_double(man); } if(exp > 0){ - boost::multiprecision::cpp_int as(man); + Mantissa as(man); as <<= exp; return CGAL::to_double(as); } - boost::multiprecision::cpp_int pow(1); + Mantissa pow(1); pow <<= -exp; boost::multiprecision::cpp_rational rat(man, pow); return CGAL::to_double(rat); From 47bfc83cba2d909ff16c61497f6df5ed50797a48 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 6 Apr 2023 12:30:01 +0100 Subject: [PATCH 089/139] Use std::move() --- Number_types/include/CGAL/cpp_float.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Number_types/include/CGAL/cpp_float.h b/Number_types/include/CGAL/cpp_float.h index 102bf9ff2fd8..0060c3a7e11b 100644 --- a/Number_types/include/CGAL/cpp_float.h +++ b/Number_types/include/CGAL/cpp_float.h @@ -169,7 +169,7 @@ class cpp_float { } // std::cout << "m = " << m << " * 2^" << exp << std::endl; // fmt(m); - man = Mantissa(m); + man = std::move(m); } friend std::ostream& operator<<(std::ostream& os, const cpp_float& m) From 1d5f57ebb7f4b8251c8c9d5b700368877af3fb5c Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 6 Apr 2023 15:53:43 +0100 Subject: [PATCH 090/139] 256 -> 512 and no need for std::move() --- Number_types/include/CGAL/cpp_float.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Number_types/include/CGAL/cpp_float.h b/Number_types/include/CGAL/cpp_float.h index 0060c3a7e11b..5c121796d3bb 100644 --- a/Number_types/include/CGAL/cpp_float.h +++ b/Number_types/include/CGAL/cpp_float.h @@ -64,7 +64,7 @@ class cpp_float { boost::multiprecision::cpp_rational rat; #endif - typedef boost::multiprecision::number > Mantissa; + typedef boost::multiprecision::number > Mantissa; Mantissa man; int exp; /* The number man (an integer) * 2 ^ exp */ @@ -169,7 +169,7 @@ class cpp_float { } // std::cout << "m = " << m << " * 2^" << exp << std::endl; // fmt(m); - man = std::move(m); + man = m; } friend std::ostream& operator<<(std::ostream& os, const cpp_float& m) From 8a5fc31c6cbd13347d736fce6377e9bdb690a10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 6 Apr 2023 17:25:17 +0200 Subject: [PATCH 091/139] example of perfect forwarding for Point_3 --- Cartesian_kernel/include/CGAL/Cartesian/Point_3.h | 5 +++++ Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h | 5 ++++- .../include/CGAL/Cartesian/function_objects.h | 8 ++++++++ Kernel_23/include/CGAL/Point_3.h | 9 ++++++++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h index 1bd80cdb016f..205a9af6346a 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h @@ -45,6 +45,11 @@ class PointC3 PointC3(const FT &x, const FT &y, const FT &z) : base(x, y, z) {} + PointC3(FT &&x, FT &&y, FT &&z) + : base(std::forward(x), std::forward(y), std::forward(z)) + {} + + PointC3(const FT &x, const FT &y, const FT &z, const FT &w) : base(x, y, z, w) {} diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h index 5b03e8d0fb35..55862b39bc87 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h @@ -65,7 +65,10 @@ class VectorC3 { *this = R().construct_vector_3_object()(l); } VectorC3(const FT_ &x, const FT_ &y, const FT_ &z) - : base(CGAL::make_array(x, y, z)) {} + : base(Rep{x, y, z}) {} + + VectorC3(FT_ &&x, FT_ &&y, FT_ &&z) + : base(Rep{x, y, z}) {} VectorC3(const FT_ &x, const FT_ &y, const FT_ &z, const FT_ &w) : base( w != FT_(1) ? CGAL::make_array(x/w, y/w, z/w) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index 737a52dfc143..effe3bf68a95 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3160,6 +3160,10 @@ namespace CartesianKernelFunctors { operator()(Return_base_tag, const RT& x, const RT& y, const RT& z) const { return Rep(x, y, z); } + Rep // Point_3 + operator()(Return_base_tag, RT&& x, RT&& y, RT&& z) const + { return Rep(std::forward(x), std::forward(y), std::forward(z)); } + Rep // Point_3 operator()(Return_base_tag, const RT& x, const RT& y, const RT& z, const RT& w) const { return Rep(x, y, z, w); } @@ -3180,6 +3184,10 @@ namespace CartesianKernelFunctors { operator()(const RT& x, const RT& y, const RT& z) const { return Point_3(x, y, z); } + Point_3 + operator()(RT&& x, RT&& y, RT&& z) const + { return Point_3(std::forward(x), std::forward(y), std::forward(z)); } + Point_3 operator()(const RT& x, const RT& y, const RT& z, const RT& w) const { return Point_3(x, y, z, w); } diff --git a/Kernel_23/include/CGAL/Point_3.h b/Kernel_23/include/CGAL/Point_3.h index 03d00f78f3f2..127e77460896 100644 --- a/Kernel_23/include/CGAL/Point_3.h +++ b/Kernel_23/include/CGAL/Point_3.h @@ -79,6 +79,13 @@ class Point_3 : public R_::Kernel_base::Point_3 : Rep(typename R::Construct_point_3()(Return_base_tag(), x, y, z)) {} + template < typename T1, typename T2, typename T3 > + Point_3(T1&& x, T2&& y, T3&& z) + : Rep(typename R::Construct_point_3()(Return_base_tag(), std::forward(x), + std::forward(y), + std::forward(z))) + {} + Point_3(const RT& hx, const RT& hy, const RT& hz, const RT& hw) : Rep(typename R::Construct_point_3()(Return_base_tag(), hx, hy, hz, hw)) {} @@ -283,7 +290,7 @@ extract(std::istream& is, Point_3& p, const Cartesian_tag&) break; } if (is) - p = Point_3(x, y, z); + p = Point_3(std::move(x), std::move(y), std::move(z)); return is; } From 6eb866f9d9e42c0d5de71d25013107d527f95955 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 6 Apr 2023 17:49:24 +0100 Subject: [PATCH 092/139] More forwarding --- Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h | 2 +- Cartesian_kernel/include/CGAL/Cartesian/function_objects.h | 4 ++++ Kernel_23/include/CGAL/Vector_3.h | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h index 55862b39bc87..cf0df15df762 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h @@ -68,7 +68,7 @@ class VectorC3 : base(Rep{x, y, z}) {} VectorC3(FT_ &&x, FT_ &&y, FT_ &&z) - : base(Rep{x, y, z}) {} + : base(Rep{std::forward(x), std::forward(y), std::forward(z)}) {} VectorC3(const FT_ &x, const FT_ &y, const FT_ &z, const FT_ &w) : base( w != FT_(1) ? CGAL::make_array(x/w, y/w, z/w) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index effe3bf68a95..0425e888b544 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3679,6 +3679,10 @@ namespace CartesianKernelFunctors { operator()(Return_base_tag, const RT& x, const RT& y, const RT& z) const { return Rep(x, y, z); } + Rep // Vector_3 + operator()(Return_base_tag, RT&& x, RT&& y, RT&& z) const + { return Rep(std::forward(x), std::forward(y), std::forward(z)); } + Rep // Vector_3 operator()(Return_base_tag, const RT& x, const RT& y, const RT& z, const RT& w) const { return Rep(x, y, z, w); } diff --git a/Kernel_23/include/CGAL/Vector_3.h b/Kernel_23/include/CGAL/Vector_3.h index f81aee480f42..e8cf72bdf878 100644 --- a/Kernel_23/include/CGAL/Vector_3.h +++ b/Kernel_23/include/CGAL/Vector_3.h @@ -91,6 +91,13 @@ class Vector_3 : public R_::Kernel_base::Vector_3 Vector_3(const T1 &x, const T2 &y, const T3 &z) : Rep(typename R::Construct_vector_3()(Return_base_tag(), x, y, z)) {} + template < typename T1, typename T2, typename T3 > + Vector_3(T1&& x, T2&& y, T3&& z) + : Rep(typename R::Construct_vector_3()(Return_base_tag(), std::forward(x), + std::forward(y), + std::forward(z))) + {} + Vector_3(const RT& x, const RT& y, const RT& z, const RT& w) : Rep(typename R::Construct_vector_3()(Return_base_tag(), x, y, z, w)) {} From 97fbd69822f2c7ec8eeaf4b9776da75008f35f44 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 23 Feb 2024 16:14:41 +0000 Subject: [PATCH 093/139] remove duplicate line --- Number_types/test/Number_types/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/Number_types/test/Number_types/CMakeLists.txt b/Number_types/test/Number_types/CMakeLists.txt index 05c0fecf115d..b3dd989c7664 100644 --- a/Number_types/test/Number_types/CMakeLists.txt +++ b/Number_types/test/Number_types/CMakeLists.txt @@ -10,7 +10,6 @@ find_package(CGAL REQUIRED COMPONENTS Core) include_directories(BEFORE include) -create_single_source_cgal_program("cpp_float.cpp") create_single_source_cgal_program("bench_interval.cpp") create_single_source_cgal_program("cpp_float.cpp") create_single_source_cgal_program("constant.cpp") From e20485782c196ad4744809f0d57d4c3789635c54 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 23 Feb 2024 16:46:34 +0000 Subject: [PATCH 094/139] Fixes for expression templates --- .../include/CGAL/Arr_conic_traits_2.h | 28 +++++++++---------- .../Conic_intersections_2.h | 9 +++--- .../internal/Exact_type_selector.h | 5 ---- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h index a850f5ef3c88..c9aec291440b 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h @@ -3316,9 +3316,9 @@ class Arr_conic_traits_2 { // sqrt((r - s)^2 + t^2) // const int or_fact = (cv.orientation() == CLOCKWISE) ? -1 : 1; - const Algebraic r = m_nt_traits->convert(or_fact * cv.r()); - const Algebraic s = m_nt_traits->convert(or_fact * cv.s()); - const Algebraic t = m_nt_traits->convert(or_fact * cv.t()); + const Algebraic r = m_nt_traits->convert(Integer(or_fact * cv.r())); + const Algebraic s = m_nt_traits->convert(Integer(or_fact * cv.s())); + const Algebraic t = m_nt_traits->convert(Integer(or_fact * cv.t())); const Algebraic cos_2phi = (r - s) / m_nt_traits->sqrt((r-s)*(r-s) + t*t); const Algebraic zero = 0; const Algebraic one = 1; @@ -3363,8 +3363,8 @@ class Arr_conic_traits_2 { // 4*r*s - t^2 4*r*s - t^2 // // The denominator (4*r*s - t^2) must be negative for hyperbolas. - const Algebraic u = m_nt_traits->convert(or_fact * cv.u()); - const Algebraic v = m_nt_traits->convert(or_fact * cv.v()); + const Algebraic u = m_nt_traits->convert(Integer(or_fact * cv.u())); + const Algebraic v = m_nt_traits->convert(Integer(or_fact * cv.v())); const Algebraic det = 4*r*s - t*t; Algebraic x0, y0; @@ -3803,9 +3803,9 @@ class Arr_conic_traits_2 { auto u = cv.u(); auto v = cv.v(); auto w = cv.w(); - Algebraic* xs_end = m_nt_traits->solve_quadratic_equation(t*t - four*r*s, - two*t*v - four*s*u, - v*v - four*s*w, + Algebraic* xs_end = m_nt_traits->solve_quadratic_equation(Integer(t*t - four*r*s), + Integer(two*t*v - four*s*u), + Integer(v*v - four*s*w), xs); auto n_xs = static_cast(xs_end - xs); @@ -3816,14 +3816,14 @@ class Arr_conic_traits_2 { if (CGAL::sign(cv.t()) == ZERO) { // The two vertical tangency points have the same y coordinate: - ys[0] = m_nt_traits->convert(-v) / m_nt_traits->convert(two*s); + ys[0] = m_nt_traits->convert(Integer(- v)) / m_nt_traits->convert(Integer(two * s)); n_ys = 1; } else { - ys_end = m_nt_traits->solve_quadratic_equation(four*r*s*s - s*t*t, - four*r*s*v - two*s*t*u, - r*v*v - t*u*v + - t*t*w, + ys_end = m_nt_traits->solve_quadratic_equation(Integer(four*r*s*s - s*t*t), + Integer(four*r*s*v - two*s*t*u), + Integer(r*v*v - t*u*v) + + Integer(t*t*w), ys); n_ys = static_cast(ys_end - ys); } @@ -3837,7 +3837,7 @@ class Arr_conic_traits_2 { } else { for (int j = 0; j < n_ys; ++j) { - if (CGAL::compare(m_nt_traits->convert(two*s) * ys[j], + if (CGAL::compare(m_nt_traits->convert(Integer(two*s)) * ys[j], -(m_nt_traits->convert(t) * xs[i] + m_nt_traits->convert(v))) == EQUAL) { diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_intersections_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_intersections_2.h index 223fcda24e9f..3af830c193da 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_intersections_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Conic_intersections_2.h @@ -64,8 +64,9 @@ int compute_resultant_roots(const Nt_traits& nt_traits, } // Act according to the degree of the first conic curve. - const typename Nt_traits::Integer two = 2; - typename Nt_traits::Integer c[5]; + typedef typename Nt_traits::Integer Integer; + const Integer two = 2; + Integer c[5]; unsigned int degree = 4; typename Nt_traits::Algebraic* xs_end; @@ -73,7 +74,7 @@ int compute_resultant_roots(const Nt_traits& nt_traits, // The first curve has no quadratic coefficients, and represents a line. if (CGAL::sign (v1) == ZERO) { // The first line is u1*x + w1 = 0, therefore: - xs[0] = nt_traits.convert(-w1) / nt_traits.convert(u1); + xs[0] = nt_traits.convert(Integer(- w1)) / nt_traits.convert(u1); return 1; } @@ -87,7 +88,7 @@ int compute_resultant_roots(const Nt_traits& nt_traits, // Return if the two lines are parallel if (CGAL::sign (c[1]) == ZERO) return 0; - xs[0] = nt_traits.convert(-c[0]) / nt_traits.convert(c[1]); + xs[0] = nt_traits.convert(Integer(- c[0])) / nt_traits.convert(c[1]); return 1; } diff --git a/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h b/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h index 35690bbdf29d..745d1d93433e 100644 --- a/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h +++ b/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h @@ -128,11 +128,6 @@ struct Exact_NT_backend #endif template <> -struct Exact_ring_selector -#ifdef CGAL_HAS_MPZF -{ typedef cpp_float Type; }; -#elif defined(CGAL_HAS_THREADS) || !defined(CGAL_USE_GMP) -{ typedef MP_Float Type; }; struct Exact_NT_backend : public MP_Float_arithmetic_kernel { From 4a222f116540f6ccba37d71a6ec916b0b21d3c17 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 26 Feb 2024 13:46:32 +0100 Subject: [PATCH 095/139] fix the CI issue --- Installation/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 7fcaf91c0353..10fd9e9888c9 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -940,7 +940,7 @@ if(CGAL_BRANCH_BUILD) set(compile_options "\ -${CMAKE_CXX_FLAGS} -DCGAL_EIGEN3_ENABLED -DCGAL_PROFILE -DCGAL_USE_CORE\ +${CMAKE_CXX_FLAGS} -DCGAL_EIGEN3_ENABLED -DCGAL_PROFILE -DCGAL_USE_CORE \ ${Qt6Widgets_DEFINITIONS} ${Qt6OpenGL_DEFINITIONS} ${Qt6Gui_DEFINITIONS} \ ${Qt6OpenGL_EXECUTABLE_COMPILE_FLAGS} -fPIC \ ${Qt6Gui_EXECUTABLE_COMPILE_FLAGS} \ From 30e9eac7bde567ca2463f59646b8bd0a768ac392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 27 Feb 2024 10:18:50 +0100 Subject: [PATCH 096/139] Revert "More forwarding" This reverts commit 6eb866f9d9e42c0d5de71d25013107d527f95955. --- Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h | 2 +- Cartesian_kernel/include/CGAL/Cartesian/function_objects.h | 4 ---- Kernel_23/include/CGAL/Vector_3.h | 7 ------- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h index cf0df15df762..55862b39bc87 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h @@ -68,7 +68,7 @@ class VectorC3 : base(Rep{x, y, z}) {} VectorC3(FT_ &&x, FT_ &&y, FT_ &&z) - : base(Rep{std::forward(x), std::forward(y), std::forward(z)}) {} + : base(Rep{x, y, z}) {} VectorC3(const FT_ &x, const FT_ &y, const FT_ &z, const FT_ &w) : base( w != FT_(1) ? CGAL::make_array(x/w, y/w, z/w) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index 0425e888b544..effe3bf68a95 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3679,10 +3679,6 @@ namespace CartesianKernelFunctors { operator()(Return_base_tag, const RT& x, const RT& y, const RT& z) const { return Rep(x, y, z); } - Rep // Vector_3 - operator()(Return_base_tag, RT&& x, RT&& y, RT&& z) const - { return Rep(std::forward(x), std::forward(y), std::forward(z)); } - Rep // Vector_3 operator()(Return_base_tag, const RT& x, const RT& y, const RT& z, const RT& w) const { return Rep(x, y, z, w); } diff --git a/Kernel_23/include/CGAL/Vector_3.h b/Kernel_23/include/CGAL/Vector_3.h index 36decefd0047..9220f3e8527b 100644 --- a/Kernel_23/include/CGAL/Vector_3.h +++ b/Kernel_23/include/CGAL/Vector_3.h @@ -91,13 +91,6 @@ class Vector_3 : public R_::Kernel_base::Vector_3 Vector_3(const T1 &x, const T2 &y, const T3 &z) : Rep(typename R::Construct_vector_3()(Return_base_tag(), x, y, z)) {} - template < typename T1, typename T2, typename T3 > - Vector_3(T1&& x, T2&& y, T3&& z) - : Rep(typename R::Construct_vector_3()(Return_base_tag(), std::forward(x), - std::forward(y), - std::forward(z))) - {} - Vector_3(const RT& x, const RT& y, const RT& z, const RT& w) : Rep(typename R::Construct_vector_3()(Return_base_tag(), x, y, z, w)) {} From 5ad84b06b6dd7c1af58fe7e2b0e4034bc093180b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 27 Feb 2024 10:18:56 +0100 Subject: [PATCH 097/139] Revert "example of perfect forwarding for Point_3" This reverts commit 8a5fc31c6cbd13347d736fce6377e9bdb690a10b. --- Cartesian_kernel/include/CGAL/Cartesian/Point_3.h | 5 ----- Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h | 5 +---- .../include/CGAL/Cartesian/function_objects.h | 8 -------- Kernel_23/include/CGAL/Point_3.h | 9 +-------- 4 files changed, 2 insertions(+), 25 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h index 205a9af6346a..1bd80cdb016f 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h @@ -45,11 +45,6 @@ class PointC3 PointC3(const FT &x, const FT &y, const FT &z) : base(x, y, z) {} - PointC3(FT &&x, FT &&y, FT &&z) - : base(std::forward(x), std::forward(y), std::forward(z)) - {} - - PointC3(const FT &x, const FT &y, const FT &z, const FT &w) : base(x, y, z, w) {} diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h index 55862b39bc87..5b03e8d0fb35 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h @@ -65,10 +65,7 @@ class VectorC3 { *this = R().construct_vector_3_object()(l); } VectorC3(const FT_ &x, const FT_ &y, const FT_ &z) - : base(Rep{x, y, z}) {} - - VectorC3(FT_ &&x, FT_ &&y, FT_ &&z) - : base(Rep{x, y, z}) {} + : base(CGAL::make_array(x, y, z)) {} VectorC3(const FT_ &x, const FT_ &y, const FT_ &z, const FT_ &w) : base( w != FT_(1) ? CGAL::make_array(x/w, y/w, z/w) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index effe3bf68a95..737a52dfc143 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3160,10 +3160,6 @@ namespace CartesianKernelFunctors { operator()(Return_base_tag, const RT& x, const RT& y, const RT& z) const { return Rep(x, y, z); } - Rep // Point_3 - operator()(Return_base_tag, RT&& x, RT&& y, RT&& z) const - { return Rep(std::forward(x), std::forward(y), std::forward(z)); } - Rep // Point_3 operator()(Return_base_tag, const RT& x, const RT& y, const RT& z, const RT& w) const { return Rep(x, y, z, w); } @@ -3184,10 +3180,6 @@ namespace CartesianKernelFunctors { operator()(const RT& x, const RT& y, const RT& z) const { return Point_3(x, y, z); } - Point_3 - operator()(RT&& x, RT&& y, RT&& z) const - { return Point_3(std::forward(x), std::forward(y), std::forward(z)); } - Point_3 operator()(const RT& x, const RT& y, const RT& z, const RT& w) const { return Point_3(x, y, z, w); } diff --git a/Kernel_23/include/CGAL/Point_3.h b/Kernel_23/include/CGAL/Point_3.h index 613e9f20c5b1..f2444a9506c0 100644 --- a/Kernel_23/include/CGAL/Point_3.h +++ b/Kernel_23/include/CGAL/Point_3.h @@ -79,13 +79,6 @@ class Point_3 : public R_::Kernel_base::Point_3 : Rep(typename R::Construct_point_3()(Return_base_tag(), x, y, z)) {} - template < typename T1, typename T2, typename T3 > - Point_3(T1&& x, T2&& y, T3&& z) - : Rep(typename R::Construct_point_3()(Return_base_tag(), std::forward(x), - std::forward(y), - std::forward(z))) - {} - Point_3(const RT& hx, const RT& hy, const RT& hz, const RT& hw) : Rep(typename R::Construct_point_3()(Return_base_tag(), hx, hy, hz, hw)) {} @@ -290,7 +283,7 @@ extract(std::istream& is, Point_3& p, const Cartesian_tag&) break; } if (is) - p = Point_3(std::move(x), std::move(y), std::move(z)); + p = Point_3(x, y, z); return is; } From f802557b7bc2ef07dae3965bb8eb972065fb9dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 27 Feb 2024 11:23:10 +0100 Subject: [PATCH 098/139] sync with master@ec9de37b61 --- .../CGAL/Number_types/internal/Exact_type_selector.h | 4 ++-- Number_types/include/CGAL/boost_mp_type.h | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h b/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h index 745d1d93433e..772200e7b729 100644 --- a/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h +++ b/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h @@ -23,8 +23,8 @@ #include #include -#include -# include +#include + #ifdef CGAL_USE_GMP # include # include diff --git a/Number_types/include/CGAL/boost_mp_type.h b/Number_types/include/CGAL/boost_mp_type.h index 731364b43c76..1c038ad33905 100644 --- a/Number_types/include/CGAL/boost_mp_type.h +++ b/Number_types/include/CGAL/boost_mp_type.h @@ -20,8 +20,18 @@ // easy solution. // MSVC had trouble with versions <= 1.69: // https://github.com/boostorg/multiprecision/issues/98 +// +// Disable also on Windows 32 bits +// because CGAL/cpp_float.h assumes _BitScanForward64 is available +// See https://learn.microsoft.com/en-us/cpp/intrinsics/bitscanforward-bitscanforward64 +// +// Disable also with PowerPC processors, with Boost<1.80 because of that bug: +// https://github.com/boostorg/multiprecision/pull/421 +// #if !defined CGAL_DO_NOT_USE_BOOST_MP && \ - (!defined _MSC_VER || BOOST_VERSION >= 107000) + (!defined _MSC_VER || BOOST_VERSION >= 107000) && \ + (!defined _WIN32 || defined _WIN64) && \ + (BOOST_VERSION >= 108000 || (!defined _ARCH_PPC && !defined _ARCH_PPC64)) #define CGAL_USE_BOOST_MP 1 #include From 7e518c4511e1b5e3657ede9507b5258b64896d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 27 Feb 2024 11:57:16 +0100 Subject: [PATCH 099/139] do not add Core while computing dependencies --- Installation/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 10fd9e9888c9..fa2102ff7c00 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -940,7 +940,7 @@ if(CGAL_BRANCH_BUILD) set(compile_options "\ -${CMAKE_CXX_FLAGS} -DCGAL_EIGEN3_ENABLED -DCGAL_PROFILE -DCGAL_USE_CORE \ +${CMAKE_CXX_FLAGS} -DCGAL_EIGEN3_ENABLED -DCGAL_PROFILE \ ${Qt6Widgets_DEFINITIONS} ${Qt6OpenGL_DEFINITIONS} ${Qt6Gui_DEFINITIONS} \ ${Qt6OpenGL_EXECUTABLE_COMPILE_FLAGS} -fPIC \ ${Qt6Gui_EXECUTABLE_COMPILE_FLAGS} \ From 3b30756cd30baeef19bfb4188268c646dcd20920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 27 Feb 2024 14:46:18 +0100 Subject: [PATCH 100/139] do not depend on CGAL_Core --- .../Advancing_front_surface_reconstruction/dependencies | 1 - Alpha_shapes_2/package_info/Alpha_shapes_2/dependencies | 1 - Alpha_shapes_3/package_info/Alpha_shapes_3/dependencies | 1 - Alpha_wrap_3/package_info/Alpha_wrap_3/dependencies | 1 - .../package_info/Barycentric_coordinates_2/dependencies | 1 - .../package_info/Boolean_set_operations_2/dependencies | 1 - Combinatorial_map/package_info/Combinatorial_map/dependencies | 1 - .../package_info/Convex_decomposition_3/dependencies | 1 - Convex_hull_3/package_info/Convex_hull_3/dependencies | 1 - Filtered_kernel/package_info/Filtered_kernel/dependencies | 1 - Generalized_map/package_info/Generalized_map/dependencies | 1 - .../package_info/Linear_cell_complex/dependencies | 1 - Mesh_3/package_info/Mesh_3/dependencies | 1 - Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies | 1 - Minkowski_sum_3/package_info/Minkowski_sum_3/dependencies | 1 - Nef_3/package_info/Nef_3/dependencies | 1 - NewKernel_d/package_info/NewKernel_d/dependencies | 1 - .../package_info/Optimal_bounding_box/dependencies | 1 - Partition_2/package_info/Partition_2/dependencies | 1 - Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies | 1 - .../package_info/Periodic_3_triangulation_3/dependencies | 1 - .../package_info/Point_set_processing_3/dependencies | 1 - .../package_info/Poisson_surface_reconstruction_3/dependencies | 1 - .../package_info/Polygon_mesh_processing/dependencies | 1 - .../package_info/Polygonal_surface_reconstruction/dependencies | 1 - .../package_info/Polyline_simplification_2/dependencies | 1 - .../package_info/Polytope_distance_d/dependencies | 1 - SMDS_3/package_info/SMDS_3/dependencies | 1 - .../package_info/Scale_space_reconstruction_3/dependencies | 1 - .../package_info/Segment_Delaunay_graph_2/dependencies | 1 - .../package_info/Segment_Delaunay_graph_Linf_2/dependencies | 1 - Shape_detection/package_info/Shape_detection/dependencies | 1 - Skin_surface_3/package_info/Skin_surface_3/dependencies | 1 - Snap_rounding_2/package_info/Snap_rounding_2/dependencies | 1 - .../package_info/Surface_mesh_parameterization/dependencies | 1 - .../package_info/Surface_mesh_skeletonization/dependencies | 1 - .../package_info/Surface_mesh_topology/dependencies | 1 - Surface_mesher/package_info/Surface_mesher/dependencies | 1 - Surface_sweep_2/package_info/Surface_sweep_2/dependencies | 1 - .../package_info/Tetrahedral_remeshing/dependencies | 1 - Triangulation_2/package_info/Triangulation_2/dependencies | 1 - Triangulation_3/package_info/Triangulation_3/dependencies | 1 - Visibility_2/package_info/Visibility_2/dependencies | 1 - 43 files changed, 43 deletions(-) diff --git a/Advancing_front_surface_reconstruction/package_info/Advancing_front_surface_reconstruction/dependencies b/Advancing_front_surface_reconstruction/package_info/Advancing_front_surface_reconstruction/dependencies index d885997679a9..fffe4db3c74c 100644 --- a/Advancing_front_surface_reconstruction/package_info/Advancing_front_surface_reconstruction/dependencies +++ b/Advancing_front_surface_reconstruction/package_info/Advancing_front_surface_reconstruction/dependencies @@ -2,7 +2,6 @@ Advancing_front_surface_reconstruction Algebraic_foundations Arithmetic_kernel BGL -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Alpha_shapes_2/package_info/Alpha_shapes_2/dependencies b/Alpha_shapes_2/package_info/Alpha_shapes_2/dependencies index d9c0f7d94a82..6c1597376389 100644 --- a/Alpha_shapes_2/package_info/Alpha_shapes_2/dependencies +++ b/Alpha_shapes_2/package_info/Alpha_shapes_2/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Alpha_shapes_2 Arithmetic_kernel -CGAL_Core Cartesian_kernel Hash_map Homogeneous_kernel diff --git a/Alpha_shapes_3/package_info/Alpha_shapes_3/dependencies b/Alpha_shapes_3/package_info/Alpha_shapes_3/dependencies index 516a70a2bdeb..f0dc76c90d99 100644 --- a/Alpha_shapes_3/package_info/Alpha_shapes_3/dependencies +++ b/Alpha_shapes_3/package_info/Alpha_shapes_3/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Alpha_shapes_3 Arithmetic_kernel -CGAL_Core Cartesian_kernel Circulator Filtered_kernel diff --git a/Alpha_wrap_3/package_info/Alpha_wrap_3/dependencies b/Alpha_wrap_3/package_info/Alpha_wrap_3/dependencies index a3f60578532c..7645e1ba53c5 100644 --- a/Alpha_wrap_3/package_info/Alpha_wrap_3/dependencies +++ b/Alpha_wrap_3/package_info/Alpha_wrap_3/dependencies @@ -4,7 +4,6 @@ Alpha_wrap_3 Arithmetic_kernel BGL Box_intersection_d -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/dependencies b/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/dependencies index 1ea1e70b883e..ee1e1d6538ae 100644 --- a/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/dependencies +++ b/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/dependencies @@ -2,7 +2,6 @@ Algebraic_foundations Arithmetic_kernel BGL Barycentric_coordinates_2 -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Boolean_set_operations_2/package_info/Boolean_set_operations_2/dependencies b/Boolean_set_operations_2/package_info/Boolean_set_operations_2/dependencies index c5720a8c2b1f..a4d2b53c7b30 100644 --- a/Boolean_set_operations_2/package_info/Boolean_set_operations_2/dependencies +++ b/Boolean_set_operations_2/package_info/Boolean_set_operations_2/dependencies @@ -2,7 +2,6 @@ Algebraic_foundations Arithmetic_kernel Arrangement_on_surface_2 Boolean_set_operations_2 -CGAL_Core Cartesian_kernel Circular_kernel_2 Circulator diff --git a/Combinatorial_map/package_info/Combinatorial_map/dependencies b/Combinatorial_map/package_info/Combinatorial_map/dependencies index 0902e1798f1a..279a01a72ae2 100644 --- a/Combinatorial_map/package_info/Combinatorial_map/dependencies +++ b/Combinatorial_map/package_info/Combinatorial_map/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Arithmetic_kernel BGL -CGAL_Core Cartesian_kernel Circulator Combinatorial_map diff --git a/Convex_decomposition_3/package_info/Convex_decomposition_3/dependencies b/Convex_decomposition_3/package_info/Convex_decomposition_3/dependencies index 09382985c877..fa1556add87e 100644 --- a/Convex_decomposition_3/package_info/Convex_decomposition_3/dependencies +++ b/Convex_decomposition_3/package_info/Convex_decomposition_3/dependencies @@ -2,7 +2,6 @@ Algebraic_foundations Arithmetic_kernel BGL Box_intersection_d -CGAL_Core Cartesian_kernel Circulator Convex_decomposition_3 diff --git a/Convex_hull_3/package_info/Convex_hull_3/dependencies b/Convex_hull_3/package_info/Convex_hull_3/dependencies index bdd3aa15916c..406722ba9aff 100644 --- a/Convex_hull_3/package_info/Convex_hull_3/dependencies +++ b/Convex_hull_3/package_info/Convex_hull_3/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Arithmetic_kernel BGL -CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Filtered_kernel/package_info/Filtered_kernel/dependencies b/Filtered_kernel/package_info/Filtered_kernel/dependencies index 5e320e639525..4b009ce54e47 100644 --- a/Filtered_kernel/package_info/Filtered_kernel/dependencies +++ b/Filtered_kernel/package_info/Filtered_kernel/dependencies @@ -1,6 +1,5 @@ Algebraic_foundations Arithmetic_kernel -CGAL_Core Cartesian_kernel Distance_2 Distance_3 diff --git a/Generalized_map/package_info/Generalized_map/dependencies b/Generalized_map/package_info/Generalized_map/dependencies index 97e368892d5e..bf19ede8a16d 100644 --- a/Generalized_map/package_info/Generalized_map/dependencies +++ b/Generalized_map/package_info/Generalized_map/dependencies @@ -1,6 +1,5 @@ Algebraic_foundations Arithmetic_kernel -CGAL_Core Cartesian_kernel Circulator Combinatorial_map diff --git a/Linear_cell_complex/package_info/Linear_cell_complex/dependencies b/Linear_cell_complex/package_info/Linear_cell_complex/dependencies index a3ecaf39ee28..53e5ce3f1530 100644 --- a/Linear_cell_complex/package_info/Linear_cell_complex/dependencies +++ b/Linear_cell_complex/package_info/Linear_cell_complex/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Arithmetic_kernel BGL -CGAL_Core Cartesian_kernel Circulator Combinatorial_map diff --git a/Mesh_3/package_info/Mesh_3/dependencies b/Mesh_3/package_info/Mesh_3/dependencies index 0f9c65cd105b..65eec56b3606 100644 --- a/Mesh_3/package_info/Mesh_3/dependencies +++ b/Mesh_3/package_info/Mesh_3/dependencies @@ -2,7 +2,6 @@ AABB_tree Algebraic_foundations Arithmetic_kernel BGL -CGAL_Core CGAL_ImageIO Cartesian_kernel Circulator diff --git a/Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies b/Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies index a71a4c66f559..62f64c4bfd1c 100644 --- a/Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies +++ b/Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies @@ -3,7 +3,6 @@ Algebraic_foundations Arithmetic_kernel Arrangement_on_surface_2 Boolean_set_operations_2 -CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Minkowski_sum_3/package_info/Minkowski_sum_3/dependencies b/Minkowski_sum_3/package_info/Minkowski_sum_3/dependencies index b60f37e8338f..e2123abc9c96 100644 --- a/Minkowski_sum_3/package_info/Minkowski_sum_3/dependencies +++ b/Minkowski_sum_3/package_info/Minkowski_sum_3/dependencies @@ -2,7 +2,6 @@ Algebraic_foundations Arithmetic_kernel BGL Box_intersection_d -CGAL_Core Cartesian_kernel Circulator Convex_decomposition_3 diff --git a/Nef_3/package_info/Nef_3/dependencies b/Nef_3/package_info/Nef_3/dependencies index 92337ba55f10..7fec88e23734 100644 --- a/Nef_3/package_info/Nef_3/dependencies +++ b/Nef_3/package_info/Nef_3/dependencies @@ -2,7 +2,6 @@ Algebraic_foundations Arithmetic_kernel BGL Box_intersection_d -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/NewKernel_d/package_info/NewKernel_d/dependencies b/NewKernel_d/package_info/NewKernel_d/dependencies index bfb2e6e60407..04e1d32ff873 100644 --- a/NewKernel_d/package_info/NewKernel_d/dependencies +++ b/NewKernel_d/package_info/NewKernel_d/dependencies @@ -1,6 +1,5 @@ Algebraic_foundations Arithmetic_kernel -CGAL_Core Filtered_kernel Installation Interval_support diff --git a/Optimal_bounding_box/package_info/Optimal_bounding_box/dependencies b/Optimal_bounding_box/package_info/Optimal_bounding_box/dependencies index 37cb6893ab85..249760e29284 100644 --- a/Optimal_bounding_box/package_info/Optimal_bounding_box/dependencies +++ b/Optimal_bounding_box/package_info/Optimal_bounding_box/dependencies @@ -2,7 +2,6 @@ Algebraic_foundations Arithmetic_kernel BGL Bounding_volumes -CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Partition_2/package_info/Partition_2/dependencies b/Partition_2/package_info/Partition_2/dependencies index 2d383a64c885..0d4ee19ad2b1 100644 --- a/Partition_2/package_info/Partition_2/dependencies +++ b/Partition_2/package_info/Partition_2/dependencies @@ -1,6 +1,5 @@ Algebraic_foundations Arithmetic_kernel -CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies b/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies index bd1fc7bd057f..eb2b8e24cc3a 100644 --- a/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies +++ b/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Arithmetic_kernel BGL -CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Periodic_3_triangulation_3/package_info/Periodic_3_triangulation_3/dependencies b/Periodic_3_triangulation_3/package_info/Periodic_3_triangulation_3/dependencies index 619cafd06060..b31b936ff044 100644 --- a/Periodic_3_triangulation_3/package_info/Periodic_3_triangulation_3/dependencies +++ b/Periodic_3_triangulation_3/package_info/Periodic_3_triangulation_3/dependencies @@ -1,6 +1,5 @@ Algebraic_foundations Arithmetic_kernel -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Point_set_processing_3/package_info/Point_set_processing_3/dependencies b/Point_set_processing_3/package_info/Point_set_processing_3/dependencies index 3d33ad32a3e6..dcdadf3e8dcc 100644 --- a/Point_set_processing_3/package_info/Point_set_processing_3/dependencies +++ b/Point_set_processing_3/package_info/Point_set_processing_3/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Arithmetic_kernel BGL -CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Poisson_surface_reconstruction_3/package_info/Poisson_surface_reconstruction_3/dependencies b/Poisson_surface_reconstruction_3/package_info/Poisson_surface_reconstruction_3/dependencies index e8a4a934cd68..5c532a3d624e 100644 --- a/Poisson_surface_reconstruction_3/package_info/Poisson_surface_reconstruction_3/dependencies +++ b/Poisson_surface_reconstruction_3/package_info/Poisson_surface_reconstruction_3/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Arithmetic_kernel BGL -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Polygon_mesh_processing/package_info/Polygon_mesh_processing/dependencies b/Polygon_mesh_processing/package_info/Polygon_mesh_processing/dependencies index f44718e3c9bc..6d471658093c 100644 --- a/Polygon_mesh_processing/package_info/Polygon_mesh_processing/dependencies +++ b/Polygon_mesh_processing/package_info/Polygon_mesh_processing/dependencies @@ -3,7 +3,6 @@ Algebraic_foundations Arithmetic_kernel BGL Box_intersection_d -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies b/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies index 81348d73583c..650e4a65343e 100644 --- a/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies +++ b/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies @@ -2,7 +2,6 @@ Algebraic_foundations Alpha_shapes_2 Arithmetic_kernel BGL -CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Polyline_simplification_2/package_info/Polyline_simplification_2/dependencies b/Polyline_simplification_2/package_info/Polyline_simplification_2/dependencies index b1e47ef32221..46b60927a441 100644 --- a/Polyline_simplification_2/package_info/Polyline_simplification_2/dependencies +++ b/Polyline_simplification_2/package_info/Polyline_simplification_2/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Arithmetic_kernel BGL -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Polytope_distance_d/package_info/Polytope_distance_d/dependencies b/Polytope_distance_d/package_info/Polytope_distance_d/dependencies index 4b0007880c16..2ec81fe38f8a 100644 --- a/Polytope_distance_d/package_info/Polytope_distance_d/dependencies +++ b/Polytope_distance_d/package_info/Polytope_distance_d/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Arithmetic_kernel BGL -CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/SMDS_3/package_info/SMDS_3/dependencies b/SMDS_3/package_info/SMDS_3/dependencies index 749f4764b554..bebf22165bb0 100644 --- a/SMDS_3/package_info/SMDS_3/dependencies +++ b/SMDS_3/package_info/SMDS_3/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Arithmetic_kernel BGL -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Scale_space_reconstruction_3/package_info/Scale_space_reconstruction_3/dependencies b/Scale_space_reconstruction_3/package_info/Scale_space_reconstruction_3/dependencies index 4582cf68fe68..114d4ba5acdb 100644 --- a/Scale_space_reconstruction_3/package_info/Scale_space_reconstruction_3/dependencies +++ b/Scale_space_reconstruction_3/package_info/Scale_space_reconstruction_3/dependencies @@ -3,7 +3,6 @@ Algebraic_foundations Alpha_shapes_3 Arithmetic_kernel BGL -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Segment_Delaunay_graph_2/package_info/Segment_Delaunay_graph_2/dependencies b/Segment_Delaunay_graph_2/package_info/Segment_Delaunay_graph_2/dependencies index 62981bc0f230..c3083729fefd 100644 --- a/Segment_Delaunay_graph_2/package_info/Segment_Delaunay_graph_2/dependencies +++ b/Segment_Delaunay_graph_2/package_info/Segment_Delaunay_graph_2/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Apollonius_graph_2 Arithmetic_kernel -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Segment_Delaunay_graph_Linf_2/package_info/Segment_Delaunay_graph_Linf_2/dependencies b/Segment_Delaunay_graph_Linf_2/package_info/Segment_Delaunay_graph_Linf_2/dependencies index d680be9c38d5..783d3ee4cb25 100644 --- a/Segment_Delaunay_graph_Linf_2/package_info/Segment_Delaunay_graph_Linf_2/dependencies +++ b/Segment_Delaunay_graph_Linf_2/package_info/Segment_Delaunay_graph_Linf_2/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Apollonius_graph_2 Arithmetic_kernel -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Shape_detection/package_info/Shape_detection/dependencies b/Shape_detection/package_info/Shape_detection/dependencies index 26fdaaadd2f5..63e6337e4fbf 100644 --- a/Shape_detection/package_info/Shape_detection/dependencies +++ b/Shape_detection/package_info/Shape_detection/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Arithmetic_kernel BGL -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Skin_surface_3/package_info/Skin_surface_3/dependencies b/Skin_surface_3/package_info/Skin_surface_3/dependencies index e04beb03945c..fb635c6334cc 100644 --- a/Skin_surface_3/package_info/Skin_surface_3/dependencies +++ b/Skin_surface_3/package_info/Skin_surface_3/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Arithmetic_kernel BGL -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Snap_rounding_2/package_info/Snap_rounding_2/dependencies b/Snap_rounding_2/package_info/Snap_rounding_2/dependencies index 9b654c5c0ccd..2d53f573e0d6 100644 --- a/Snap_rounding_2/package_info/Snap_rounding_2/dependencies +++ b/Snap_rounding_2/package_info/Snap_rounding_2/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Arithmetic_kernel Arrangement_on_surface_2 -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Surface_mesh_parameterization/package_info/Surface_mesh_parameterization/dependencies b/Surface_mesh_parameterization/package_info/Surface_mesh_parameterization/dependencies index 8acc07edef06..19c7b2f79832 100644 --- a/Surface_mesh_parameterization/package_info/Surface_mesh_parameterization/dependencies +++ b/Surface_mesh_parameterization/package_info/Surface_mesh_parameterization/dependencies @@ -2,7 +2,6 @@ Algebraic_foundations Arithmetic_kernel BGL Box_intersection_d -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Surface_mesh_skeletonization/package_info/Surface_mesh_skeletonization/dependencies b/Surface_mesh_skeletonization/package_info/Surface_mesh_skeletonization/dependencies index cea4bd48a905..93a216163663 100644 --- a/Surface_mesh_skeletonization/package_info/Surface_mesh_skeletonization/dependencies +++ b/Surface_mesh_skeletonization/package_info/Surface_mesh_skeletonization/dependencies @@ -2,7 +2,6 @@ AABB_tree Algebraic_foundations Arithmetic_kernel BGL -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Surface_mesh_topology/package_info/Surface_mesh_topology/dependencies b/Surface_mesh_topology/package_info/Surface_mesh_topology/dependencies index 91f6a41ad104..dc2f511d1b24 100644 --- a/Surface_mesh_topology/package_info/Surface_mesh_topology/dependencies +++ b/Surface_mesh_topology/package_info/Surface_mesh_topology/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Arithmetic_kernel BGL -CGAL_Core Cartesian_kernel Circulator Combinatorial_map diff --git a/Surface_mesher/package_info/Surface_mesher/dependencies b/Surface_mesher/package_info/Surface_mesher/dependencies index bfe6c4d3548e..e6e8a3909664 100644 --- a/Surface_mesher/package_info/Surface_mesher/dependencies +++ b/Surface_mesher/package_info/Surface_mesher/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Arithmetic_kernel BGL -CGAL_Core CGAL_ImageIO Cartesian_kernel Circulator diff --git a/Surface_sweep_2/package_info/Surface_sweep_2/dependencies b/Surface_sweep_2/package_info/Surface_sweep_2/dependencies index 1a04d474a621..09546686abf3 100644 --- a/Surface_sweep_2/package_info/Surface_sweep_2/dependencies +++ b/Surface_sweep_2/package_info/Surface_sweep_2/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Arithmetic_kernel Arrangement_on_surface_2 -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Tetrahedral_remeshing/package_info/Tetrahedral_remeshing/dependencies b/Tetrahedral_remeshing/package_info/Tetrahedral_remeshing/dependencies index f9c578d62a23..d9c5098d64f6 100644 --- a/Tetrahedral_remeshing/package_info/Tetrahedral_remeshing/dependencies +++ b/Tetrahedral_remeshing/package_info/Tetrahedral_remeshing/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Arithmetic_kernel BGL -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Triangulation_2/package_info/Triangulation_2/dependencies b/Triangulation_2/package_info/Triangulation_2/dependencies index e5682c455234..c8d90b721ca3 100644 --- a/Triangulation_2/package_info/Triangulation_2/dependencies +++ b/Triangulation_2/package_info/Triangulation_2/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Arithmetic_kernel BGL -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Triangulation_3/package_info/Triangulation_3/dependencies b/Triangulation_3/package_info/Triangulation_3/dependencies index 15e6860497ea..a68982ddaa59 100644 --- a/Triangulation_3/package_info/Triangulation_3/dependencies +++ b/Triangulation_3/package_info/Triangulation_3/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Arithmetic_kernel BGL -CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Visibility_2/package_info/Visibility_2/dependencies b/Visibility_2/package_info/Visibility_2/dependencies index 2199ba4f76d3..e8367c224170 100644 --- a/Visibility_2/package_info/Visibility_2/dependencies +++ b/Visibility_2/package_info/Visibility_2/dependencies @@ -1,7 +1,6 @@ Algebraic_foundations Arithmetic_kernel Arrangement_on_surface_2 -CGAL_Core Cartesian_kernel Circulator Distance_2 From 910945eb5fc1326148049e4d49c55f780faa2f6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 27 Feb 2024 16:19:28 +0100 Subject: [PATCH 101/139] undo dependency changes + always use core if not disabled --- .../CGAL/Installation/internal/enable_third_party_libraries.h | 4 ++++ .../package_info/Linear_cell_complex/dependencies | 1 + Mesh_3/package_info/Mesh_3/dependencies | 1 + Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies | 1 + Minkowski_sum_3/package_info/Minkowski_sum_3/dependencies | 1 + Nef_3/package_info/Nef_3/dependencies | 1 + NewKernel_d/package_info/NewKernel_d/dependencies | 1 + .../package_info/Optimal_bounding_box/dependencies | 1 + Partition_2/package_info/Partition_2/dependencies | 1 + Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies | 1 + .../package_info/Periodic_3_triangulation_3/dependencies | 1 + .../package_info/Point_set_processing_3/dependencies | 1 + .../Poisson_surface_reconstruction_3/dependencies | 1 + .../package_info/Polygon_mesh_processing/dependencies | 1 + .../Polygonal_surface_reconstruction/dependencies | 3 ++- .../package_info/Polyline_simplification_2/dependencies | 1 + .../package_info/Polytope_distance_d/dependencies | 1 + SMDS_3/package_info/SMDS_3/dependencies | 1 + .../package_info/Scale_space_reconstruction_3/dependencies | 1 + .../package_info/Segment_Delaunay_graph_2/dependencies | 1 + .../package_info/Segment_Delaunay_graph_Linf_2/dependencies | 1 + Shape_detection/package_info/Shape_detection/dependencies | 1 + Skin_surface_3/package_info/Skin_surface_3/dependencies | 1 + Snap_rounding_2/package_info/Snap_rounding_2/dependencies | 1 + .../package_info/Surface_mesh_parameterization/dependencies | 1 + .../package_info/Surface_mesh_skeletonization/dependencies | 1 + .../package_info/Surface_mesh_topology/dependencies | 1 + Surface_mesher/package_info/Surface_mesher/dependencies | 1 + Surface_sweep_2/package_info/Surface_sweep_2/dependencies | 1 + .../package_info/Tetrahedral_remeshing/dependencies | 1 + Triangulation_2/package_info/Triangulation_2/dependencies | 1 + Triangulation_3/package_info/Triangulation_3/dependencies | 1 + .../package_info/Triangulation_on_sphere_2/dependencies | 1 + Visibility_2/package_info/Visibility_2/dependencies | 1 + 34 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h b/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h index 374a09b26334..f241cc6130c3 100644 --- a/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h +++ b/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h @@ -35,4 +35,8 @@ # endif // CGAL_USE_MPFR and no #endif // __has_include +#if ! CGAL_NO_CORE +# define CGAL_USE_CORE 1 +#endif + #endif // CGAL_INTERNAL_ENABLE_THIRD_PARTY_LIBRARIES_H diff --git a/Linear_cell_complex/package_info/Linear_cell_complex/dependencies b/Linear_cell_complex/package_info/Linear_cell_complex/dependencies index 53e5ce3f1530..a3ecaf39ee28 100644 --- a/Linear_cell_complex/package_info/Linear_cell_complex/dependencies +++ b/Linear_cell_complex/package_info/Linear_cell_complex/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Combinatorial_map diff --git a/Mesh_3/package_info/Mesh_3/dependencies b/Mesh_3/package_info/Mesh_3/dependencies index 65eec56b3606..0f9c65cd105b 100644 --- a/Mesh_3/package_info/Mesh_3/dependencies +++ b/Mesh_3/package_info/Mesh_3/dependencies @@ -2,6 +2,7 @@ AABB_tree Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core CGAL_ImageIO Cartesian_kernel Circulator diff --git a/Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies b/Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies index 62f64c4bfd1c..a71a4c66f559 100644 --- a/Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies +++ b/Minkowski_sum_2/package_info/Minkowski_sum_2/dependencies @@ -3,6 +3,7 @@ Algebraic_foundations Arithmetic_kernel Arrangement_on_surface_2 Boolean_set_operations_2 +CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Minkowski_sum_3/package_info/Minkowski_sum_3/dependencies b/Minkowski_sum_3/package_info/Minkowski_sum_3/dependencies index e2123abc9c96..b60f37e8338f 100644 --- a/Minkowski_sum_3/package_info/Minkowski_sum_3/dependencies +++ b/Minkowski_sum_3/package_info/Minkowski_sum_3/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Arithmetic_kernel BGL Box_intersection_d +CGAL_Core Cartesian_kernel Circulator Convex_decomposition_3 diff --git a/Nef_3/package_info/Nef_3/dependencies b/Nef_3/package_info/Nef_3/dependencies index 7fec88e23734..92337ba55f10 100644 --- a/Nef_3/package_info/Nef_3/dependencies +++ b/Nef_3/package_info/Nef_3/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Arithmetic_kernel BGL Box_intersection_d +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/NewKernel_d/package_info/NewKernel_d/dependencies b/NewKernel_d/package_info/NewKernel_d/dependencies index 04e1d32ff873..bfb2e6e60407 100644 --- a/NewKernel_d/package_info/NewKernel_d/dependencies +++ b/NewKernel_d/package_info/NewKernel_d/dependencies @@ -1,5 +1,6 @@ Algebraic_foundations Arithmetic_kernel +CGAL_Core Filtered_kernel Installation Interval_support diff --git a/Optimal_bounding_box/package_info/Optimal_bounding_box/dependencies b/Optimal_bounding_box/package_info/Optimal_bounding_box/dependencies index 249760e29284..37cb6893ab85 100644 --- a/Optimal_bounding_box/package_info/Optimal_bounding_box/dependencies +++ b/Optimal_bounding_box/package_info/Optimal_bounding_box/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Arithmetic_kernel BGL Bounding_volumes +CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Partition_2/package_info/Partition_2/dependencies b/Partition_2/package_info/Partition_2/dependencies index 0d4ee19ad2b1..2d383a64c885 100644 --- a/Partition_2/package_info/Partition_2/dependencies +++ b/Partition_2/package_info/Partition_2/dependencies @@ -1,5 +1,6 @@ Algebraic_foundations Arithmetic_kernel +CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies b/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies index eb2b8e24cc3a..bd1fc7bd057f 100644 --- a/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies +++ b/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Periodic_3_triangulation_3/package_info/Periodic_3_triangulation_3/dependencies b/Periodic_3_triangulation_3/package_info/Periodic_3_triangulation_3/dependencies index b31b936ff044..619cafd06060 100644 --- a/Periodic_3_triangulation_3/package_info/Periodic_3_triangulation_3/dependencies +++ b/Periodic_3_triangulation_3/package_info/Periodic_3_triangulation_3/dependencies @@ -1,5 +1,6 @@ Algebraic_foundations Arithmetic_kernel +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Point_set_processing_3/package_info/Point_set_processing_3/dependencies b/Point_set_processing_3/package_info/Point_set_processing_3/dependencies index dcdadf3e8dcc..3d33ad32a3e6 100644 --- a/Point_set_processing_3/package_info/Point_set_processing_3/dependencies +++ b/Point_set_processing_3/package_info/Point_set_processing_3/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Poisson_surface_reconstruction_3/package_info/Poisson_surface_reconstruction_3/dependencies b/Poisson_surface_reconstruction_3/package_info/Poisson_surface_reconstruction_3/dependencies index 5c532a3d624e..e8a4a934cd68 100644 --- a/Poisson_surface_reconstruction_3/package_info/Poisson_surface_reconstruction_3/dependencies +++ b/Poisson_surface_reconstruction_3/package_info/Poisson_surface_reconstruction_3/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Polygon_mesh_processing/package_info/Polygon_mesh_processing/dependencies b/Polygon_mesh_processing/package_info/Polygon_mesh_processing/dependencies index 6d471658093c..f44718e3c9bc 100644 --- a/Polygon_mesh_processing/package_info/Polygon_mesh_processing/dependencies +++ b/Polygon_mesh_processing/package_info/Polygon_mesh_processing/dependencies @@ -3,6 +3,7 @@ Algebraic_foundations Arithmetic_kernel BGL Box_intersection_d +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies b/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies index 650e4a65343e..dfaa76af3a57 100644 --- a/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies +++ b/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Alpha_shapes_2 Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Convex_hull_2 @@ -21,8 +22,8 @@ Number_types Point_set_3 Point_set_processing_3 Polygon -Polygonal_surface_reconstruction Polygon_mesh_processing +Polygonal_surface_reconstruction Principal_component_analysis Principal_component_analysis_LGPL Profiling_tools diff --git a/Polyline_simplification_2/package_info/Polyline_simplification_2/dependencies b/Polyline_simplification_2/package_info/Polyline_simplification_2/dependencies index 46b60927a441..b1e47ef32221 100644 --- a/Polyline_simplification_2/package_info/Polyline_simplification_2/dependencies +++ b/Polyline_simplification_2/package_info/Polyline_simplification_2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Polytope_distance_d/package_info/Polytope_distance_d/dependencies b/Polytope_distance_d/package_info/Polytope_distance_d/dependencies index 2ec81fe38f8a..4b0007880c16 100644 --- a/Polytope_distance_d/package_info/Polytope_distance_d/dependencies +++ b/Polytope_distance_d/package_info/Polytope_distance_d/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/SMDS_3/package_info/SMDS_3/dependencies b/SMDS_3/package_info/SMDS_3/dependencies index bebf22165bb0..749f4764b554 100644 --- a/SMDS_3/package_info/SMDS_3/dependencies +++ b/SMDS_3/package_info/SMDS_3/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Scale_space_reconstruction_3/package_info/Scale_space_reconstruction_3/dependencies b/Scale_space_reconstruction_3/package_info/Scale_space_reconstruction_3/dependencies index 114d4ba5acdb..4582cf68fe68 100644 --- a/Scale_space_reconstruction_3/package_info/Scale_space_reconstruction_3/dependencies +++ b/Scale_space_reconstruction_3/package_info/Scale_space_reconstruction_3/dependencies @@ -3,6 +3,7 @@ Algebraic_foundations Alpha_shapes_3 Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Segment_Delaunay_graph_2/package_info/Segment_Delaunay_graph_2/dependencies b/Segment_Delaunay_graph_2/package_info/Segment_Delaunay_graph_2/dependencies index c3083729fefd..62981bc0f230 100644 --- a/Segment_Delaunay_graph_2/package_info/Segment_Delaunay_graph_2/dependencies +++ b/Segment_Delaunay_graph_2/package_info/Segment_Delaunay_graph_2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Apollonius_graph_2 Arithmetic_kernel +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Segment_Delaunay_graph_Linf_2/package_info/Segment_Delaunay_graph_Linf_2/dependencies b/Segment_Delaunay_graph_Linf_2/package_info/Segment_Delaunay_graph_Linf_2/dependencies index 783d3ee4cb25..d680be9c38d5 100644 --- a/Segment_Delaunay_graph_Linf_2/package_info/Segment_Delaunay_graph_Linf_2/dependencies +++ b/Segment_Delaunay_graph_Linf_2/package_info/Segment_Delaunay_graph_Linf_2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Apollonius_graph_2 Arithmetic_kernel +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Shape_detection/package_info/Shape_detection/dependencies b/Shape_detection/package_info/Shape_detection/dependencies index 63e6337e4fbf..26fdaaadd2f5 100644 --- a/Shape_detection/package_info/Shape_detection/dependencies +++ b/Shape_detection/package_info/Shape_detection/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Skin_surface_3/package_info/Skin_surface_3/dependencies b/Skin_surface_3/package_info/Skin_surface_3/dependencies index fb635c6334cc..e04beb03945c 100644 --- a/Skin_surface_3/package_info/Skin_surface_3/dependencies +++ b/Skin_surface_3/package_info/Skin_surface_3/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Snap_rounding_2/package_info/Snap_rounding_2/dependencies b/Snap_rounding_2/package_info/Snap_rounding_2/dependencies index 2d53f573e0d6..9b654c5c0ccd 100644 --- a/Snap_rounding_2/package_info/Snap_rounding_2/dependencies +++ b/Snap_rounding_2/package_info/Snap_rounding_2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel Arrangement_on_surface_2 +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Surface_mesh_parameterization/package_info/Surface_mesh_parameterization/dependencies b/Surface_mesh_parameterization/package_info/Surface_mesh_parameterization/dependencies index 19c7b2f79832..8acc07edef06 100644 --- a/Surface_mesh_parameterization/package_info/Surface_mesh_parameterization/dependencies +++ b/Surface_mesh_parameterization/package_info/Surface_mesh_parameterization/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Arithmetic_kernel BGL Box_intersection_d +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Surface_mesh_skeletonization/package_info/Surface_mesh_skeletonization/dependencies b/Surface_mesh_skeletonization/package_info/Surface_mesh_skeletonization/dependencies index 93a216163663..cea4bd48a905 100644 --- a/Surface_mesh_skeletonization/package_info/Surface_mesh_skeletonization/dependencies +++ b/Surface_mesh_skeletonization/package_info/Surface_mesh_skeletonization/dependencies @@ -2,6 +2,7 @@ AABB_tree Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Surface_mesh_topology/package_info/Surface_mesh_topology/dependencies b/Surface_mesh_topology/package_info/Surface_mesh_topology/dependencies index dc2f511d1b24..91f6a41ad104 100644 --- a/Surface_mesh_topology/package_info/Surface_mesh_topology/dependencies +++ b/Surface_mesh_topology/package_info/Surface_mesh_topology/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Combinatorial_map diff --git a/Surface_mesher/package_info/Surface_mesher/dependencies b/Surface_mesher/package_info/Surface_mesher/dependencies index e6e8a3909664..bfe6c4d3548e 100644 --- a/Surface_mesher/package_info/Surface_mesher/dependencies +++ b/Surface_mesher/package_info/Surface_mesher/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core CGAL_ImageIO Cartesian_kernel Circulator diff --git a/Surface_sweep_2/package_info/Surface_sweep_2/dependencies b/Surface_sweep_2/package_info/Surface_sweep_2/dependencies index 09546686abf3..1a04d474a621 100644 --- a/Surface_sweep_2/package_info/Surface_sweep_2/dependencies +++ b/Surface_sweep_2/package_info/Surface_sweep_2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel Arrangement_on_surface_2 +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Tetrahedral_remeshing/package_info/Tetrahedral_remeshing/dependencies b/Tetrahedral_remeshing/package_info/Tetrahedral_remeshing/dependencies index d9c5098d64f6..f9c578d62a23 100644 --- a/Tetrahedral_remeshing/package_info/Tetrahedral_remeshing/dependencies +++ b/Tetrahedral_remeshing/package_info/Tetrahedral_remeshing/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Triangulation_2/package_info/Triangulation_2/dependencies b/Triangulation_2/package_info/Triangulation_2/dependencies index c8d90b721ca3..e5682c455234 100644 --- a/Triangulation_2/package_info/Triangulation_2/dependencies +++ b/Triangulation_2/package_info/Triangulation_2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Triangulation_3/package_info/Triangulation_3/dependencies b/Triangulation_3/package_info/Triangulation_3/dependencies index a68982ddaa59..15e6860497ea 100644 --- a/Triangulation_3/package_info/Triangulation_3/dependencies +++ b/Triangulation_3/package_info/Triangulation_3/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Triangulation_on_sphere_2/package_info/Triangulation_on_sphere_2/dependencies b/Triangulation_on_sphere_2/package_info/Triangulation_on_sphere_2/dependencies index 5b77a741e4d0..bf3594adb9b4 100644 --- a/Triangulation_on_sphere_2/package_info/Triangulation_on_sphere_2/dependencies +++ b/Triangulation_on_sphere_2/package_info/Triangulation_on_sphere_2/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Algebraic_kernel_for_spheres Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circular_kernel_3 Circulator diff --git a/Visibility_2/package_info/Visibility_2/dependencies b/Visibility_2/package_info/Visibility_2/dependencies index e8367c224170..2199ba4f76d3 100644 --- a/Visibility_2/package_info/Visibility_2/dependencies +++ b/Visibility_2/package_info/Visibility_2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel Arrangement_on_surface_2 +CGAL_Core Cartesian_kernel Circulator Distance_2 From 647d26edaf73a5dee059226fc4bba87f5c1f7184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 27 Feb 2024 17:55:05 +0100 Subject: [PATCH 102/139] actually core is now needed as it extends the gmp/boost arithmetic kernel --- .../Advancing_front_surface_reconstruction/dependencies | 1 + .../package_info/Algebraic_kernel_for_circles/dependencies | 1 + .../package_info/Algebraic_kernel_for_spheres/dependencies | 1 + Alpha_shapes_2/package_info/Alpha_shapes_2/dependencies | 1 + Alpha_shapes_3/package_info/Alpha_shapes_3/dependencies | 1 + Alpha_wrap_3/package_info/Alpha_wrap_3/dependencies | 1 + .../package_info/Barycentric_coordinates_2/dependencies | 1 + .../package_info/Boolean_set_operations_2/dependencies | 1 + Circular_kernel_2/package_info/Circular_kernel_2/dependencies | 1 + Circular_kernel_3/package_info/Circular_kernel_3/dependencies | 1 + Combinatorial_map/package_info/Combinatorial_map/dependencies | 1 + .../package_info/Convex_decomposition_3/dependencies | 1 + Convex_hull_3/package_info/Convex_hull_3/dependencies | 1 + Envelope_3/package_info/Envelope_3/dependencies | 1 + Filtered_kernel/package_info/Filtered_kernel/dependencies | 1 + Generalized_map/package_info/Generalized_map/dependencies | 1 + 16 files changed, 16 insertions(+) diff --git a/Advancing_front_surface_reconstruction/package_info/Advancing_front_surface_reconstruction/dependencies b/Advancing_front_surface_reconstruction/package_info/Advancing_front_surface_reconstruction/dependencies index fffe4db3c74c..d885997679a9 100644 --- a/Advancing_front_surface_reconstruction/package_info/Advancing_front_surface_reconstruction/dependencies +++ b/Advancing_front_surface_reconstruction/package_info/Advancing_front_surface_reconstruction/dependencies @@ -2,6 +2,7 @@ Advancing_front_surface_reconstruction Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Algebraic_kernel_for_circles/package_info/Algebraic_kernel_for_circles/dependencies b/Algebraic_kernel_for_circles/package_info/Algebraic_kernel_for_circles/dependencies index 8d3b893eeb2b..2345a7f06d44 100644 --- a/Algebraic_kernel_for_circles/package_info/Algebraic_kernel_for_circles/dependencies +++ b/Algebraic_kernel_for_circles/package_info/Algebraic_kernel_for_circles/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Algebraic_kernel_for_circles Arithmetic_kernel +CGAL_Core Filtered_kernel Installation Interval_support diff --git a/Algebraic_kernel_for_spheres/package_info/Algebraic_kernel_for_spheres/dependencies b/Algebraic_kernel_for_spheres/package_info/Algebraic_kernel_for_spheres/dependencies index bfe13a407f4a..e9b3846ab795 100644 --- a/Algebraic_kernel_for_spheres/package_info/Algebraic_kernel_for_spheres/dependencies +++ b/Algebraic_kernel_for_spheres/package_info/Algebraic_kernel_for_spheres/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Algebraic_kernel_for_spheres Arithmetic_kernel +CGAL_Core Filtered_kernel Installation Interval_support diff --git a/Alpha_shapes_2/package_info/Alpha_shapes_2/dependencies b/Alpha_shapes_2/package_info/Alpha_shapes_2/dependencies index 6c1597376389..d9c0f7d94a82 100644 --- a/Alpha_shapes_2/package_info/Alpha_shapes_2/dependencies +++ b/Alpha_shapes_2/package_info/Alpha_shapes_2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Alpha_shapes_2 Arithmetic_kernel +CGAL_Core Cartesian_kernel Hash_map Homogeneous_kernel diff --git a/Alpha_shapes_3/package_info/Alpha_shapes_3/dependencies b/Alpha_shapes_3/package_info/Alpha_shapes_3/dependencies index f0dc76c90d99..516a70a2bdeb 100644 --- a/Alpha_shapes_3/package_info/Alpha_shapes_3/dependencies +++ b/Alpha_shapes_3/package_info/Alpha_shapes_3/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Alpha_shapes_3 Arithmetic_kernel +CGAL_Core Cartesian_kernel Circulator Filtered_kernel diff --git a/Alpha_wrap_3/package_info/Alpha_wrap_3/dependencies b/Alpha_wrap_3/package_info/Alpha_wrap_3/dependencies index 7645e1ba53c5..a3f60578532c 100644 --- a/Alpha_wrap_3/package_info/Alpha_wrap_3/dependencies +++ b/Alpha_wrap_3/package_info/Alpha_wrap_3/dependencies @@ -4,6 +4,7 @@ Alpha_wrap_3 Arithmetic_kernel BGL Box_intersection_d +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/dependencies b/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/dependencies index ee1e1d6538ae..1ea1e70b883e 100644 --- a/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/dependencies +++ b/Barycentric_coordinates_2/package_info/Barycentric_coordinates_2/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Arithmetic_kernel BGL Barycentric_coordinates_2 +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Boolean_set_operations_2/package_info/Boolean_set_operations_2/dependencies b/Boolean_set_operations_2/package_info/Boolean_set_operations_2/dependencies index a4d2b53c7b30..c5720a8c2b1f 100644 --- a/Boolean_set_operations_2/package_info/Boolean_set_operations_2/dependencies +++ b/Boolean_set_operations_2/package_info/Boolean_set_operations_2/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Arithmetic_kernel Arrangement_on_surface_2 Boolean_set_operations_2 +CGAL_Core Cartesian_kernel Circular_kernel_2 Circulator diff --git a/Circular_kernel_2/package_info/Circular_kernel_2/dependencies b/Circular_kernel_2/package_info/Circular_kernel_2/dependencies index ffbd888bc135..2621ba85ea7c 100644 --- a/Circular_kernel_2/package_info/Circular_kernel_2/dependencies +++ b/Circular_kernel_2/package_info/Circular_kernel_2/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Algebraic_kernel_for_circles Arithmetic_kernel +CGAL_Core Cartesian_kernel Circular_kernel_2 Distance_2 diff --git a/Circular_kernel_3/package_info/Circular_kernel_3/dependencies b/Circular_kernel_3/package_info/Circular_kernel_3/dependencies index dfceb904b448..476a5513bf01 100644 --- a/Circular_kernel_3/package_info/Circular_kernel_3/dependencies +++ b/Circular_kernel_3/package_info/Circular_kernel_3/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Algebraic_kernel_for_spheres Arithmetic_kernel +CGAL_Core Cartesian_kernel Circular_kernel_3 Distance_2 diff --git a/Combinatorial_map/package_info/Combinatorial_map/dependencies b/Combinatorial_map/package_info/Combinatorial_map/dependencies index 279a01a72ae2..0902e1798f1a 100644 --- a/Combinatorial_map/package_info/Combinatorial_map/dependencies +++ b/Combinatorial_map/package_info/Combinatorial_map/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Combinatorial_map diff --git a/Convex_decomposition_3/package_info/Convex_decomposition_3/dependencies b/Convex_decomposition_3/package_info/Convex_decomposition_3/dependencies index fa1556add87e..09382985c877 100644 --- a/Convex_decomposition_3/package_info/Convex_decomposition_3/dependencies +++ b/Convex_decomposition_3/package_info/Convex_decomposition_3/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Arithmetic_kernel BGL Box_intersection_d +CGAL_Core Cartesian_kernel Circulator Convex_decomposition_3 diff --git a/Convex_hull_3/package_info/Convex_hull_3/dependencies b/Convex_hull_3/package_info/Convex_hull_3/dependencies index 406722ba9aff..bdd3aa15916c 100644 --- a/Convex_hull_3/package_info/Convex_hull_3/dependencies +++ b/Convex_hull_3/package_info/Convex_hull_3/dependencies @@ -1,6 +1,7 @@ Algebraic_foundations Arithmetic_kernel BGL +CGAL_Core Cartesian_kernel Circulator Convex_hull_2 diff --git a/Envelope_3/package_info/Envelope_3/dependencies b/Envelope_3/package_info/Envelope_3/dependencies index 5abc02d0186e..8b0ee9f9511a 100644 --- a/Envelope_3/package_info/Envelope_3/dependencies +++ b/Envelope_3/package_info/Envelope_3/dependencies @@ -2,6 +2,7 @@ Algebraic_foundations Apollonius_graph_2 Arithmetic_kernel Arrangement_on_surface_2 +CGAL_Core Cartesian_kernel Circulator Distance_2 diff --git a/Filtered_kernel/package_info/Filtered_kernel/dependencies b/Filtered_kernel/package_info/Filtered_kernel/dependencies index 4b009ce54e47..5e320e639525 100644 --- a/Filtered_kernel/package_info/Filtered_kernel/dependencies +++ b/Filtered_kernel/package_info/Filtered_kernel/dependencies @@ -1,5 +1,6 @@ Algebraic_foundations Arithmetic_kernel +CGAL_Core Cartesian_kernel Distance_2 Distance_3 diff --git a/Generalized_map/package_info/Generalized_map/dependencies b/Generalized_map/package_info/Generalized_map/dependencies index bf19ede8a16d..97e368892d5e 100644 --- a/Generalized_map/package_info/Generalized_map/dependencies +++ b/Generalized_map/package_info/Generalized_map/dependencies @@ -1,5 +1,6 @@ Algebraic_foundations Arithmetic_kernel +CGAL_Core Cartesian_kernel Circulator Combinatorial_map From c9c089ccc14a7bc3183086e13d2672193d83f268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 28 Feb 2024 11:38:56 +0100 Subject: [PATCH 103/139] remove GMP specific files and hide GMP specific code --- CGAL_Core/include/CGAL/CORE/BigInt.h | 1 - CGAL_Core/include/CGAL/CORE/CoreAux_impl.h | 1 - CGAL_Core/include/CGAL/CORE/Gmp.h | 37 --- CGAL_Core/include/CGAL/CORE/Gmp_impl.h | 265 --------------------- Number_types/include/CGAL/boost_mp_type.h | 3 +- 5 files changed, 2 insertions(+), 305 deletions(-) delete mode 100644 CGAL_Core/include/CGAL/CORE/Gmp.h delete mode 100644 CGAL_Core/include/CGAL/CORE/Gmp_impl.h diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 84cc0c6a880d..fff3c91eef72 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -25,7 +25,6 @@ #define _CORE_BIGINT_H_ #include -#include #include #include #include diff --git a/CGAL_Core/include/CGAL/CORE/CoreAux_impl.h b/CGAL_Core/include/CGAL/CORE/CoreAux_impl.h index e1fa64e5330c..434978c83250 100644 --- a/CGAL_Core/include/CGAL/CORE/CoreAux_impl.h +++ b/CGAL_Core/include/CGAL/CORE/CoreAux_impl.h @@ -31,7 +31,6 @@ #include #include -#include namespace CORE { diff --git a/CGAL_Core/include/CGAL/CORE/Gmp.h b/CGAL_Core/include/CGAL/CORE/Gmp.h deleted file mode 100644 index 4febe840d9ac..000000000000 --- a/CGAL_Core/include/CGAL/CORE/Gmp.h +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** - * Core Library Version 1.7, August 2004 - * Copyright (c) 1995-2004 Exact Computation Project - * All rights reserved. - * - * This file is part of CGAL (www.cgal.org). - * - * $URL$ - * $Id$ - * SPDX-License-Identifier: LGPL-3.0-or-later - ***************************************************************************/ - -// CORE LIBRARY FILE -#ifndef _CORE_GMP_H_ -#define _CORE_GMP_H_ - -#include -#include - -namespace CORE { - -CGAL_CORE_EXPORT std::ostream& io_write (std::ostream &, mpz_srcptr); -CGAL_CORE_EXPORT std::ostream& io_write (std::ostream &, mpq_srcptr); -CGAL_CORE_EXPORT std::istream& io_read (std::istream &, mpz_ptr); -CGAL_CORE_EXPORT std::istream& io_read (std::istream &, mpq_ptr); -//std::ostream& operator<< (std::ostream &, mpz_srcptr); -//std::ostream& operator<< (std::ostream &, mpq_srcptr); -//std::istream& operator>> (std::istream &, mpz_ptr); -//std::istream& operator>> (std::istream &, mpq_ptr); - -} //namespace CORE - -#ifdef CGAL_HEADER_ONLY -#include -#endif // CGAL_HEADER_ONLY - -#endif // _CORE_GMP_H_ diff --git a/CGAL_Core/include/CGAL/CORE/Gmp_impl.h b/CGAL_Core/include/CGAL/CORE/Gmp_impl.h deleted file mode 100644 index 479dc0dd0faf..000000000000 --- a/CGAL_Core/include/CGAL/CORE/Gmp_impl.h +++ /dev/null @@ -1,265 +0,0 @@ -/**************************************************************************** - * Core Library Version 1.7, August 2004 - * Copyright (c) 1995-2004 Exact Computation Project - * All rights reserved. - * - * file: GmpIO.cpp - * Adapted from multi-files under /cxx in GMP's source distribution - * - * Zilin Du, 2003 - * - * $URL$ - * $Id$ - * SPDX-License-Identifier: LGPL-3.0-only - ***************************************************************************/ - -/* Auxiliary functions for C++-style input of GMP types. - -Copyright 2001 Free Software Foundation, Inc. - -This file is part of the GNU MP Library. - -*/ - -#ifdef CGAL_HEADER_ONLY -#define CGAL_INLINE_FUNCTION inline -#else -#define CGAL_INLINE_FUNCTION -#endif - -#include -#include -#include -#include -#include - -namespace CORE { - -CGAL_INLINE_FUNCTION -int -__gmp_istream_set_base (std::istream &i, char &c, bool &zero, bool &showbase) -{ - int base; - using std::ios; - - zero = showbase = false; - switch (i.flags() & ios::basefield) - { - case ios::dec: - base = 10; - break; - case ios::hex: - base = 16; - break; - case ios::oct: - base = 8; - break; - default: - showbase = true; // look for initial "0" or "0x" or "0X" - if (c == '0') - { - if (! i.get(c)) - c = 0; // reset or we might loop indefinitely - - if (c == 'x' || c == 'X') - { - base = 16; - i.get(c); - } - else - { - base = 8; - zero = true; // if no other digit is read, the "0" counts - } - } - else - base = 10; - break; - } - - return base; -} - -CGAL_INLINE_FUNCTION -void -__gmp_istream_set_digits (std::string &s, std::istream &i, char &c, bool &ok, int base) -{ - switch (base) - { - case 10: - while (isdigit(c)) - { - ok = true; // at least a valid digit was read - s += c; - if (! i.get(c)) - break; - } - break; - case 8: - while (isdigit(c) && c != '8' && c != '9') - { - ok = true; // at least a valid digit was read - s += c; - if (! i.get(c)) - break; - } - break; - case 16: - while (isxdigit(c)) - { - ok = true; // at least a valid digit was read - s += c; - if (! i.get(c)) - break; - } - break; - } -} - -CGAL_INLINE_FUNCTION -std::istream & -//operator>> (std::istream &i, mpz_ptr z) -io_read (std::istream &i, mpz_ptr z) -{ - using namespace std; - int base; - char c = 0; - std::string s; - bool ok = false, zero, showbase; - - i.get(c); // start reading - - if (i.flags() & ios::skipws) // skip initial whitespace - while (isspace(c) && i.get(c)) - ; - - if (c == '-' || c == '+') // sign - { - if (c == '-') // mpz_set_str doesn't accept '+' - s = "-"; - i.get(c); - } - - while (isspace(c) && i.get(c)) // skip whitespace - ; - - base = __gmp_istream_set_base(i, c, zero, showbase); // select the base - __gmp_istream_set_digits(s, i, c, ok, base); // read the number - - if (i.good()) // last character read was non-numeric - i.putback(c); - else if (i.eof() && (ok || zero)) // stopped just before eof - i.clear(); - - if (ok) - mpz_set_str(z, s.c_str(), base); // extract the number - else if (zero) - mpz_set_ui(z, 0); - else - i.setstate(ios::failbit); // read failed - - return i; -} - -CGAL_INLINE_FUNCTION -std::istream & -//operator>> (std::istream &i, mpq_ptr q) -io_read (std::istream &i, mpq_ptr q) -{ - using namespace std; - int base; - char c = 0; - std::string s; - bool ok = false, zero, showbase; - - i.get(c); // start reading - - if (i.flags() & ios::skipws) // skip initial whitespace - while (isspace(c) && i.get(c)) - ; - - if (c == '-' || c == '+') // sign - { - if (c == '-') - s = "-"; - i.get(c); - } - - while (isspace(c) && i.get(c)) // skip whitespace - ; - - base = __gmp_istream_set_base(i, c, zero, showbase); // select the base - __gmp_istream_set_digits(s, i, c, ok, base); // read the numerator - - if (! ok && zero) // the only digit read was "0" - { - base = 10; - s += '0'; - ok = true; - } - - if (c == '/') // there's a denominator - { - bool zero2 = false; - int base2 = base; - - s += '/'; - ok = false; // denominator is mandatory - i.get(c); - - while (isspace(c) && i.get(c)) // skip whitespace - ; - - if (showbase) // check base of denominator - base2 = __gmp_istream_set_base(i, c, zero2, showbase); - - if (base2 == base || base2 == 10) // read the denominator - __gmp_istream_set_digits(s, i, c, ok, base); - - if (! ok && zero2) // the only digit read was "0" - { // denominator is 0, but that's your business - s += '0'; - ok = true; - } - } - - if (i.good()) // last character read was non-numeric - i.putback(c); - else if (i.eof() && ok) // stopped just before eof - i.clear(); - - if (ok) - mpq_set_str(q, s.c_str(), base); // extract the number - else - i.setstate(ios::failbit); // read failed - - return i; -} - -CGAL_INLINE_FUNCTION -std::ostream& -//operator<< (std::ostream &o, mpz_srcptr z) -io_write (std::ostream &o, mpz_srcptr z) -{ - char *str = new char [mpz_sizeinbase(z,10) + 2]; - str = mpz_get_str(str, 10, z); - o << str ; - delete[] str; - return o; -} - -CGAL_INLINE_FUNCTION -std::ostream& -//operator<< (std::ostream &o, mpq_srcptr q) -io_write (std::ostream &o, mpq_srcptr q) -{ - // size according to GMP documentation - char *str = new char [mpz_sizeinbase(mpq_numref(q), 10) + - mpz_sizeinbase (mpq_denref(q), 10) + 3]; - str = mpq_get_str(str, 10, q); - o << str ; - delete[] str; - return o; -} - -} //namespace CORE diff --git a/Number_types/include/CGAL/boost_mp_type.h b/Number_types/include/CGAL/boost_mp_type.h index 1c038ad33905..ae65fb6d3ba4 100644 --- a/Number_types/include/CGAL/boost_mp_type.h +++ b/Number_types/include/CGAL/boost_mp_type.h @@ -85,6 +85,7 @@ struct Needs_parens_as_product{ }; +#ifdef CGAL_USE_GMP template<> struct Needs_parens_as_product{ bool operator()(const typename boost::multiprecision::mpz_int& x){ @@ -100,8 +101,8 @@ struct Needs_parens_as_product{ else return needs_parens_as_product(numerator(x)) ; } - }; +#endif From 432449b23bbf153210522877412e29f5ef9eb3cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 28 Feb 2024 13:55:01 +0100 Subject: [PATCH 104/139] fix compilation issues mainly due to expression template --- .../include/CGAL/Arr_conic_traits_2.h | 11 ++++++----- .../gfx/Curve_renderer_traits.h | 2 +- Envelope_3/include/CGAL/Env_sphere_traits_3.h | 18 +++++++++--------- Number_types/test/Number_types/ioformat.cpp | 1 - 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h index c9aec291440b..4f2071c4f736 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h @@ -3904,10 +3904,11 @@ class Arr_conic_traits_2 { auto u = cv.u(); auto v = cv.v(); auto w = cv.w(); - Algebraic* ys_end = m_nt_traits->solve_quadratic_equation(t*t - four*r*s, - two*t*u - four*r*v, - u*u - four*r*w, - ys); + Algebraic* ys_end = m_nt_traits->template + solve_quadratic_equation(t*t - four*r*s, + two*t*u - four*r*v, + u*u - four*r*w, + ys); auto n = static_cast(ys_end - ys); // Compute the x coordinates and construct the horizontal tangency points. @@ -3915,7 +3916,7 @@ class Arr_conic_traits_2 { // Having computed y, x is the single solution to the quadratic equation // above, and since its discriminant is 0, x is simply given by: Algebraic x = -(m_nt_traits->convert(t)*ys[i] + m_nt_traits->convert(u)) / - m_nt_traits->convert(two*r); + m_nt_traits->convert(Integer(two*r)); ps[i] = Point_2(x, ys[i]); } diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_traits.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_traits.h index 63e31f8ad504..7520f9cfad29 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_traits.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_traits.h @@ -336,7 +336,7 @@ struct Curve_renderer_traits, CORE::BigRat > : //! Specialization for \c CORE::BigFloat template <> -struct Curve_renderer_traits +struct Curve_renderer_traits : public Curve_renderer_traits_base { diff --git a/Envelope_3/include/CGAL/Env_sphere_traits_3.h b/Envelope_3/include/CGAL/Env_sphere_traits_3.h index 3d272f81b29f..9c1eed123ff5 100644 --- a/Envelope_3/include/CGAL/Env_sphere_traits_3.h +++ b/Envelope_3/include/CGAL/Env_sphere_traits_3.h @@ -265,7 +265,7 @@ class Env_sphere_traits_3 : public ConicTraits_2 { if (n_ys == 0) return o; // no intersection // the x coordinate of the solution points - Algebraic xs = m / (2*a_diff); + Algebraic xs = m / (Rational(2)*a_diff); if (n_ys == 1) { // intersection is a point @@ -340,7 +340,7 @@ class Env_sphere_traits_3 : public ConicTraits_2 { } if (n_xs == 1) { // intersection is a point - Point_2 inter_point(xs[0], (-2*a_diff*xs[0] + m)/(2*b_diff) ); + Point_2 inter_point(xs[0], (-Rational(2)*a_diff*xs[0] + m)/(Rational(2)*b_diff) ); *o++ = inter_point; return o; } @@ -350,8 +350,8 @@ class Env_sphere_traits_3 : public ConicTraits_2 { // so we construct a COLLINEAR conic (with equation as in (1)) // with 2 endpoints Algebraic ys[2]; - ys[0] = (-2*a_diff*xs[0] + m)/(2*b_diff); - ys[1] = (-2*a_diff*xs[1] + m)/(2*b_diff); + ys[0] = (-Rational(2)*a_diff*xs[0] + m)/(Rational(2)*b_diff); + ys[1] = (-Rational(2)*a_diff*xs[1] + m)/(Rational(2)*b_diff); Alg_point_2 end1(xs[0], ys[0]); Alg_point_2 end2(xs[1], ys[1]); @@ -977,10 +977,10 @@ class Env_sphere_traits_3 : public ConicTraits_2 { const Rational& u = cv.u(); const Rational& v = cv.v(); // const Rational& w = cv.w(); // unused - Algebraic m = -1 * (2*r*x0 + t*y0 + u); - Algebraic n = 2*s*y0 + t*x0 + v; + Algebraic m = -1 * (Rational(2)*r*x0 + t*y0 + u); + Algebraic n = Rational(2)*s*y0 + t*x0 + v; // line coefficients: A3, B3, C3 - Algebraic A3 = -1*m, B3 = n, C3 = m*x0 - n*y0; + Algebraic A3 = -m, B3 = n, C3 = m*x0 - n*y0; // the tangences of the spheres (in point (x0,y0,z0)): Algebraic z0 = compute_envelope_z_in_point(cv_point, s1); @@ -1077,8 +1077,8 @@ class Env_sphere_traits_3 : public ConicTraits_2 { Algebraic x_diff = x1 - a, y_diff = y1 - b; // the coefficients are: Algebraic A = 1; - Algebraic B = -2*c; - Algebraic C = x_diff*x_diff + y_diff*y_diff + c*c - sqr_r; + Algebraic B = -Rational(2)*c; + Algebraic C = x_diff*x_diff + y_diff*y_diff + Algebraic(c*c - sqr_r); Algebraic zs[2]; Algebraic* zs_end; diff --git a/Number_types/test/Number_types/ioformat.cpp b/Number_types/test/Number_types/ioformat.cpp index 54eaa26bf227..457f1be15b11 100644 --- a/Number_types/test/Number_types/ioformat.cpp +++ b/Number_types/test/Number_types/ioformat.cpp @@ -106,7 +106,6 @@ int main() // CORE #ifdef CGAL_USE_CORE - static_assert(CGAL::Output_rep::is_specialized == true); //bug in io for CORE. test_it("CORE::BigInt"); test_it("CORE::BigRat"); From 5825defee3ff4a968a3da81ab331af7edf5b1bee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 28 Feb 2024 14:10:58 +0100 Subject: [PATCH 105/139] update license --- CGAL_Core/package_info/CGAL_Core/license.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CGAL_Core/package_info/CGAL_Core/license.txt b/CGAL_Core/package_info/CGAL_Core/license.txt index 66d68590d248..5c1c5d8436f8 100644 --- a/CGAL_Core/package_info/CGAL_Core/license.txt +++ b/CGAL_Core/package_info/CGAL_Core/license.txt @@ -1,2 +1 @@ -LGPL (v3) LGPL (v3 or later) From 0cb4b837b0ed44eb048e3168540e13344e812295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 28 Feb 2024 15:06:48 +0100 Subject: [PATCH 106/139] remove no longer used license --- LICENSES/LGPL-3.0-only.txt | 165 ------------------------------------- 1 file changed, 165 deletions(-) delete mode 100644 LICENSES/LGPL-3.0-only.txt diff --git a/LICENSES/LGPL-3.0-only.txt b/LICENSES/LGPL-3.0-only.txt deleted file mode 100644 index 65c5ca88a67c..000000000000 --- a/LICENSES/LGPL-3.0-only.txt +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. From 1847a46a7c0688b5563de9775e0f8f5b9d131234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 28 Feb 2024 15:19:51 +0100 Subject: [PATCH 107/139] update changes [skip ci] --- Installation/CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 01179cc55c75..f7abc2e93120 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -15,7 +15,11 @@ Release date: October 2023 - **Breaking change**: The usage of `boost::optional` has been replaced by `std::optional`. Packages affected are 2D Straight Line Skeleton, 3D Fast Intersection and Distance Computation (AABB Tree), and the Kernel intersection. - **Breaking change**: The usage of `boost::variant` has been replaced by `std::variant`. Packages affected are 2D Arrangements, and the Kernel intersection. - **Breaking change**: The file CMake file `UseCGAL.cmake` has been removed from CGAL. Usages of the CMake variables `${CGAL_USE_FILE}` and `${CGAL_LIBRARIES}` must be replaced by a link to the imported target `CGAL::CGAL`, for example: `target_link_library(the_target PRIVATE CGAL::CGAL)`. +- The minimal supported version of Boost is now 1.70.0 +### Installation + +- The CGAL\_Core library is no longer based on GMP but boost multiprecision now, and can be used with either gmp backend or boost backend. #### 2D Arrangements From 250462568331d4667d053a6ddc9c713750d03d08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 28 Feb 2024 17:13:45 +0100 Subject: [PATCH 108/139] qualify gcd calls --- Polynomial/test/Polynomial/test_polynomial.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Polynomial/test/Polynomial/test_polynomial.h b/Polynomial/test/Polynomial/test_polynomial.h index 031373ce7409..1b5bb0868aca 100644 --- a/Polynomial/test/Polynomial/test_polynomial.h +++ b/Polynomial/test/Polynomial/test_polynomial.h @@ -403,12 +403,12 @@ void unigcdres(CGAL::Field_tag) { h /= h.unit_part(); POLY d; - d = gcd(f, g); + d = CGAL::gcd(f, g); assert( d == POLY(NT(1)) ); assert( prs_resultant(f, g) == NT(230664271L)/NT(759375L) ); // Maple POLY fh(f*h), gh(g*h); - d = gcd(fh, gh); + d = CGAL::gcd(fh, gh); assert( d == h ); assert( prs_resultant(fh, gh) == NT(0) ); @@ -429,12 +429,12 @@ void unigcdres(CGAL::Integral_domain_tag) { POLY d; NT c(42); - d = gcd((-c)*f, c*g); + d = CGAL::gcd((-c)*f, c*g); assert( d == POLY(c) ); assert( prs_resultant(f, g) == NT(230664271L) ); // as computed by Maple POLY fh(f*h), gh(g*h); - d = gcd((-c)*fh, c*gh); + d = CGAL::gcd((-c)*fh, c*gh); assert( d == c*h ); assert( prs_resultant(fh, gh) == NT(0) ); @@ -476,14 +476,14 @@ void bigcdres(CGAL::Field_tag) { h /= h.unit_part(); POLY2 d; - d = gcd(f, g); + d = CGAL::gcd(f, g); assert( d == POLY2(1) ); POLY1 r(NT(1444), NT(-1726), NT(3295), NT(-2501), NT(560)); r /= NT(225); assert( prs_resultant(f, g) == r ); // says Maple POLY2 fh(f*h), gh(g*h); - d = gcd(fh, gh); + d = CGAL::gcd(fh, gh); assert( d == h ); assert( prs_resultant(fh, gh) == POLY1(0) ); } @@ -502,13 +502,13 @@ void bigcdres(CGAL::Integral_domain_tag) { POLY1(NT(9), NT(7)), POLY1(NT(7))); POLY2 c(42), d; - d = gcd(-c*f, c*g); + d = CGAL::gcd(-c*f, c*g); assert( d == c ); POLY1 r(NT(1444), NT(-1726), NT(3295), NT(-2501), NT(560)); assert( prs_resultant(f, g) == r ); // says Maple POLY2 fh(f*h), gh(g*h); - d = gcd(-c*fh, c*gh); + d = CGAL::gcd(-c*fh, c*gh); assert( d == c*h ); assert( prs_resultant(fh, gh) == POLY1(0) ); } From 6da4e7a57f99813474be52fb30a54eb9d76476b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 28 Feb 2024 17:22:41 +0100 Subject: [PATCH 109/139] remove non-used functions --- CGAL_Core/include/CGAL/CORE/BigFloat.h | 27 -------------------------- CGAL_Core/include/CGAL/CORE/BigRat.h | 14 ------------- 2 files changed, 41 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigFloat.h b/CGAL_Core/include/CGAL/CORE/BigFloat.h index 5969c1b5e286..de9ed2f55089 100644 --- a/CGAL_Core/include/CGAL/CORE/BigFloat.h +++ b/CGAL_Core/include/CGAL/CORE/BigFloat.h @@ -513,32 +513,6 @@ inline long minStar(long m, long n) { } /// \name Functions for Compatibility with BigInt (needed by Poly, Curves) //@{ -/// isDivisible(a,b) = "is a divisible by b" -/** Assuming that a and b are in coanonized forms. - Defined to be true if mantissa(b) | mantissa(a) && - exp(b) = min*(exp(b), exp(a)). - * This concepts assume a and b are exact BigFloats. - */ -inline bool isDivisible(const BigFloat& a, const BigFloat& b) { - // assert: a and b are exact BigFloats. - if (sign(a.m()) == 0) return true; - if (sign(b.m()) == 0) return false; - unsigned long bin_a = getBinExpo(a.m()); - unsigned long bin_b = getBinExpo(b.m()); - - BigInt m_a = a.m() >> bin_a; - BigInt m_b = b.m() >> bin_b; - long e_a = bin_a + BigFloatRep::bits(a.exp()); - long e_b = bin_b + BigFloatRep::bits(b.exp()); - long dx = minStar(e_a, e_b); - - return isDivisible(m_a, m_b) && (dx == e_b); -} - -inline bool isDivisible(double x, double y) { - //Are these exact? - return isDivisible(BigFloat(x), BigFloat(y)); -} /// div_exact(x,y) returns the BigFloat quotient of x divided by y /** This is defined only if isDivisible(x,y). @@ -551,7 +525,6 @@ inline bool isDivisible(double x, double y) { // normalizing it then we get zero. inline BigFloat div_exact(const BigFloat& x, const BigFloat& y) { BigInt z; - CGAL_assertion (isDivisible(x,y)); unsigned long bin_x = getBinExpo(x.m()); unsigned long bin_y = getBinExpo(y.m()); diff --git a/CGAL_Core/include/CGAL/CORE/BigRat.h b/CGAL_Core/include/CGAL/CORE/BigRat.h index df60c54b9bfd..cc0c8d5ed174 100644 --- a/CGAL_Core/include/CGAL/CORE/BigRat.h +++ b/CGAL_Core/include/CGAL/CORE/BigRat.h @@ -67,20 +67,6 @@ namespace CORE { return BigRat(n,d); } - // Chee: 8/8/2004: need isDivisible to compile Polynomial - // A trivial implementation is to return true always. But this - // caused tPolyRat to fail. - // So we follow the definition of - // Expr::isDivisible(e1, e2) which checks if e1/e2 is an integer. - inline bool isInteger(const BigRat& x) { - return denominator(x) == 1; // AF: does that need canonicalize? - } - inline bool isDivisible(const BigRat& x, const BigRat& y) { - BigRat r; - r = x/y; - return isInteger(r); - } - /// BigIntValue inline BigInt BigIntValue(const BigRat& br) { From cac4f5c854f14f17e7db2fbc70bcd37a013f5c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 29 Feb 2024 11:29:15 +0100 Subject: [PATCH 110/139] avoid GMP dependency --- Number_types/test/Number_types/CORE_Expr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Number_types/test/Number_types/CORE_Expr.cpp b/Number_types/test/Number_types/CORE_Expr.cpp index 74bb4b14350e..6fd99d12e41a 100644 --- a/Number_types/test/Number_types/CORE_Expr.cpp +++ b/Number_types/test/Number_types/CORE_Expr.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include @@ -119,7 +119,7 @@ void test_MSB_bug() int main() { precision_bug(); test_istream(); - test_MSB_bug(); + test_MSB_bug(); test_MSB_bug(); typedef CORE::Expr NT; From 993991eade7dd0574d03680ff8c6cda81cf5d968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 29 Feb 2024 13:16:48 +0100 Subject: [PATCH 111/139] turn warning messages in errors for the testsuite --- CGAL_Core/include/CGAL/CORE/BigFloat_impl.h | 2 +- CGAL_Core/include/CGAL/CORE/Config.h | 7 +++++++ CGAL_Core/include/CGAL/CORE/ExprRep.h | 6 +++--- CGAL_Core/include/CGAL/CORE/Expr_impl.h | 6 +++--- CGAL_Core/include/CGAL/CORE/Filter.h | 4 ++-- CGAL_Core/include/CGAL/CORE/MemoryPool.h | 2 +- CGAL_Core/include/CGAL/CORE/extLong.h | 2 +- CGAL_Core/include/CGAL/CORE/extLong_impl.h | 12 ++++++------ CGAL_Core/include/CGAL/CORE/poly/Curves.tcc | 2 +- CGAL_Core/include/CGAL/CORE/poly/Poly.tcc | 2 +- CGAL_Core/include/CGAL/CORE/poly/Sturm.h | 2 +- 11 files changed, 27 insertions(+), 20 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h b/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h index 32683de7a2c7..b6eb9054c8e1 100644 --- a/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h +++ b/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h @@ -819,7 +819,7 @@ BigFloatRep::toDecimal(unsigned int width, bool Scientific) const { if (err > 0 && err >= abs(m)) { // if err is larger than mantissa, sign and significant values // can not be determined. - CGAL_warning_msg(true, "BigFloat error: Error is too big!"); + CGAL_CORE_warning_msg(true, "BigFloat error: Error is too big!"); decOut.rep = "0.0e0"; // error is too big decOut.isScientific = false; decOut.noSignificant = 0; diff --git a/CGAL_Core/include/CGAL/CORE/Config.h b/CGAL_Core/include/CGAL/CORE/Config.h index b85ddbf55384..d55b5edfcb96 100644 --- a/CGAL_Core/include/CGAL/CORE/Config.h +++ b/CGAL_Core/include/CGAL/CORE/Config.h @@ -29,4 +29,11 @@ #include +#ifdef CGAL_TEST_SUITE +#define CGAL_CORE_warning_msg(X ,Y) CGAL_error_msg(Y) +#else +#define CGAL_CORE_warning_msg(X ,Y) CGAL_warning_msg(X ,Y) +#endif + + #endif // _CORE_CONFIG_H_ diff --git a/CGAL_Core/include/CGAL/CORE/ExprRep.h b/CGAL_Core/include/CGAL/CORE/ExprRep.h index a8f8c0aea37a..0e721dda16a8 100644 --- a/CGAL_Core/include/CGAL/CORE/ExprRep.h +++ b/CGAL_Core/include/CGAL/CORE/ExprRep.h @@ -1088,7 +1088,7 @@ void AddSubRep::computeExactFlags() { uMSB() = newValue.uMSB(); // chen: to get tighers value. sign() = newValue.sign(); } else if (lowBound.isInfty()) {//check if rootbound is too big - CGAL_warning_msg(false, "AddSubRep:root bound has exceeded the maximum size but we still cannot decide zero."); + CGAL_CORE_warning_msg(false, "AddSubRep:root bound has exceeded the maximum size but we still cannot decide zero."); } else { // Op(first, second) == 0 lMSB() = CORE_negInfty; sign() = 0; @@ -1181,7 +1181,7 @@ void AddSubRep::computeExactFlags() { //8/9/01, Chee: implement escape precision here: if (i> get_static_EscapePrec()) { get_static_EscapePrecFlag() = -i.asLong();//negative means EscapePrec is used - CGAL_warning_msg(false, "Escape precision triggered"); + CGAL_CORE_warning_msg(false, "Escape precision triggered"); if (get_static_EscapePrecWarning()) std::cout<< "Escape Precision triggered at " << get_static_EscapePrec() << " bits" << std::endl; @@ -1229,7 +1229,7 @@ void AddSubRep::computeApproxValue(const extLong& relPrec, { std::ostringstream oss; oss << "CORE WARNING: a huge lMSB in AddSubRep: " << lMSB(); - CGAL_warning_msg(false, oss.str().c_str()); + CGAL_CORE_warning_msg(false, oss.str().c_str()); } extLong rf = first->uMSB()-lMSB()+relPrec+EXTLONG_FOUR; // 2 better diff --git a/CGAL_Core/include/CGAL/CORE/Expr_impl.h b/CGAL_Core/include/CGAL/CORE/Expr_impl.h index aeae1ef1ea0e..c21f88361a3e 100644 --- a/CGAL_Core/include/CGAL/CORE/Expr_impl.h +++ b/CGAL_Core/include/CGAL/CORE/Expr_impl.h @@ -1024,7 +1024,7 @@ void MultRep::computeApproxValue(const extLong& relPrec, { std::ostringstream oss; oss << "CORE WARNING: a huge lMSB in AddSubRep " << lMSB(); - CGAL_warning_msg(false, oss.str().c_str()); + CGAL_CORE_warning_msg(false, oss.str().c_str()); } extLong r = relPrec + EXTLONG_FOUR; @@ -1046,7 +1046,7 @@ void DivRep::computeApproxValue(const extLong& relPrec, { std::ostringstream oss; oss << "CORE WARNING: a huge lMSB in AddSubRep " << lMSB(); - CGAL_warning_msg(false, oss.str().c_str()); + CGAL_CORE_warning_msg(false, oss.str().c_str()); } extLong rr = relPrec + EXTLONG_SEVEN; // These rules come from @@ -1079,7 +1079,7 @@ void Expr::debug(int mode, int level, int depthLimit) const { else if (mode == Expr::TREE_MODE) rep->debugTree(level, 0, depthLimit); else - CGAL_warning_msg(false, "unknown debugging mode"); + CGAL_CORE_warning_msg(false, "unknown debugging mode"); std::cout << "---- End Expr debug(): " << std::endl; } diff --git a/CGAL_Core/include/CGAL/CORE/Filter.h b/CGAL_Core/include/CGAL/CORE/Filter.h index c59e69fe1eb8..e71c8aa8733f 100644 --- a/CGAL_Core/include/CGAL/CORE/Filter.h +++ b/CGAL_Core/include/CGAL/CORE/Filter.h @@ -137,7 +137,7 @@ class filteredFp { } /// division filteredFp operator/ (const filteredFp& x) const { - CGAL_warning_msg(x.fpVal != 0.0, "possible zero divisor!"); + CGAL_CORE_warning_msg(x.fpVal != 0.0, "possible zero divisor!"); double xxx = core_abs(x.fpVal) / x.maxAbs - (x.ind+1)*CORE_EPS + DBL_MIN; if (xxx > 0) { @@ -150,7 +150,7 @@ class filteredFp { /// square root filteredFp sqrt () const { - CGAL_warning_msg( !(fpVal < 0.0), "possible negative sqrt!"); + CGAL_CORE_warning_msg( !(fpVal < 0.0), "possible negative sqrt!"); if (fpVal > 0.0) { double val = std::sqrt(fpVal); return filteredFp(val, ( maxAbs / fpVal ) * val, 1 + ind); diff --git a/CGAL_Core/include/CGAL/CORE/MemoryPool.h b/CGAL_Core/include/CGAL/CORE/MemoryPool.h index 60a95c862e22..2db3de8736e1 100644 --- a/CGAL_Core/include/CGAL/CORE/MemoryPool.h +++ b/CGAL_Core/include/CGAL/CORE/MemoryPool.h @@ -57,7 +57,7 @@ class MemoryPool { t = t->next; } //); - //CGAL_warning_msg(count == nObjects * blocks.size(), + //CGAL_CORE_warning_msg(count == nObjects * blocks.size(), // "Cannot delete memory as there are cyclic references"); if(count == nObjects * blocks.size()){ diff --git a/CGAL_Core/include/CGAL/CORE/extLong.h b/CGAL_Core/include/CGAL/CORE/extLong.h index 7f01e4e167a8..095c5105b8dd 100644 --- a/CGAL_Core/include/CGAL/CORE/extLong.h +++ b/CGAL_Core/include/CGAL/CORE/extLong.h @@ -149,7 +149,7 @@ const extLong EXTLONG_EIGHT(8); // private comparison function inline int extLong::cmp(const extLong& x) const { if (isNaN() || x.isNaN()) { - CGAL_warning_msg(false, "Two extLong NaN's cannot be compared!"); + CGAL_CORE_warning_msg(false, "Two extLong NaN's cannot be compared!"); } return (val == x.val) ? 0 : ((val > x.val) ? 1 : -1); } diff --git a/CGAL_Core/include/CGAL/CORE/extLong_impl.h b/CGAL_Core/include/CGAL/CORE/extLong_impl.h index c881bb74b51c..f7b967d76d3d 100644 --- a/CGAL_Core/include/CGAL/CORE/extLong_impl.h +++ b/CGAL_Core/include/CGAL/CORE/extLong_impl.h @@ -77,7 +77,7 @@ extLong& extLong::operator+= (const extLong& y) { if (flag == 2 || y.flag == 2 || (flag * y.flag < 0)) { #ifdef CORE_DEBUG if (flag * y.flag < 0) //want a message at the first creation of NaN - CGAL_warning_msg(false, "extLong NaN Error in addition."); + CGAL_CORE_warning_msg(false, "extLong NaN Error in addition."); #endif *this = CORE_NaNLong; @@ -96,7 +96,7 @@ extLong& extLong::operator-= (const extLong& y) { if (flag == 2 || y.flag == 2 || (flag * y.flag > 0)) { #ifdef CORE_DEBUG if (flag * y.flag > 0) //want a message at the first creation of NaN - CGAL_warning_msg(false, "extLong NaN Error in subtraction."); + CGAL_CORE_warning_msg(false, "extLong NaN Error in subtraction."); #endif *this = CORE_NaNLong; @@ -131,7 +131,7 @@ extLong& extLong::operator*= (const extLong& y) { *this = CORE_negInfty; } else { #ifdef CORE_DEBUG - CGAL_warning_msg(false, "extLong NaN Error in multiplication."); + CGAL_CORE_warning_msg(false, "extLong NaN Error in multiplication."); #endif *this = CORE_NaNLong; } @@ -144,9 +144,9 @@ extLong& extLong::operator/= (const extLong& y) { if (flag==2 || y.flag==2 || ((flag != 0) && (y.flag != 0)) || (y.val == 0)) { #ifdef CORE_DEBUG if (y.val == 0) - CGAL_warning_msg(false, "extLong NaN Error, Divide by Zero."); + CGAL_CORE_warning_msg(false, "extLong NaN Error, Divide by Zero."); else if ((flag !=0) && (y.flag !=0)) - CGAL_warning_msg(false, "extLong NaN Error, +/-Inf/Inf."); + CGAL_CORE_warning_msg(false, "extLong NaN Error, +/-Inf/Inf."); #endif *this = CORE_NaNLong; @@ -181,7 +181,7 @@ extLong extLong::operator- () const { CGAL_INLINE_FUNCTION int extLong::sign() const { if (flag == 2) - CGAL_warning_msg(false, "NaN Sign can not be determined!"); + CGAL_CORE_warning_msg(false, "NaN Sign can not be determined!"); return ((val == 0) ? 0 : ((val > 0) ? 1 : -1)); } diff --git a/CGAL_Core/include/CGAL/CORE/poly/Curves.tcc b/CGAL_Core/include/CGAL/CORE/poly/Curves.tcc index 0fffb4ae470a..3f53e34da44e 100644 --- a/CGAL_Core/include/CGAL/CORE/poly/Curves.tcc +++ b/CGAL_Core/include/CGAL/CORE/poly/Curves.tcc @@ -1336,7 +1336,7 @@ cout <<"Number of roots at " << xCurr << " are " << numRoots<::pseudoRemainder :\n -- divide by zero polynomial"); + CGAL_CORE_warning_msg(false, "ERROR in Polynomial::pseudoRemainder :\n -- divide by zero polynomial"); return Polynomial(0); // Unit Polynomial (arbitrary!) } if (bTrueDegree > degree) { diff --git a/CGAL_Core/include/CGAL/CORE/poly/Sturm.h b/CGAL_Core/include/CGAL/CORE/poly/Sturm.h index 99e78d6a9300..2fe00e3706d8 100644 --- a/CGAL_Core/include/CGAL/CORE/poly/Sturm.h +++ b/CGAL_Core/include/CGAL/CORE/poly/Sturm.h @@ -607,7 +607,7 @@ class Sturm { if (ff == 0) { NEWTON_DIV_BY_ZERO = true; del = 0; - CGAL_warning_msg(false, "Zero divisor in Newton Iteration"); + CGAL_CORE_warning_msg(false, "Zero divisor in Newton Iteration"); return 0; } From f130cfe92c21774cab55dec7e0529c51615f273c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 1 Mar 2024 11:51:34 +0100 Subject: [PATCH 112/139] fix conversion error --- Envelope_3/include/CGAL/Env_sphere_traits_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Envelope_3/include/CGAL/Env_sphere_traits_3.h b/Envelope_3/include/CGAL/Env_sphere_traits_3.h index 9c1eed123ff5..bb7f34a25be0 100644 --- a/Envelope_3/include/CGAL/Env_sphere_traits_3.h +++ b/Envelope_3/include/CGAL/Env_sphere_traits_3.h @@ -457,7 +457,7 @@ class Env_sphere_traits_3 : public ConicTraits_2 { int envelope_coef = 1; if (! m_traits.m_is_lower) envelope_coef = -1; - Sign sign_c_diff = CGAL_NTS sign(c_diff); + Rational sign_c_diff = Rational(sign(c_diff)); Rational la = envelope_coef*2*a_diff*sign_c_diff; Rational lb = envelope_coef*2*b_diff*sign_c_diff; Rational lc = envelope_coef*sign_c_diff*(2*c_diff*z_plane - m); From 4b5fabac12ace33d0bca163f622e1e5ec2324fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 1 Mar 2024 14:42:57 +0100 Subject: [PATCH 113/139] disable warning/errors in the testsuite it seems there are information but not errors --- CGAL_Core/include/CGAL/CORE/Config.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CGAL_Core/include/CGAL/CORE/Config.h b/CGAL_Core/include/CGAL/CORE/Config.h index d55b5edfcb96..9f49a7f59860 100644 --- a/CGAL_Core/include/CGAL/CORE/Config.h +++ b/CGAL_Core/include/CGAL/CORE/Config.h @@ -30,7 +30,9 @@ #include #ifdef CGAL_TEST_SUITE -#define CGAL_CORE_warning_msg(X ,Y) CGAL_error_msg(Y) +// disabled for the testsuite to avoid `w` +#define CGAL_CORE_warning_msg(X ,Y) +// if (!(X)) CGAL_error_msg(Y) #else #define CGAL_CORE_warning_msg(X ,Y) CGAL_warning_msg(X ,Y) #endif From d0d8efeeee0a4512cf18d640dc1b2abeed61a951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 6 Mar 2024 17:38:09 +0100 Subject: [PATCH 114/139] use GMP by default --- CGAL_Core/include/CGAL/CORE/BigInt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index fff3c91eef72..20e216cf5402 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -30,7 +30,7 @@ #include -#if !(BOOST_VERSION > 107900 && defined(CGAL_USE_BOOST_MP)) +#if !(defined(CGAL_CORE_USE_BOOST_BACKEND) && BOOST_VERSION > 107900 && defined(CGAL_USE_BOOST_MP)) #define CGAL_CORE_USE_GMP_BACKEND 1 #endif From 4a30611cdbc3d484bbad2a7ec5314740ed4a5ce1 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 7 Mar 2024 08:28:23 +0000 Subject: [PATCH 115/139] Add parenthesis to avoid warning --- CGAL_Core/include/CGAL/CORE/extLong_impl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CGAL_Core/include/CGAL/CORE/extLong_impl.h b/CGAL_Core/include/CGAL/CORE/extLong_impl.h index f7b967d76d3d..665642b15f39 100644 --- a/CGAL_Core/include/CGAL/CORE/extLong_impl.h +++ b/CGAL_Core/include/CGAL/CORE/extLong_impl.h @@ -180,8 +180,9 @@ extLong extLong::operator- () const { // you cannot interpret the returned value! CGAL_INLINE_FUNCTION int extLong::sign() const { - if (flag == 2) + if (flag == 2){ CGAL_CORE_warning_msg(false, "NaN Sign can not be determined!"); + } return ((val == 0) ? 0 : ((val > 0) ? 1 : -1)); } From 7a0f3da89bdb3f51d3e59d52ee42657d9b8eaca6 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 7 Mar 2024 11:26:14 +0100 Subject: [PATCH 116/139] Update CGAL_Core/include/CGAL/CORE/extLong_impl.h Co-authored-by: Laurent Rineau --- CGAL_Core/include/CGAL/CORE/extLong_impl.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/extLong_impl.h b/CGAL_Core/include/CGAL/CORE/extLong_impl.h index 665642b15f39..1d636545eeee 100644 --- a/CGAL_Core/include/CGAL/CORE/extLong_impl.h +++ b/CGAL_Core/include/CGAL/CORE/extLong_impl.h @@ -180,9 +180,7 @@ extLong extLong::operator- () const { // you cannot interpret the returned value! CGAL_INLINE_FUNCTION int extLong::sign() const { - if (flag == 2){ - CGAL_CORE_warning_msg(false, "NaN Sign can not be determined!"); - } + CGAL_CORE_warning_msg(flag != 2, "NaN Sign can not be determined!"); return ((val == 0) ? 0 : ((val > 0) ? 1 : -1)); } From 44b7ec6f3aab1dfeef1c1a480a2d222fdc89eb19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 14 Mar 2024 11:11:18 +0100 Subject: [PATCH 117/139] improve detection of cases when Core can be used --- CGAL_Core/include/CGAL/CORE/BigInt.h | 2 +- Installation/CMakeLists.txt | 3 +++ .../modules/CGAL_SetupCGALDependencies.cmake | 11 ++++----- .../CGAL_SetupCGAL_CoreDependencies.cmake | 1 - .../internal/enable_third_party_libraries.h | 24 +++++++++++++++++++ Installation/lib/cmake/CGAL/CGALConfig.cmake | 10 ++++++-- .../internal/Exact_type_selector.h | 2 ++ Number_types/include/CGAL/boost_mp_type.h | 21 +++------------- 8 files changed, 46 insertions(+), 28 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 20e216cf5402..dc376906f020 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -30,7 +30,7 @@ #include -#if !(defined(CGAL_CORE_USE_BOOST_BACKEND) && BOOST_VERSION > 107900 && defined(CGAL_USE_BOOST_MP)) +#if !(defined(CGAL_CORE_USE_BOOST_BACKEND) && BOOST_VERSION > 107900 && defined(CGAL_USE_BOOST_MP)) && !defined(CGAL_DISABLE_GMP) #define CGAL_CORE_USE_GMP_BACKEND 1 #endif diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index fa2102ff7c00..6335ead84111 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -115,6 +115,9 @@ option(CGAL_ENABLE_TESTING "Build the testing tree." ${BUILD_TESTING}) endif() endif(CGAL_BRANCH_BUILD) +#allow to force disabling boost multiprecision support +option(CGAL_DO_NOT_USE_BOOST_MP "Disable the support of boost multiprecision library" FALSE) + #message(STATUS "Packages found: ${CGAL_CONFIGURED_PACKAGES}") list(SORT CGAL_CONFIGURED_PACKAGES_NAMES) diff --git a/Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake b/Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake index 1d51bbbdac5f..347ab99e71c0 100644 --- a/Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake +++ b/Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake @@ -131,12 +131,6 @@ function(CGAL_setup_CGAL_flags target) $<$:/fp:except-> $<$:/bigobj> # Use /bigobj by default ) - elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang") - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.0.3) - message(STATUS "Apple Clang version ${CMAKE_CXX_COMPILER_VERSION} compiler detected") - message(STATUS "Boost MP is turned off for all Apple Clang versions below 11.0.3!") - target_compile_options(${target} INTERFACE "-DCGAL_DO_NOT_USE_BOOST_MP") - endif() elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel") message( STATUS "Using Intel Compiler. Adding -fp-model strict" ) if(WIN32) @@ -166,4 +160,9 @@ function(CGAL_setup_CGAL_flags target) target_compile_options(${target} INTERFACE "-mieee" "-mfp-rounding-mode=d" ) endif() endif() + + if (CGAL_DO_NOT_USE_BOOST_MP) + target_compile_options(${target} INTERFACE "-DCGAL_DO_NOT_USE_BOOST_MP") + endif() + endfunction() diff --git a/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake b/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake index 44be800f9c01..17e0dd017385 100644 --- a/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake +++ b/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake @@ -52,5 +52,4 @@ function(CGAL_setup_CGAL_Core_dependencies target) use_CGAL_GMP_support(CGAL_Core INTERFACE) target_compile_definitions(${target} INTERFACE CGAL_USE_CORE=1) target_link_libraries( CGAL_Core INTERFACE CGAL::CGAL ) - endfunction() diff --git a/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h b/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h index f241cc6130c3..461a41707d11 100644 --- a/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h +++ b/Installation/include/CGAL/Installation/internal/enable_third_party_libraries.h @@ -35,8 +35,32 @@ # endif // CGAL_USE_MPFR and no #endif // __has_include + +// It is easier to disable this number type completely for old versions. +// Before 1.63, I/O is broken. Again, disabling the whole file is just the +// easy solution. +// MSVC had trouble with versions <= 1.69: +// https://github.com/boostorg/multiprecision/issues/98 +// +// Disable also on Windows 32 bits +// because CGAL/cpp_float.h assumes _BitScanForward64 is available +// See https://learn.microsoft.com/en-us/cpp/intrinsics/bitscanforward-bitscanforward64 +// +// Disable also with PowerPC processors, with Boost<1.80 because of that bug: +// https://github.com/boostorg/multiprecision/pull/421 +// +#if !defined CGAL_DO_NOT_USE_BOOST_MP && \ + (!defined _MSC_VER || BOOST_VERSION >= 107000) && \ + (!defined _WIN32 || defined _WIN64) && \ + (BOOST_VERSION >= 108000 || (!defined _ARCH_PPC && !defined _ARCH_PPC64)) +#define CGAL_USE_BOOST_MP 1 +#endif + + +#if CGAL_USE_BOOST_MP #if ! CGAL_NO_CORE # define CGAL_USE_CORE 1 #endif +#endif #endif // CGAL_INTERNAL_ENABLE_THIRD_PARTY_LIBRARIES_H diff --git a/Installation/lib/cmake/CGAL/CGALConfig.cmake b/Installation/lib/cmake/CGAL/CGALConfig.cmake index 93e9e8830f0a..5f54f9aad344 100644 --- a/Installation/lib/cmake/CGAL/CGALConfig.cmake +++ b/Installation/lib/cmake/CGAL/CGALConfig.cmake @@ -127,12 +127,18 @@ if( CGAL_DEV_MODE OR RUNNING_CGAL_AUTO_TEST OR CGAL_TEST_SUITE ) endif() endif() +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.0.3) + message(STATUS "Apple Clang version ${CMAKE_CXX_COMPILER_VERSION} compiler detected") + message(STATUS "Boost MP is turned off for all Apple Clang versions below 11.0.3!") + set(CGAL_DO_NOT_USE_BOOST_MP TRUE) +endif() + foreach(comp ${CGAL_FIND_COMPONENTS}) if(NOT comp MATCHES "Core|ImageIO|Qt6") message(FATAL_ERROR "The requested CGAL component ${comp} does not exist!") endif() - if(comp MATCHES "Core" AND CGAL_DISABLE_GMP) - message("CGAL_Core needs GMP and won't be used.") + if(comp MATCHES "Core" AND CGAL_DO_NOT_USE_BOOST_MP) + message("CGAL_Core needs Boost multiprecision support and won't be used.") else() list(APPEND CGAL_LIBRARIES CGAL_${comp}) endif() diff --git a/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h b/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h index 772200e7b729..d29278219dca 100644 --- a/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h +++ b/Number_types/include/CGAL/Number_types/internal/Exact_type_selector.h @@ -23,7 +23,9 @@ #include #include +#ifdef CGAL_USE_BOOST_MP #include +#endif #ifdef CGAL_USE_GMP # include diff --git a/Number_types/include/CGAL/boost_mp_type.h b/Number_types/include/CGAL/boost_mp_type.h index ae65fb6d3ba4..cf18678c0114 100644 --- a/Number_types/include/CGAL/boost_mp_type.h +++ b/Number_types/include/CGAL/boost_mp_type.h @@ -15,24 +15,9 @@ #include #include -// It is easier to disable this number type completely for old versions. -// Before 1.63, I/O is broken. Again, disabling the whole file is just the -// easy solution. -// MSVC had trouble with versions <= 1.69: -// https://github.com/boostorg/multiprecision/issues/98 -// -// Disable also on Windows 32 bits -// because CGAL/cpp_float.h assumes _BitScanForward64 is available -// See https://learn.microsoft.com/en-us/cpp/intrinsics/bitscanforward-bitscanforward64 -// -// Disable also with PowerPC processors, with Boost<1.80 because of that bug: -// https://github.com/boostorg/multiprecision/pull/421 -// -#if !defined CGAL_DO_NOT_USE_BOOST_MP && \ - (!defined _MSC_VER || BOOST_VERSION >= 107000) && \ - (!defined _WIN32 || defined _WIN64) && \ - (BOOST_VERSION >= 108000 || (!defined _ARCH_PPC && !defined _ARCH_PPC64)) -#define CGAL_USE_BOOST_MP 1 +// CGAL_USE_BOOST_MP is defined in +// CGAL/Installation/internal/enable_third_party_libraries.h +#if CGAL_USE_BOOST_MP #include #include // *ary_function From 24015ce3a7ebe7e96e98d4ba2aeafe1d65d0b1f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 14 Mar 2024 11:30:14 +0100 Subject: [PATCH 118/139] fix conditional compilation of programs using CORE --- CGAL_Core/include/CGAL/CORE/BigInt.h | 4 ++-- Installation/lib/cmake/CGAL/CGALConfig.cmake | 2 +- Number_types/test/Number_types/CMakeLists.txt | 13 ++++++------- Number_types/test/Number_types/utilities.cpp | 3 +++ 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index dc376906f020..a66de01839e9 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -55,12 +55,12 @@ inline int set_str(BigInt& a, const char* s) { /// longValue inline long longValue(const BigInt& a) { - return a.convert_to();; + return a.convert_to(); } /// doubleValue inline double doubleValue(const BigInt& a) { - return a.convert_to();; + return a.convert_to(); } /// isEven diff --git a/Installation/lib/cmake/CGAL/CGALConfig.cmake b/Installation/lib/cmake/CGAL/CGALConfig.cmake index 5f54f9aad344..0ebd009ac8d8 100644 --- a/Installation/lib/cmake/CGAL/CGALConfig.cmake +++ b/Installation/lib/cmake/CGAL/CGALConfig.cmake @@ -138,7 +138,7 @@ foreach(comp ${CGAL_FIND_COMPONENTS}) message(FATAL_ERROR "The requested CGAL component ${comp} does not exist!") endif() if(comp MATCHES "Core" AND CGAL_DO_NOT_USE_BOOST_MP) - message("CGAL_Core needs Boost multiprecision support and won't be used.") + message(STATUS "CGAL_Core needs Boost multiprecision support and won't be used.") else() list(APPEND CGAL_LIBRARIES CGAL_${comp}) endif() diff --git a/Number_types/test/Number_types/CMakeLists.txt b/Number_types/test/Number_types/CMakeLists.txt index b3dd989c7664..5496946fb287 100644 --- a/Number_types/test/Number_types/CMakeLists.txt +++ b/Number_types/test/Number_types/CMakeLists.txt @@ -13,10 +13,6 @@ include_directories(BEFORE include) create_single_source_cgal_program("bench_interval.cpp") create_single_source_cgal_program("cpp_float.cpp") create_single_source_cgal_program("constant.cpp") -create_single_source_cgal_program("CORE_BigFloat.cpp") -create_single_source_cgal_program("CORE_BigInt.cpp") -create_single_source_cgal_program("CORE_BigRat.cpp") -create_single_source_cgal_program("CORE_Expr.cpp") create_single_source_cgal_program("Counted_number.cpp") create_single_source_cgal_program("double.cpp") create_single_source_cgal_program("doubletst.cpp") @@ -66,14 +62,17 @@ create_single_source_cgal_program("utilities.cpp") create_single_source_cgal_program("Exact_rational.cpp") create_single_source_cgal_program("Mpzf_new.cpp") -find_package( GMP ) -if( GMP_FOUND AND NOT CGAL_DISABLE_GMP ) +if( CGAL_CORE_FOUND ) create_single_source_cgal_program( "CORE_Expr_ticket_4296.cpp" ) + create_single_source_cgal_program("CORE_BigFloat.cpp") + create_single_source_cgal_program("CORE_BigInt.cpp") + create_single_source_cgal_program("CORE_BigRat.cpp") + create_single_source_cgal_program("CORE_Expr.cpp") find_package(MPFI QUIET) if( MPFI_FOUND ) include( ${MPFI_USE_FILE} ) endif() #MPFI_FOUND -endif() #GMP_FOUND AND NOT CGAL_DISABLE_GMP +endif() #CGAL_CORE_FOUND if(NOT CGAL_DISABLE_GMP) create_single_source_cgal_program( "Gmpfi.cpp" ) diff --git a/Number_types/test/Number_types/utilities.cpp b/Number_types/test/Number_types/utilities.cpp index 48400c975205..e716624ffaed 100644 --- a/Number_types/test/Number_types/utilities.cpp +++ b/Number_types/test/Number_types/utilities.cpp @@ -5,7 +5,10 @@ #include #include #include + +#ifdef CGAL_USE_BOOST_MP #include +#endif #ifdef CGAL_USE_GMP #include From 87ab37e92b860caacd5827a728c3f5328cb4713c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 14 Mar 2024 11:48:12 +0100 Subject: [PATCH 119/139] CORE no longer requires GMP so link only if available --- .../cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake b/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake index 17e0dd017385..a1bf37c0286b 100644 --- a/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake +++ b/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake @@ -49,7 +49,9 @@ set_property(GLOBAL PROPERTY CGAL_Core_FOUND TRUE) function(CGAL_setup_CGAL_Core_dependencies target) find_package( Boost 1.70 REQUIRED ) - use_CGAL_GMP_support(CGAL_Core INTERFACE) + if (!CGAL_DISABLE_GMP AND GMP_FOUND) + use_CGAL_GMP_support(CGAL_Core INTERFACE) + endif() target_compile_definitions(${target} INTERFACE CGAL_USE_CORE=1) target_link_libraries( CGAL_Core INTERFACE CGAL::CGAL ) endfunction() From 694099b6ecbb23db4eeb610b18923a6d74f16805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 14 Mar 2024 17:41:10 +0100 Subject: [PATCH 120/139] fix macro name --- Number_types/test/Number_types/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Number_types/test/Number_types/CMakeLists.txt b/Number_types/test/Number_types/CMakeLists.txt index 5496946fb287..73488a8a819b 100644 --- a/Number_types/test/Number_types/CMakeLists.txt +++ b/Number_types/test/Number_types/CMakeLists.txt @@ -62,7 +62,7 @@ create_single_source_cgal_program("utilities.cpp") create_single_source_cgal_program("Exact_rational.cpp") create_single_source_cgal_program("Mpzf_new.cpp") -if( CGAL_CORE_FOUND ) +if( CGAL_Core_FOUND ) create_single_source_cgal_program( "CORE_Expr_ticket_4296.cpp" ) create_single_source_cgal_program("CORE_BigFloat.cpp") create_single_source_cgal_program("CORE_BigInt.cpp") @@ -72,7 +72,7 @@ if( CGAL_CORE_FOUND ) if( MPFI_FOUND ) include( ${MPFI_USE_FILE} ) endif() #MPFI_FOUND -endif() #CGAL_CORE_FOUND +endif() #CGAL_Core_FOUND if(NOT CGAL_DISABLE_GMP) create_single_source_cgal_program( "Gmpfi.cpp" ) From 8981c376d34b82927d4b93e62988e9b1adf7c4cd Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 15 Mar 2024 09:39:05 +0100 Subject: [PATCH 121/139] casts for dealing with expression templates --- Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h | 4 ++-- CGAL_Core/include/CGAL/CORE/poly/Poly.tcc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h index 4f2071c4f736..fd0215a1a1e4 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h @@ -3822,9 +3822,9 @@ class Arr_conic_traits_2 { else { ys_end = m_nt_traits->solve_quadratic_equation(Integer(four*r*s*s - s*t*t), Integer(four*r*s*v - two*s*t*u), - Integer(r*v*v - t*u*v) + - Integer(t*t*w), + Integer((r*v*v - t*u*v) + (t*t*w)), ys); + n_ys = static_cast(ys_end - ys); } diff --git a/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc b/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc index 2352ac763390..8e95f92189c4 100644 --- a/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc +++ b/CGAL_Core/include/CGAL/CORE/poly/Poly.tcc @@ -922,7 +922,7 @@ BigInt Polynomial::CauchyBound() const { /* compute B^{deg} */ if (rhs <= lhs) { B <<= 1; - rhs *= (BigInt(1)<::UpperBound() const { /* compute B^{deg} */ if (rhs <= (std::max)(lhsPos,lhsNeg)) { B <<= 1; - rhs *= (BigInt(1)< Date: Fri, 15 Mar 2024 09:59:33 +0100 Subject: [PATCH 122/139] Use Core_found --- .../test/Arrangement_on_surface_2/cgal_test.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test.cmake b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test.cmake index 59f174e0ba60..bc8f8c10c5cb 100644 --- a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test.cmake +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test.cmake @@ -877,7 +877,7 @@ endfunction() #---------------------------------------------------------------------# function(test_polycurve_conic_traits) # echo polycurve test starting - if(CGAL_DISABLE_GMP) + if(NOT CGAL_Core_FOUND) MESSAGE(STATUS "test_polycurve_conic_traits requires CORE and will not be executed") return() endif() @@ -948,7 +948,7 @@ endfunction() # polycurve bezier traits #---------------------------------------------------------------------# function(test_polycurve_bezier_traits) - if(CGAL_DISABLE_GMP) + if(NOT CGAL_Core_FOUND) MESSAGE(STATUS "test_polycurve_bezier_traits requires CORE and will not be executed") return() endif() @@ -1057,7 +1057,7 @@ endfunction() # conic traits #---------------------------------------------------------------------# function(test_conic_traits) - if(CGAL_DISABLE_GMP) + if(NOT CGAL_Core_FOUND) MESSAGE(STATUS "test_conic_traits requires CORE and will not be executed") return() endif() @@ -1188,7 +1188,7 @@ endfunction() # bezier traits #---------------------------------------------------------------------# function(test_bezier_traits) - if(CGAL_DISABLE_GMP) + if(NOT CGAL_Core_FOUND) MESSAGE(STATUS "test_bezier_traits requires CORE and will not be executed") return() endif() @@ -1235,7 +1235,7 @@ endfunction() # rational arc traits #---------------------------------------------------------------------# function(test_rational_arc_traits) - if(CGAL_DISABLE_GMP) + if(NOT CGAL_Core_FOUND) MESSAGE(STATUS "test_rational_arc_traits requires CORE and will not be executed") return() endif() @@ -1302,7 +1302,7 @@ endfunction() #---------------------------------------------------------------------# function(test_algebraic_traits_core) #TODO: Adapt - if(CGAL_DISABLE_GMP) + if(NOT CGAL_Core_FOUND) MESSAGE(STATUS "test_algebraic_traits_core requires CORE and will not be executed") return() endif() From 6e1762c1093cc0937a448ab4c7552867fea45964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 15 Mar 2024 10:26:41 +0100 Subject: [PATCH 123/139] minimal supported version is now 1.72 workaround a bug with MSVC2017 --- Documentation/doc/Documentation/Third_party.txt | 2 +- .../doc/Documentation/advanced/Configuration_variables.txt | 4 ++-- Installation/CHANGES.md | 2 +- Installation/cmake/modules/CGAL_SetupBoost.cmake | 2 +- .../cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Documentation/doc/Documentation/Third_party.txt b/Documentation/doc/Documentation/Third_party.txt index 2d79cf4c0850..ceb3eb7e74a9 100644 --- a/Documentation/doc/Documentation/Third_party.txt +++ b/Documentation/doc/Documentation/Third_party.txt @@ -56,7 +56,7 @@ or `h The \stl comes with the compiler, and as such no installation is required. \subsection thirdpartyBoost Boost -Version 1.70 or later +Version 1.72 or later The \boost libraries are a set of portable C++ source libraries. Most of \boost libraries are header-only, but a few of them need to be compiled or diff --git a/Documentation/doc/Documentation/advanced/Configuration_variables.txt b/Documentation/doc/Documentation/advanced/Configuration_variables.txt index 7c475f547766..d4ac891a30f5 100644 --- a/Documentation/doc/Documentation/advanced/Configuration_variables.txt +++ b/Documentation/doc/Documentation/advanced/Configuration_variables.txt @@ -103,8 +103,8 @@ other but never both. \subsection installation_boost Boost Libraries -\subsubsection inst_boost_1_70_plus Version 1.70 and Later -Starting from \boost 1.70, the cmake config mode can be used for configuring the \boost version +\subsubsection inst_boost_1_72_plus Version 1.72 and Later +Starting from \boost 1.72, the cmake config mode can be used for configuring the \boost version to use by setting the environment variable `Boost_DIR` to the path containing the file `BoostConfig.cmake`. For example if you manually installed \boost 1.77 with `--prefix=`, then you should set `Boost_DIR=/lib/cmake/Boost-1.77.0`. diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index f7abc2e93120..efe152177f79 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -15,7 +15,7 @@ Release date: October 2023 - **Breaking change**: The usage of `boost::optional` has been replaced by `std::optional`. Packages affected are 2D Straight Line Skeleton, 3D Fast Intersection and Distance Computation (AABB Tree), and the Kernel intersection. - **Breaking change**: The usage of `boost::variant` has been replaced by `std::variant`. Packages affected are 2D Arrangements, and the Kernel intersection. - **Breaking change**: The file CMake file `UseCGAL.cmake` has been removed from CGAL. Usages of the CMake variables `${CGAL_USE_FILE}` and `${CGAL_LIBRARIES}` must be replaced by a link to the imported target `CGAL::CGAL`, for example: `target_link_library(the_target PRIVATE CGAL::CGAL)`. -- The minimal supported version of Boost is now 1.70.0 +- The minimal supported version of Boost is now 1.72.0 ### Installation diff --git a/Installation/cmake/modules/CGAL_SetupBoost.cmake b/Installation/cmake/modules/CGAL_SetupBoost.cmake index fccdd488a68f..dee2440dac28 100644 --- a/Installation/cmake/modules/CGAL_SetupBoost.cmake +++ b/Installation/cmake/modules/CGAL_SetupBoost.cmake @@ -19,7 +19,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/CGAL_TweakFindBoost.cmake) find_package( Boost 1.66 REQUIRED ) -if(Boost_FOUND AND Boost_VERSION VERSION_LESS 1.70) +if(Boost_FOUND AND Boost_VERSION VERSION_LESS 1.72) if(DEFINED Boost_DIR AND NOT Boost_DIR) # Unset that cache variable that is set in the cache by FindBoost # (while it was searching for boost-cmake). diff --git a/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake b/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake index a1bf37c0286b..816ae656fb43 100644 --- a/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake +++ b/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake @@ -48,7 +48,7 @@ set_property(GLOBAL PROPERTY CGAL_Core_FOUND TRUE) # function(CGAL_setup_CGAL_Core_dependencies target) - find_package( Boost 1.70 REQUIRED ) + find_package( Boost 1.72 REQUIRED ) if (!CGAL_DISABLE_GMP AND GMP_FOUND) use_CGAL_GMP_support(CGAL_Core INTERFACE) endif() From 3b1dd44081d07d6d8000e3221cec6633e1b3b887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 15 Mar 2024 11:18:56 +0100 Subject: [PATCH 124/139] WIP Expr constructor from expression --- CGAL_Core/include/CGAL/CORE/Expr.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CGAL_Core/include/CGAL/CORE/Expr.h b/CGAL_Core/include/CGAL/CORE/Expr.h index 7c8f348fa502..0c9109792860 100644 --- a/CGAL_Core/include/CGAL/CORE/Expr.h +++ b/CGAL_Core/include/CGAL/CORE/Expr.h @@ -91,6 +91,9 @@ class Expr : public RCExpr { Expr(const BigInt& I) : RCExpr(new ConstRealRep(Real(I))) {} /// constructor for BigRat Expr(const BigRat& R) : RCExpr(new ConstRealRep(Real(R))) {} + /// constructor for BigRat expression + template ::value> > + explicit Expr(const BigRatExpr& R) : RCExpr(new ConstRealRep(Real(BigRat(R)))) {} /// constructor for BigFloat Expr(const BigFloat& F) : RCExpr(new ConstRealRep(Real(F))) {} From 01f89b0ccc128c359a9d8d5f2b5a8ecbaa64c76b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 15 Mar 2024 11:37:18 +0100 Subject: [PATCH 125/139] make call no longer ambiguious --- CGAL_Core/include/CGAL/CORE/Expr.h | 2 +- Number_types/include/CGAL/CORE_BigFloat.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/Expr.h b/CGAL_Core/include/CGAL/CORE/Expr.h index 0c9109792860..c10fb5fc560b 100644 --- a/CGAL_Core/include/CGAL/CORE/Expr.h +++ b/CGAL_Core/include/CGAL/CORE/Expr.h @@ -93,7 +93,7 @@ class Expr : public RCExpr { Expr(const BigRat& R) : RCExpr(new ConstRealRep(Real(R))) {} /// constructor for BigRat expression template ::value> > - explicit Expr(const BigRatExpr& R) : RCExpr(new ConstRealRep(Real(BigRat(R)))) {} + Expr(const BigRatExpr& R) : RCExpr(new ConstRealRep(Real(BigRat(R)))) {} /// constructor for BigFloat Expr(const BigFloat& F) : RCExpr(new ConstRealRep(Real(F))) {} diff --git a/Number_types/include/CGAL/CORE_BigFloat.h b/Number_types/include/CGAL/CORE_BigFloat.h index 11934a244b97..81e9fcbaca60 100644 --- a/Number_types/include/CGAL/CORE_BigFloat.h +++ b/Number_types/include/CGAL/CORE_BigFloat.h @@ -326,7 +326,7 @@ template<> class Bigfloat_interval_traits NT w = Width()(x); w /= ::CORE::BigFloat(x.m()-x.err(),0,x.exp()); w = w.abs(); - return -(CORE::ceilLg(w.m()+w.err())+w.exp()*CORE::CHUNK_BIT); + return -(CORE::ceilLg(CORE::BigInt(w.m()+w.err()))+w.exp()*CORE::CHUNK_BIT); } }; From 47b264eb58e7834de377662f1f67986609dfadb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 15 Mar 2024 12:53:01 +0100 Subject: [PATCH 126/139] more disambiguation --- .../include/CGAL/Algebraic_kernel_d/Real_embeddable_extension.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Real_embeddable_extension.h b/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Real_embeddable_extension.h index 31e43a0f2dd0..e39e520899f2 100644 --- a/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Real_embeddable_extension.h +++ b/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Real_embeddable_extension.h @@ -337,7 +337,7 @@ class Real_embeddable_extension< CORE::BigFloat > { // (already commented out in EXACUS)... // NiX_precond(!(NiX::in_zero(x) && NiX::singleton(x))); x = CGAL::abs(x); - return CORE::ceilLg(x.m()+x.err())+x.exp()*CORE::CHUNK_BIT; + return CORE::ceilLg(CORE::BigInt(x.m()+x.err()))+x.exp()*CORE::CHUNK_BIT; } }; From 5f89d090b197ba8af5af27acaa8c9811acd4d93a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 15 Mar 2024 13:30:28 +0100 Subject: [PATCH 127/139] int/rat dispatch --- CGAL_Core/include/CGAL/CORE/Expr.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/Expr.h b/CGAL_Core/include/CGAL/CORE/Expr.h index c10fb5fc560b..e6efa1feb7cf 100644 --- a/CGAL_Core/include/CGAL/CORE/Expr.h +++ b/CGAL_Core/include/CGAL/CORE/Expr.h @@ -91,9 +91,14 @@ class Expr : public RCExpr { Expr(const BigInt& I) : RCExpr(new ConstRealRep(Real(I))) {} /// constructor for BigRat Expr(const BigRat& R) : RCExpr(new ConstRealRep(Real(R))) {} - /// constructor for BigRat expression - template ::value> > - Expr(const BigRatExpr& R) : RCExpr(new ConstRealRep(Real(BigRat(R)))) {} + /// constructor from expression template + template ::value> > + Expr(const TmplExpr& R) + : RCExpr(new ConstRealRep(Real( + std::conditional_t::value == boost::multiprecision::number_kind_integer, + BigInt, BigRat>(R)))) {} /// constructor for BigFloat Expr(const BigFloat& F) : RCExpr(new ConstRealRep(Real(F))) {} From dd9bf32ce46052148137c74de66e800c607c3e61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 15 Mar 2024 13:33:07 +0100 Subject: [PATCH 128/139] more disambiguation --- .../CGAL/Algebraic_kernel_d/Real_embeddable_extension.h | 2 +- CGAL_Core/include/CGAL/CORE/BigFloatRep.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Real_embeddable_extension.h b/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Real_embeddable_extension.h index e39e520899f2..9f06bc83383c 100644 --- a/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Real_embeddable_extension.h +++ b/Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Real_embeddable_extension.h @@ -327,7 +327,7 @@ class Real_embeddable_extension< CORE::BigFloat > { long operator()( CORE::BigFloat x ) const { CGAL_precondition(!CGAL::zero_in(x)); x = CGAL::abs(x); - return CORE::floorLg(x.m()-x.err())+x.exp()*CORE::CHUNK_BIT; + return CORE::floorLg(CORE::BigInt(x.m()-x.err()))+x.exp()*CORE::CHUNK_BIT; } }; diff --git a/CGAL_Core/include/CGAL/CORE/BigFloatRep.h b/CGAL_Core/include/CGAL/CORE/BigFloatRep.h index 4cb5f461b058..cce0771f06fa 100644 --- a/CGAL_Core/include/CGAL/CORE/BigFloatRep.h +++ b/CGAL_Core/include/CGAL/CORE/BigFloatRep.h @@ -317,7 +317,7 @@ inline void BigFloatRep::eliminateTrailingZeroes() { // builtin functions inline extLong BigFloatRep::lMSB() const { if (!isZeroIn()) - return extLong(floorLg(abs(m) - err)) + bits(exp); + return extLong(floorLg(BigInt(abs(m) - err))) + bits(exp); else return extLong(CORE_negInfty); } @@ -327,7 +327,7 @@ inline extLong BigFloatRep::lMSB() const { * Not well-defined if zero is in the interval. */ inline extLong BigFloatRep::uMSB() const { - return extLong(floorLg(abs(m) + err)) + bits(exp); + return extLong(floorLg(BigInt(abs(m) + err))) + bits(exp); } inline extLong BigFloatRep::MSB() const { From 02148db3de756bf05abb5a2f62724558d2c2e7ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 15 Mar 2024 14:56:57 +0100 Subject: [PATCH 129/139] add missing condition --- QP_solver/test/QP_solver/master_mps_to_derivatives.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/QP_solver/test/QP_solver/master_mps_to_derivatives.cpp b/QP_solver/test/QP_solver/master_mps_to_derivatives.cpp index b0af787b72e9..ad6fd7abc897 100644 --- a/QP_solver/test/QP_solver/master_mps_to_derivatives.cpp +++ b/QP_solver/test/QP_solver/master_mps_to_derivatives.cpp @@ -32,7 +32,9 @@ #include #include +#ifdef CGAL_USE_BOOST_MP #include +#endif //Currently already included in boost_mp.h //#ifdef CGAL_USE_BOOST_MP //# include From a26c93d8f6e428d67f38a7a8673281d546b77228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 19 Mar 2024 14:22:51 +0100 Subject: [PATCH 130/139] fix warnings --- CGAL_Core/include/CGAL/CORE/BigInt.h | 4 ++-- CGAL_Core/include/CGAL/CORE/Expr_impl.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index a66de01839e9..4dd1f1e8ecd7 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -87,7 +87,7 @@ inline bool isDivisible(long x, long y) { } /// get exponent of power 2 -inline unsigned long getBinExpo(const BigInt& z) { +inline auto getBinExpo(const BigInt& z) { if (z.is_zero()) { return (std::numeric_limits::max)(); } @@ -95,7 +95,7 @@ inline unsigned long getBinExpo(const BigInt& z) { } // bit length -inline int bitLength(const BigInt& a) { +inline auto bitLength(const BigInt& a) { if (a.is_zero()) { return 0; } diff --git a/CGAL_Core/include/CGAL/CORE/Expr_impl.h b/CGAL_Core/include/CGAL/CORE/Expr_impl.h index c21f88361a3e..0a36d169cf5c 100644 --- a/CGAL_Core/include/CGAL/CORE/Expr_impl.h +++ b/CGAL_Core/include/CGAL/CORE/Expr_impl.h @@ -1079,7 +1079,9 @@ void Expr::debug(int mode, int level, int depthLimit) const { else if (mode == Expr::TREE_MODE) rep->debugTree(level, 0, depthLimit); else + { CGAL_CORE_warning_msg(false, "unknown debugging mode"); + } std::cout << "---- End Expr debug(): " << std::endl; } From ae324aee83e1093fffd63cd905342cb88e2a4205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 19 Mar 2024 15:27:54 +0100 Subject: [PATCH 131/139] fix compilation issue + use boost mp type --- CGAL_Core/include/CGAL/CORE/BigFloat_impl.h | 2 +- CGAL_Core/include/CGAL/CORE/BigInt.h | 6 +++--- Number_types/include/CGAL/CORE_BigFloat.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h b/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h index b6eb9054c8e1..7bf616e8fda7 100644 --- a/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h +++ b/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h @@ -214,7 +214,7 @@ CGAL_INLINE_FUNCTION void BigFloatRep::approx(const BigFloatRep& B, const extLong& r, const extLong& a) { if (B.err) { - if (1 + clLg(B.err) <= bitLength(B.m)) + if (static_cast(1 + clLg(B.err)) <= bitLength(B.m)) truncM(B, r + 1, a); else // 1 + clLg(B.err) > lg(B.m) truncM(B, CORE_posInfty, a); diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 4dd1f1e8ecd7..a4b17f28937d 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -87,15 +87,15 @@ inline bool isDivisible(long x, long y) { } /// get exponent of power 2 -inline auto getBinExpo(const BigInt& z) { +inline unsigned getBinExpo(const BigInt& z) { if (z.is_zero()) { - return (std::numeric_limits::max)(); + return (std::numeric_limits::max)(); } return lsb(abs(z)); } // bit length -inline auto bitLength(const BigInt& a) { +inline unsigned bitLength(const BigInt& a){ if (a.is_zero()) { return 0; } diff --git a/Number_types/include/CGAL/CORE_BigFloat.h b/Number_types/include/CGAL/CORE_BigFloat.h index 81e9fcbaca60..b7da346a31b3 100644 --- a/Number_types/include/CGAL/CORE_BigFloat.h +++ b/Number_types/include/CGAL/CORE_BigFloat.h @@ -178,7 +178,7 @@ class Interval_traits // shift such that err.m()+err.err() fits into long int digits_long = std::numeric_limits::digits; - if(::CORE::bitLength(err.m()+err.err()) >= digits_long){ + if(::CORE::bitLength(err.m()+err.err()) >= static_cast(digits_long)){ long shift = ::CORE::bitLength(err.m()) - digits_long + 1 ; //std::cout << "shift " << shift<< std::endl; CORE::BigInt bi = (err.m() + err.err()); From 5dc53d720f7d27b27875c673f312a4a0ca0314ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 20 Mar 2024 10:54:37 +0100 Subject: [PATCH 132/139] use only fractions --- .../data/polycurves_bezier/points | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/points b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/points index b81a26dacc18..8d157a51908f 100644 --- a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/points +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/points @@ -7,18 +7,18 @@ # We need the bezier curve (not polycurve) to contruct a bezier point. # # Point ID: 0 -r c 4 0 0 500 200 100 200 900 0 0.5 +r c 4 0 0 500 200 100 200 900 0 1/2 # Point ID: 1 -r c 4 900 0 1200 600 1500 400 900 600 0.3 +r c 4 900 0 1200 600 1500 400 900 600 3/10 # Point id: 2 r c 4 0 0 100 200 500 200 900 0 0.0 # Point id: 3 -r c 4 900 0 1200 300 1500 400 2000 450 1.0 +r c 4 900 0 1200 300 1500 400 2000 450 1 # Point id: 4 -r c 4 2000 450 2100 300 2200 200 2300 450 0.0 +r c 4 2000 450 2100 300 2200 200 2300 450 0 # Point id: 5 -r c 4 2300 450 2500 500 2800 600 3000 450 1.0 +r c 4 2300 450 2500 500 2800 600 3000 450 1 # Point id: 6 r c 4 0 0 100 200 500 200 900 0 0.0 # Point id: 7 -r c 4 2300 450 2500 500 2800 600 3000 450 1.0 \ No newline at end of file +r c 4 2300 450 2500 500 2800 600 3000 450 1 \ No newline at end of file From c2494764679e56c37174a41a4879a30c7fdf4873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 20 Mar 2024 13:40:27 +0100 Subject: [PATCH 133/139] fix conversion warning follow the code rather than the doc... --- CGAL_Core/include/CGAL/CORE/BigFloat_impl.h | 2 +- CGAL_Core/include/CGAL/CORE/BigInt.h | 6 +++--- Number_types/include/CGAL/CORE_BigFloat.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h b/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h index 7bf616e8fda7..2fabfd36124f 100644 --- a/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h +++ b/CGAL_Core/include/CGAL/CORE/BigFloat_impl.h @@ -214,7 +214,7 @@ CGAL_INLINE_FUNCTION void BigFloatRep::approx(const BigFloatRep& B, const extLong& r, const extLong& a) { if (B.err) { - if (static_cast(1 + clLg(B.err)) <= bitLength(B.m)) + if (static_cast(1 + clLg(B.err)) <= bitLength(B.m)) truncM(B, r + 1, a); else // 1 + clLg(B.err) > lg(B.m) truncM(B, CORE_posInfty, a); diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index a4b17f28937d..57a6b649db4f 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -87,15 +87,15 @@ inline bool isDivisible(long x, long y) { } /// get exponent of power 2 -inline unsigned getBinExpo(const BigInt& z) { +inline std::size_t getBinExpo(const BigInt& z) { if (z.is_zero()) { - return (std::numeric_limits::max)(); + return (std::numeric_limits::max)(); } return lsb(abs(z)); } // bit length -inline unsigned bitLength(const BigInt& a){ +inline std::size_t bitLength(const BigInt& a){ if (a.is_zero()) { return 0; } diff --git a/Number_types/include/CGAL/CORE_BigFloat.h b/Number_types/include/CGAL/CORE_BigFloat.h index b7da346a31b3..b08ee62e363a 100644 --- a/Number_types/include/CGAL/CORE_BigFloat.h +++ b/Number_types/include/CGAL/CORE_BigFloat.h @@ -178,7 +178,7 @@ class Interval_traits // shift such that err.m()+err.err() fits into long int digits_long = std::numeric_limits::digits; - if(::CORE::bitLength(err.m()+err.err()) >= static_cast(digits_long)){ + if(::CORE::bitLength(err.m()+err.err()) >= static_cast(digits_long)){ long shift = ::CORE::bitLength(err.m()) - digits_long + 1 ; //std::cout << "shift " << shift<< std::endl; CORE::BigInt bi = (err.m() + err.err()); From 92ef5751278971c3195f706c4f9cb50eecc762b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 21 Mar 2024 10:26:11 +0100 Subject: [PATCH 134/139] use integer notation --- .../Arrangement_on_surface_2/data/polycurves_bezier/points | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/points b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/points index 8d157a51908f..0382a34de18c 100644 --- a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/points +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/data/polycurves_bezier/points @@ -11,7 +11,7 @@ r c 4 0 0 500 200 100 200 900 0 1/2 # Point ID: 1 r c 4 900 0 1200 600 1500 400 900 600 3/10 # Point id: 2 -r c 4 0 0 100 200 500 200 900 0 0.0 +r c 4 0 0 100 200 500 200 900 0 0 # Point id: 3 r c 4 900 0 1200 300 1500 400 2000 450 1 # Point id: 4 @@ -19,6 +19,6 @@ r c 4 2000 450 2100 300 2200 200 2300 450 0 # Point id: 5 r c 4 2300 450 2500 500 2800 600 3000 450 1 # Point id: 6 -r c 4 0 0 100 200 500 200 900 0 0.0 +r c 4 0 0 100 200 500 200 900 0 0 # Point id: 7 r c 4 2300 450 2500 500 2800 600 3000 450 1 \ No newline at end of file From 7d3bd7107a2b5b8a2631f46ae759cf19f0a68027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 21 Mar 2024 11:01:34 +0100 Subject: [PATCH 135/139] add extLong constructor from std::size_t try to workaround compilation issue on windows --- CGAL_Core/include/CGAL/CORE/extLong.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CGAL_Core/include/CGAL/CORE/extLong.h b/CGAL_Core/include/CGAL/CORE/extLong.h index 095c5105b8dd..1447842b61e7 100644 --- a/CGAL_Core/include/CGAL/CORE/extLong.h +++ b/CGAL_Core/include/CGAL/CORE/extLong.h @@ -31,6 +31,9 @@ #include #include +#include +#include + namespace CORE { #ifndef LONG_MAX @@ -77,6 +80,9 @@ class CGAL_CORE_EXPORT extLong { extLong(long); /// constructor for \c unsigned long extLong(unsigned long); + /// constructor for \c std::size_t + template>> + extLong(std::size_t s); //@} /// \name Arithmetic and assignment operators @@ -188,6 +194,17 @@ inline extLong::extLong(unsigned long u) { } } +template +inline extLong::extLong(std::size_t u) { + if (u >= (std::numeric_limits::max)()) { + val = EXTLONG_MAX; + flag = 1; + } else { + val = static_cast(u); + flag = 0; + } +} + // isNaN defaults to false inline extLong::extLong(bool isNaN) : val(0), flag(0) { if (isNaN) { From c2e89fc2cc9e08435acde48626fd0b3765b11e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 21 Mar 2024 11:27:26 +0100 Subject: [PATCH 136/139] also update minimal version in find --- Installation/cmake/modules/CGAL_SetupBoost.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Installation/cmake/modules/CGAL_SetupBoost.cmake b/Installation/cmake/modules/CGAL_SetupBoost.cmake index dee2440dac28..ee561027370d 100644 --- a/Installation/cmake/modules/CGAL_SetupBoost.cmake +++ b/Installation/cmake/modules/CGAL_SetupBoost.cmake @@ -17,7 +17,7 @@ set ( CGAL_Boost_Setup TRUE ) include(${CMAKE_CURRENT_LIST_DIR}/CGAL_TweakFindBoost.cmake) -find_package( Boost 1.66 REQUIRED ) +find_package( Boost 1.72 REQUIRED ) if(Boost_FOUND AND Boost_VERSION VERSION_LESS 1.72) if(DEFINED Boost_DIR AND NOT Boost_DIR) From 363c79f2c831db506b4e1d9c4a428482c3d79aac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 21 Mar 2024 12:30:59 +0100 Subject: [PATCH 137/139] please clang --- CGAL_Core/include/CGAL/CORE/extLong.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/extLong.h b/CGAL_Core/include/CGAL/CORE/extLong.h index 1447842b61e7..c4146ebad84a 100644 --- a/CGAL_Core/include/CGAL/CORE/extLong.h +++ b/CGAL_Core/include/CGAL/CORE/extLong.h @@ -81,8 +81,8 @@ class CGAL_CORE_EXPORT extLong { /// constructor for \c unsigned long extLong(unsigned long); /// constructor for \c std::size_t - template>> - extLong(std::size_t s); + template && !std::is_same_v>> + extLong(T s); //@} /// \name Arithmetic and assignment operators @@ -194,8 +194,8 @@ inline extLong::extLong(unsigned long u) { } } -template -inline extLong::extLong(std::size_t u) { +template +inline extLong::extLong(T u) { if (u >= (std::numeric_limits::max)()) { val = EXTLONG_MAX; flag = 1; From 93c94ca1156f08164461f2796b5ad9f26729066f Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 22 Mar 2024 11:28:50 +0100 Subject: [PATCH 138/139] static_cast and assertion that it fits --- CGAL_Core/include/CGAL/CORE/BigInt.h | 6 ++++-- Number_types/include/CGAL/CORE_BigFloat.h | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index 57a6b649db4f..cc23ecceafe1 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -107,7 +107,8 @@ inline std::size_t bitLength(const BigInt& a){ * This makes sense for integer a. */ inline long floorLg(const BigInt& a) { - return (sign(a) == 0) ? (-1) : (bitLength(a)-1); + assert(std::size_t((std::numeric_limits::max)()) > bitLength(a)); + return (sign(a) == 0) ? (-1) : static_cast(bitLength(a)-1); } @@ -157,7 +158,8 @@ inline BigInt gcd(const BigInt& a, const BigInt& b){ inline long ceilLg(const BigInt& a) { if (sign(a) == 0) return -1; - unsigned long len = bitLength(a); + assert(std::size_t((std::numeric_limits::max)()) > bitLength(a)); + long len = static_cast(bitLength(a)); return (lsb(abs(a)) == len - 1) ? (len - 1) : len; } diff --git a/Number_types/include/CGAL/CORE_BigFloat.h b/Number_types/include/CGAL/CORE_BigFloat.h index b08ee62e363a..e2def9175fb3 100644 --- a/Number_types/include/CGAL/CORE_BigFloat.h +++ b/Number_types/include/CGAL/CORE_BigFloat.h @@ -179,7 +179,8 @@ class Interval_traits // shift such that err.m()+err.err() fits into long int digits_long = std::numeric_limits::digits; if(::CORE::bitLength(err.m()+err.err()) >= static_cast(digits_long)){ - long shift = ::CORE::bitLength(err.m()) - digits_long + 1 ; + assert(std::size_t((std::numeric_limits::max)()) > ::CORE::bitLength(err.m())); + long shift = static_cast(::CORE::bitLength(err.m())) - digits_long + 1; //std::cout << "shift " << shift<< std::endl; CORE::BigInt bi = (err.m() + err.err()); bi = bi >> shift; @@ -274,9 +275,10 @@ round(const CORE::BigFloat& x, long rel_prec = CORE::get_static_defRelPrec().toL // long shift = ::CORE::bitLength(m) - rel_prec - 1; long shift ; - if (err == 0) - shift = ::CORE::bitLength(m) - rel_prec - 3; - else + if (err == 0) { + assert(std::size_t((std::numeric_limits::max)()) > ::CORE::bitLength(m)); + shift = static_cast(::CORE::bitLength(m)) - rel_prec - 3; + }else shift = CGAL::relative_precision(x) - rel_prec -1; if( shift > 0 ){ From 5b88dfa30be1ca489767ff7a61f23c960f78f5c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 22 Mar 2024 11:44:53 +0100 Subject: [PATCH 139/139] avoid another warning --- CGAL_Core/include/CGAL/CORE/BigInt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CGAL_Core/include/CGAL/CORE/BigInt.h b/CGAL_Core/include/CGAL/CORE/BigInt.h index cc23ecceafe1..8904db58b6f4 100644 --- a/CGAL_Core/include/CGAL/CORE/BigInt.h +++ b/CGAL_Core/include/CGAL/CORE/BigInt.h @@ -159,9 +159,9 @@ inline long ceilLg(const BigInt& a) { if (sign(a) == 0) return -1; assert(std::size_t((std::numeric_limits::max)()) > bitLength(a)); - long len = static_cast(bitLength(a)); + std::size_t len = static_cast(bitLength(a)); - return (lsb(abs(a)) == len - 1) ? (len - 1) : len; + return (lsb(abs(a)) == len - 1) ? (static_cast(len) - 1) : static_cast(len); } inline long ceilLg(long a) { // need this for Polynomial