Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORE: Use boost::multiprecision::number API #6035

Merged
merged 144 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
f536770
Use boost::multiprecision::number API (WIP)
afabri Oct 7, 2021
b801aaa
Fix getKaryExpo()
afabri Oct 7, 2021
945ba57
lsb works ony on positive numbers
afabri Oct 11, 2021
dc93a3e
fix include
sloriot Oct 11, 2021
b93c2ce
fixes while doing a review
sloriot Oct 11, 2021
e2f3851
revert changes
sloriot Oct 11, 2021
112b633
add tmp assertions
sloriot Oct 11, 2021
ed41c47
remove TWS
sloriot Oct 12, 2021
a7b0b30
Add an assert()
afabri Oct 12, 2021
ef4b0ca
Add implementations; Fix getBinExpo() for zero
afabri Oct 12, 2021
74040d9
msb(BigInt) is only defined for i > 0
afabri Oct 12, 2021
f13e149
I think we must call abs(); Someone has to check
afabri Oct 12, 2021
64a64e1
Add a makeCopy()
afabri Oct 13, 2021
4ede330
add a switch for the gmp backend
sloriot Oct 14, 2021
65b10f2
fix function
sloriot Jun 1, 2022
ee0ec71
add a template version of the constructor
sloriot Jun 2, 2022
32e89c1
add assertions
sloriot Jun 2, 2022
6fa89d7
Change minimum version number of boost
afabri Jun 6, 2022
2e3f44a
Require in CMake a recent boost when using CORE.
afabri Jun 6, 2022
b32d1f0
Merge branch 'master' into CORE-boost_mp_number-GF
afabri Oct 21, 2022
e98692d
WIP: Replace CORE::BigInt and BigRat with the boost::mp classes. Ju…
afabri Oct 25, 2022
89b2e34
trailing whitespace
afabri Oct 25, 2022
0fdc4e8
Add Eigen::Num_traits specializations
afabri Oct 26, 2022
7667782
typo
afabri Oct 26, 2022
03ae1c4
Add specialization for GMP backend
afabri Oct 26, 2022
af780e2
cleaning
afabri Oct 27, 2022
27ca0df
BigInt and BigRep are no longer real CORE storage
afabri Oct 27, 2022
a56d1a5
Simplify Coercion_traits
afabri Oct 27, 2022
e82ae36
take CORE into account in Boost mp's arithmetic kernel
sloriot Oct 27, 2022
1ba311a
Prefix macro with CORE_
afabri Oct 27, 2022
811e953
clenup
afabri Oct 27, 2022
81dc0a4
use GMP if boost less than 1.80
sloriot Oct 27, 2022
015b927
add Is_square
sloriot Oct 27, 2022
7c50cf7
Make Counted_number work
afabri Oct 27, 2022
d777cd0
Deal with expressions
afabri Oct 27, 2022
bf1f7d7
add missing inline
sloriot Oct 27, 2022
d498154
Remove #if 0'ed code
afabri Feb 6, 2023
12f5892
merge master
afabri Feb 6, 2023
47414fb
add missing include
sloriot Feb 7, 2023
2ca5d6b
Fix typo
afabri Feb 7, 2023
fb71e39
Add numerator() and denominator()
afabri Feb 7, 2023
2184d22
WIP [scip ci]
afabri Feb 7, 2023
7879e21
Replace constructor by conversion operator
afabri Feb 8, 2023
3c763fd
Remove CoreIO_impl.h
afabri Feb 9, 2023
c2fefe3
remove debug output
afabri Feb 9, 2023
50621a4
reactivate code
afabri Feb 10, 2023
3446b03
inline
afabri Feb 10, 2023
872e7b9
fixes
afabri Feb 10, 2023
f381162
Fix Root_of_traits
afabri Feb 17, 2023
535045a
trailing whitespace
afabri Feb 17, 2023
258d96f
No need for an overload
afabri Feb 17, 2023
8611d16
reduce package dependencies
afabri Feb 17, 2023
c9c82b9
Remove the #if 0'ed code
afabri Feb 17, 2023
acbe714
update rules for using/finding core
sloriot Feb 20, 2023
9e72361
All packages depends now on CGAL_Core (like Kernel)
sloriot Feb 20, 2023
996d173
Fix Envelope_3
afabri Mar 7, 2023
a714a6f
Fix Surface_sweep
afabri Mar 7, 2023
ba6893b
debug output, as I cannot reproduce locally
afabri Mar 7, 2023
7106e96
Fix Polynomial
afabri Mar 7, 2023
8b200b2
debug output, as I cannot reproduce locally
afabri Mar 7, 2023
d0ad8e0
Fix include guard
afabri Mar 7, 2023
cb9c995
Fix for Envelope_3
afabri Mar 8, 2023
ca47799
Add Need_parens_as_product for the GMP backend
afabri Mar 8, 2023
44d2893
Use the CGAL assertions/warnings/errors in Core
afabri Mar 9, 2023
89c9f90
Use CGAL_assertion_msg
afabri Mar 9, 2023
345e639
Remove function core_error()
afabri Mar 10, 2023
c5e9c98
Fix in Envelope_3
afabri Mar 10, 2023
2de196a
Add an expression to the CORE_Expr test that should be similiar to wh…
afabri Mar 10, 2023
1c00c64
Fix arrangement demo
afabri Mar 10, 2023
b9a1e18
Remove expression where I wanted to see for which platforms it does n…
afabri Mar 14, 2023
01e2aef
Fix in Real.h
afabri Mar 14, 2023
7fe1f09
Fix in Poly.tcc
afabri Mar 14, 2023
e68cf67
Fix in Env_sphere_traits_3
afabri Mar 14, 2023
0d320e4
Merge branch 'Number_types-fix_VC2017_boost_mp-GF' into CORE-boost_mp…
afabri Mar 17, 2023
d02adec
Fix Counted_number
afabri Mar 17, 2023
bb944fb
Fix in Real.h
afabri Mar 17, 2023
b66fd69
Arrangement_2
afabri Mar 17, 2023
7a3c58c
Real.h
afabri Mar 17, 2023
ef54ecb
Fix Minkowski_sum_2
afabri Mar 22, 2023
4a79ff4
Restore the original test file
afabri Mar 23, 2023
83b3c73
Add partial specializations of boost::multiprecision::is_byte_container
afabri Mar 23, 2023
5c6eda3
WIP: Add a boost::mp based equivalent to Mpzf
afabri Apr 5, 2023
6d7613f
fixes
afabri Apr 5, 2023
8ce4902
The Kernel_23 testsuite compiles
afabri Apr 5, 2023
caa9c46
Polyhedron demo compiles
afabri Apr 5, 2023
10c45ef
Add constructors
afabri Apr 5, 2023
fafc4fd
Fix sign
afabri Apr 5, 2023
80eebff
bug fix. todo: remove debug assertions
afabri Apr 5, 2023
9900004
simplify expressions
afabri Apr 6, 2023
c114802
Add constructor for expression
afabri Apr 6, 2023
b9b1be1
Set MinBits to 256 (as it is good for Dt3
afabri Apr 6, 2023
47bfc83
Use std::move()
afabri Apr 6, 2023
1d5f57e
256 -> 512 and no need for std::move()
afabri Apr 6, 2023
8a5fc31
example of perfect forwarding for Point_3
sloriot Apr 6, 2023
6eb866f
More forwarding
afabri Apr 6, 2023
e4558a4
Merge branch 'master' into CORE-boost_mp_number-GF
afabri Feb 23, 2024
97fbd69
remove duplicate line
afabri Feb 23, 2024
e204857
Fixes for expression templates
afabri Feb 23, 2024
4a222f1
fix the CI issue
lrineau Feb 26, 2024
30e9eac
Revert "More forwarding"
sloriot Feb 27, 2024
5ad84b0
Revert "example of perfect forwarding for Point_3"
sloriot Feb 27, 2024
f802557
sync with master@ec9de37b61
sloriot Feb 27, 2024
7e518c4
do not add Core while computing dependencies
sloriot Feb 27, 2024
3b30756
do not depend on CGAL_Core
sloriot Feb 27, 2024
910945e
undo dependency changes + always use core if not disabled
sloriot Feb 27, 2024
647d26e
actually core is now needed as it extends the gmp/boost arithmetic ke…
sloriot Feb 27, 2024
c9c089c
remove GMP specific files and hide GMP specific code
sloriot Feb 28, 2024
432449b
fix compilation issues
sloriot Feb 28, 2024
5825def
update license
sloriot Feb 28, 2024
0cb4b83
remove no longer used license
sloriot Feb 28, 2024
1847a46
update changes
sloriot Feb 28, 2024
2504625
qualify gcd calls
sloriot Feb 28, 2024
6da4e7a
remove non-used functions
sloriot Feb 28, 2024
cac4f5c
avoid GMP dependency
sloriot Feb 29, 2024
993991e
turn warning messages in errors for the testsuite
sloriot Feb 29, 2024
f130cfe
fix conversion error
sloriot Mar 1, 2024
4b5faba
disable warning/errors in the testsuite
sloriot Mar 1, 2024
d0d8efe
use GMP by default
sloriot Mar 6, 2024
4a30611
Add parenthesis to avoid warning
afabri Mar 7, 2024
7a0f3da
Update CGAL_Core/include/CGAL/CORE/extLong_impl.h
afabri Mar 7, 2024
44b7ec6
improve detection of cases when Core can be used
sloriot Mar 14, 2024
24015ce
fix conditional compilation of programs using CORE
sloriot Mar 14, 2024
87ab37e
CORE no longer requires GMP so link only if available
sloriot Mar 14, 2024
694099b
fix macro name
sloriot Mar 14, 2024
8981c37
casts for dealing with expression templates
afabri Mar 15, 2024
c8b37d3
Use Core_found
sloriot Mar 15, 2024
6e1762c
minimal supported version is now 1.72
sloriot Mar 15, 2024
3b1dd44
WIP Expr constructor from expression
sloriot Mar 15, 2024
01f89b0
make call no longer ambiguious
sloriot Mar 15, 2024
47b264e
more disambiguation
sloriot Mar 15, 2024
5f89d09
int/rat dispatch
sloriot Mar 15, 2024
dd9bf32
more disambiguation
sloriot Mar 15, 2024
02148db
add missing condition
sloriot Mar 15, 2024
a26c93d
fix warnings
sloriot Mar 19, 2024
ae324ae
fix compilation issue + use boost mp type
sloriot Mar 19, 2024
5dc53d7
use only fractions
sloriot Mar 20, 2024
c249476
fix conversion warning
sloriot Mar 20, 2024
92ef575
use integer notation
sloriot Mar 21, 2024
7d3bd71
add extLong constructor from std::size_t
sloriot Mar 21, 2024
c2e89fc
also update minimal version in find
sloriot Mar 21, 2024
363c79f
please clang
sloriot Mar 21, 2024
93c94ca
static_cast<long> and assertion that it fits
afabri Mar 22, 2024
5b88dfa
avoid another warning
sloriot Mar 22, 2024
a42ffde
Merge branch 'master' into CORE-boost_mp_number-GF
sloriot Mar 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Advancing_front_surface_reconstruction
Algebraic_foundations
Arithmetic_kernel
BGL
CGAL_Core
Cartesian_kernel
Circulator
Distance_2
Expand Down
6 changes: 3 additions & 3 deletions Algebraic_foundations/include/CGAL/Rational_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@ struct Rational_traits_base<Rational, true>
{
private:
typedef Fraction_traits<Rational> FT;
typedef typename FT::Decompose Decomose;
typedef typename FT::Decompose Decompose;
typedef typename FT::Compose Compose;

public:
typedef typename FT::Numerator_type RT;

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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ polynomial_power_to_bernstein_approx(
std::vector<Integer> 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
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,10 @@

#include <vector>

#if CGAL_USE_CORE
namespace CORE { class BigInt; }
#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 <class Shiftable>
Shiftable shift_integer_by(Shiftable x, long shift){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};

Expand All @@ -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;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Algebraic_foundations
Algebraic_kernel_for_circles
Arithmetic_kernel
CGAL_Core
Filtered_kernel
Installation
Interval_support
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Algebraic_foundations
Algebraic_kernel_for_spheres
Arithmetic_kernel
CGAL_Core
Filtered_kernel
Installation
Interval_support
Expand Down
1 change: 1 addition & 0 deletions Alpha_shapes_2/package_info/Alpha_shapes_2/dependencies
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Algebraic_foundations
Alpha_shapes_2
Arithmetic_kernel
CGAL_Core
Cartesian_kernel
Hash_map
Homogeneous_kernel
Expand Down
1 change: 1 addition & 0 deletions Alpha_shapes_3/package_info/Alpha_shapes_3/dependencies
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Algebraic_foundations
Alpha_shapes_3
Arithmetic_kernel
CGAL_Core
Cartesian_kernel
Circulator
Filtered_kernel
Expand Down
1 change: 1 addition & 0 deletions Alpha_wrap_3/package_info/Alpha_wrap_3/dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Alpha_wrap_3
Arithmetic_kernel
BGL
Box_intersection_d
CGAL_Core
Cartesian_kernel
Circulator
Distance_2
Expand Down
15 changes: 14 additions & 1 deletion Arithmetic_kernel/include/CGAL/BOOST_MP_arithmetic_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,40 @@

#ifdef CGAL_USE_BOOST_MP

#ifdef CGAL_USE_CORE
#include <CGAL/CORE_arithmetic_kernel.h>
#endif

//Currently already included in boost_mp.h
//#include <boost/multiprecision/cpp_int.hpp>
//#ifdef CGAL_USE_GMP
//#include <boost/multiprecision/gmp.hpp>
//#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 <class T1, class T2, class T3, class T4, class T5>
Expand Down
10 changes: 2 additions & 8 deletions Arithmetic_kernel/include/CGAL/CORE_arithmetic_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@ class CORE_arithmetic_kernel : public internal::Arithmetic_kernel_base {
};


template <>
struct Get_arithmetic_kernel<CORE::BigInt>{
typedef CORE_arithmetic_kernel Arithmetic_kernel;
};
template <>
struct Get_arithmetic_kernel<CORE::BigRat>{
typedef CORE_arithmetic_kernel Arithmetic_kernel;
};
template <>
struct Get_arithmetic_kernel<CORE::Expr>{
typedef CORE_arithmetic_kernel Arithmetic_kernel;
Expand All @@ -74,6 +66,8 @@ struct Get_arithmetic_kernel<CORE::BigFloat>{

} //namespace CGAL

#include <CGAL/BOOST_MP_arithmetic_kernel.h>

#endif // CGAL_USE_CORE

#endif // CGAL_CORE_ARITHMETIC_KERNEL_H
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,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 min_dist = (std::numeric_limits<double>::max)();
for (auto& vec : points) {
Expand Down
39 changes: 20 additions & 19 deletions Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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<int>(xs_end - xs);

Expand All @@ -3816,15 +3816,15 @@ 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) + (t*t*w)),
ys);

n_ys = static_cast<int>(ys_end - ys);
}

Expand All @@ -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)
{
Expand Down Expand Up @@ -3904,18 +3904,19 @@ 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<Integer>(t*t - four*r*s,
two*t*u - four*r*v,
u*u - four*r*w,
ys);
auto n = static_cast<int>(ys_end - ys);

// Compute the x coordinates and construct the horizontal tangency points.
for (int i = 0; i < n; ++i) {
// 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]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1430,8 +1430,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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1110,9 +1110,9 @@ class Conic_arc_2 {
//
Nt_traits nt_traits;
const int or_fact = (m_orient == CLOCKWISE) ? -1 : 1;
const Algebraic r = nt_traits.convert(or_fact * m_r);
const Algebraic s = nt_traits.convert(or_fact * m_s);
const Algebraic t = nt_traits.convert(or_fact * m_t);
const Algebraic r = nt_traits.convert(Integer(or_fact * m_r));
const Algebraic s = nt_traits.convert(Integer(or_fact * m_s));
const Algebraic t = nt_traits.convert(Integer(or_fact * m_t));
const Algebraic cos_2phi = (r - s) / nt_traits.sqrt((r-s)*(r-s) + t*t);
const Algebraic zero = 0;
const Algebraic one = 1;
Expand Down Expand Up @@ -1158,8 +1158,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 * m_u);
const Algebraic v = nt_traits.convert(or_fact * m_v);
const Algebraic u = nt_traits.convert(Integer(or_fact * m_u));
const Algebraic v = nt_traits.convert(Integer(or_fact * m_v));
const Algebraic det = 4*r*s - t*t;
Algebraic x0, y0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@ 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;

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;
}

Expand All @@ -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;
}

Expand Down
Loading
Loading