From 4bb4fde1f73ee1eb9b600e905f6f5f10fdfc48f8 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 16 Jun 2017 17:38:47 +0200 Subject: [PATCH] Missing includes and I/O. --- .../include/CGAL/BOOST_MP_arithmetic_kernel.h | 1 + Number_types/include/CGAL/boost_mp.h | 24 +++++++++++++++++++ .../QP_solver/master_mps_to_derivatives.cpp | 17 ++++++++++++- 3 files changed, 41 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 101ee85e4c4..cbcb9cf699a 100644 --- a/Arithmetic_kernel/include/CGAL/BOOST_MP_arithmetic_kernel.h +++ b/Arithmetic_kernel/include/CGAL/BOOST_MP_arithmetic_kernel.h @@ -21,6 +21,7 @@ #include #include +#include // FIXME: the could be several kernels based on Boost.Multiprecision. diff --git a/Number_types/include/CGAL/boost_mp.h b/Number_types/include/CGAL/boost_mp.h index 9b92356d472..5e6c44f1db0 100644 --- a/Number_types/include/CGAL/boost_mp.h +++ b/Number_types/include/CGAL/boost_mp.h @@ -24,6 +24,7 @@ #include // We can't just include all Boost.Multiprecision here... #include +#include // TODO: work on the coercions (end of the file) @@ -452,6 +453,29 @@ CGAL_COERCE_FLOAT(float); CGAL_COERCE_FLOAT(double); #undef CGAL_COERCE_FLOAT +template <> +class Input_rep : public IO_rep_is_specialized { + mpq_class& q; +public: + Input_rep( mpq_class& qq) : q(qq) {} + std::istream& operator()( std::istream& in) const { + internal::read_float_or_quotient(in, q); + return in; + } +}; + +// 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); + } +} // namespace internal } //namespace CGAL 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 6bebf123b03..f6328cf001c 100644 --- a/QP_solver/test/QP_solver/master_mps_to_derivatives.cpp +++ b/QP_solver/test/QP_solver/master_mps_to_derivatives.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -58,6 +59,14 @@ namespace QP_from_mps_detail { struct MPS_type_name { static const char *name() { return "integer"; } }; + template<> + struct MPS_type_name { + static const char *name() { return "rational"; } + }; + template<> + struct MPS_type_name { + static const char *name() { return "integer"; } + }; #ifdef CGAL_USE_GMPXX template<> struct MPS_type_name { @@ -80,7 +89,9 @@ namespace QP_from_mps_detail { template<> struct MPS_type_name > { static const char *name() { return "rational"; } - }; template + }; + + template struct IT_to_ET { }; @@ -88,6 +99,10 @@ namespace QP_from_mps_detail { struct IT_to_ET { typedef CGAL::MP_Float ET; }; + template<> + struct IT_to_ET { + typedef boost::multiprecision::cpp_rational ET; + }; #ifdef CGAL_USE_GMP #ifdef CGAL_USE_GMPXX