/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* This file is part of the program and library */ /* PaPILO --- Parallel Presolve for Integer and Linear Optimization */ /* */ /* Copyright (C) 2020-2022 Konrad-Zuse-Zentrum */ /* fuer Informationstechnik Berlin */ /* */ /* This program is free software: you can redistribute it and/or modify */ /* it under the terms of the GNU Lesser General Public License as published */ /* by the Free Software Foundation, either version 3 of the License, or */ /* (at your option) any later version. */ /* */ /* This program is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public License */ /* along with this program. If not, see . */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifndef _PAPILO_MISC_MULTIPRECISION_HPP_ #define _PAPILO_MISC_MULTIPRECISION_HPP_ #include "papilo/Config.hpp" // work around build failure with boost on Fedora 37 #include #include #ifdef PAPILO_HAVE_FLOAT128 #include namespace papilo { using Quad = boost::multiprecision::float128; } // namespace papilo #elif defined( PAPILO_HAVE_GMP ) #include namespace papilo { using Quad = boost::multiprecision::number>; } // namespace papilo BOOST_SERIALIZATION_SPLIT_FREE( papilo::Quad ) #else #include #include namespace papilo { using Quad = boost::multiprecision::cpp_bin_float_quad; } // namespace papilo #endif #ifdef PAPILO_HAVE_GMP #include #include #include // unfortunately the multiprecision gmp types do not provide an overload for // serialization namespace papilo { using Rational = boost::multiprecision::mpq_rational; using Float100 = boost::multiprecision::mpf_float_100; using Float500 = boost::multiprecision::mpf_float_500; using Float1000 = boost::multiprecision::mpf_float_1000; } // namespace papilo BOOST_SERIALIZATION_SPLIT_FREE( papilo::Rational ) BOOST_SERIALIZATION_SPLIT_FREE( papilo::Float100 ) BOOST_SERIALIZATION_SPLIT_FREE( papilo::Float500 ) BOOST_SERIALIZATION_SPLIT_FREE( papilo::Float1000 ) namespace boost { namespace serialization { template void save( Archive& ar, const papilo::Rational& num, const unsigned int version ) { boost::multiprecision::cpp_rational t( num ); ar& t; } template void load( Archive& ar, papilo::Rational& num, const unsigned int version ) { boost::multiprecision::cpp_rational t; ar& t; num = papilo::Rational( t ); } template void save( Archive& ar, const boost::multiprecision::number>& num, const unsigned int version ) { boost::multiprecision::number> t( num ); ar& t; } template void load( Archive& ar, boost::multiprecision::number>& num, const unsigned int version ) { boost::multiprecision::number> t; ar& t; num = boost::multiprecision::number>( t ); } } // namespace serialization } // namespace boost #else #include #include #include namespace papilo { using Rational = boost::multiprecision::cpp_rational; using Float100 = boost::multiprecision::number>; using Float500 = boost::multiprecision::number>; using Float1000 = boost::multiprecision::number>; } // namespace papilo #endif #endif