update boost
This commit is contained in:
@@ -1,36 +1,39 @@
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Copyright 2012 John Maddock. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_
|
||||
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#ifndef BOOST_MATH_CONCEPTS_ER_HPP
|
||||
#define BOOST_MATH_CONCEPTS_ER_HPP
|
||||
#ifndef BOOST_MP_MP_NUMBER_ARCHETYPES_HPP
|
||||
#define BOOST_MP_MP_NUMBER_ARCHETYPES_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <cmath>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <tuple>
|
||||
#include <functional>
|
||||
#include <boost/multiprecision/detail/standalone_config.hpp>
|
||||
#include <boost/multiprecision/number.hpp>
|
||||
#include <boost/math/special_functions/fpclassify.hpp>
|
||||
#include <boost/mpl/list.hpp>
|
||||
#include <boost/container_hash/hash.hpp>
|
||||
#include <boost/multiprecision/detail/no_exceptions_support.hpp>
|
||||
#include <boost/multiprecision/detail/fpclassify.hpp>
|
||||
|
||||
namespace boost{
|
||||
namespace multiprecision{
|
||||
namespace concepts{
|
||||
namespace boost {
|
||||
namespace multiprecision {
|
||||
namespace concepts {
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4244)
|
||||
#pragma warning(disable : 4244)
|
||||
#endif
|
||||
|
||||
struct number_backend_float_architype
|
||||
{
|
||||
typedef mpl::list<boost::long_long_type> signed_types;
|
||||
typedef mpl::list<boost::ulong_long_type> unsigned_types;
|
||||
typedef mpl::list<long double> float_types;
|
||||
typedef int exponent_type;
|
||||
using signed_types = std::tuple<long long> ;
|
||||
using unsigned_types = std::tuple<unsigned long long>;
|
||||
using float_types = std::tuple<long double>;
|
||||
using exponent_type = int;
|
||||
|
||||
number_backend_float_architype()
|
||||
{
|
||||
@@ -42,42 +45,51 @@ struct number_backend_float_architype
|
||||
std::cout << "Copy construct" << std::endl;
|
||||
m_value = o.m_value;
|
||||
}
|
||||
number_backend_float_architype& operator = (const number_backend_float_architype& o)
|
||||
number_backend_float_architype& operator=(const number_backend_float_architype& o)
|
||||
{
|
||||
m_value = o.m_value;
|
||||
std::cout << "Assignment (" << m_value << ")" << std::endl;
|
||||
return *this;
|
||||
}
|
||||
number_backend_float_architype& operator = (boost::ulong_long_type i)
|
||||
number_backend_float_architype& operator=(unsigned long long i)
|
||||
{
|
||||
m_value = i;
|
||||
std::cout << "UInt Assignment (" << i << ")" << std::endl;
|
||||
return *this;
|
||||
}
|
||||
number_backend_float_architype& operator = (boost::long_long_type i)
|
||||
number_backend_float_architype& operator=(long long i)
|
||||
{
|
||||
m_value = i;
|
||||
std::cout << "Int Assignment (" << i << ")" << std::endl;
|
||||
return *this;
|
||||
}
|
||||
number_backend_float_architype& operator = (long double d)
|
||||
number_backend_float_architype& operator=(long double d)
|
||||
{
|
||||
m_value = d;
|
||||
std::cout << "long double Assignment (" << d << ")" << std::endl;
|
||||
return *this;
|
||||
}
|
||||
number_backend_float_architype& operator = (const char* s)
|
||||
number_backend_float_architype& operator=(const char* s)
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif
|
||||
#ifndef BOOST_MP_STANDALONE
|
||||
m_value = boost::lexical_cast<long double>(s);
|
||||
#else
|
||||
m_value = std::strtold(s, nullptr);
|
||||
|
||||
if(m_value == HUGE_VALL || m_value == 0)
|
||||
{
|
||||
BOOST_MP_THROW_EXCEPTION(std::runtime_error("Value can not be assigned in standalone mode. Please disable and try again."));
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
}
|
||||
catch(const std::exception&)
|
||||
catch (const std::exception&)
|
||||
{
|
||||
BOOST_THROW_EXCEPTION(std::runtime_error(std::string("Unable to parse input string: \"") + s + std::string("\" as a valid floating point number.")));
|
||||
BOOST_MP_THROW_EXCEPTION(std::runtime_error(std::string("Unable to parse input string: \"") + s + std::string("\" as a valid floating point number.")));
|
||||
}
|
||||
#endif
|
||||
std::cout << "const char* Assignment (" << s << ")" << std::endl;
|
||||
@@ -88,19 +100,19 @@ struct number_backend_float_architype
|
||||
std::cout << "Swapping (" << m_value << " with " << o.m_value << ")" << std::endl;
|
||||
std::swap(m_value, o.m_value);
|
||||
}
|
||||
std::string str(std::streamsize digits, std::ios_base::fmtflags f)const
|
||||
std::string str(std::streamsize digits, std::ios_base::fmtflags f) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss.flags(f);
|
||||
if(digits)
|
||||
if (digits)
|
||||
ss.precision(digits);
|
||||
else
|
||||
ss.precision(std::numeric_limits<long double>::digits10 + 3);
|
||||
boost::intmax_t i = m_value;
|
||||
boost::uintmax_t u = m_value;
|
||||
if(!(f & std::ios_base::scientific) && m_value == i)
|
||||
std::intmax_t i = m_value;
|
||||
std::uintmax_t u = m_value;
|
||||
if (!(f & std::ios_base::scientific) && m_value == i)
|
||||
ss << i;
|
||||
else if(!(f & std::ios_base::scientific) && m_value == u)
|
||||
else if (!(f & std::ios_base::scientific) && m_value == u)
|
||||
ss << u;
|
||||
else
|
||||
ss << m_value;
|
||||
@@ -113,22 +125,22 @@ struct number_backend_float_architype
|
||||
std::cout << "Negating (" << m_value << ")" << std::endl;
|
||||
m_value = -m_value;
|
||||
}
|
||||
int compare(const number_backend_float_architype& o)const
|
||||
int compare(const number_backend_float_architype& o) const
|
||||
{
|
||||
std::cout << "Comparison" << std::endl;
|
||||
return m_value > o.m_value ? 1 : (m_value < o.m_value ? -1 : 0);
|
||||
}
|
||||
int compare(boost::long_long_type i)const
|
||||
int compare(long long i) const
|
||||
{
|
||||
std::cout << "Comparison with int" << std::endl;
|
||||
return m_value > i ? 1 : (m_value < i ? -1 : 0);
|
||||
}
|
||||
int compare(boost::ulong_long_type i)const
|
||||
int compare(unsigned long long i) const
|
||||
{
|
||||
std::cout << "Comparison with unsigned" << std::endl;
|
||||
return m_value > i ? 1 : (m_value < i ? -1 : 0);
|
||||
}
|
||||
int compare(long double d)const
|
||||
int compare(long double d) const
|
||||
{
|
||||
std::cout << "Comparison with long double" << std::endl;
|
||||
return m_value > d ? 1 : (m_value < d ? -1 : 0);
|
||||
@@ -157,13 +169,13 @@ inline void eval_divide(number_backend_float_architype& result, const number_bac
|
||||
result.m_value /= o.m_value;
|
||||
}
|
||||
|
||||
inline void eval_convert_to(boost::ulong_long_type* result, const number_backend_float_architype& val)
|
||||
inline void eval_convert_to(unsigned long long* result, const number_backend_float_architype& val)
|
||||
{
|
||||
*result = static_cast<boost::ulong_long_type>(val.m_value);
|
||||
*result = static_cast<unsigned long long>(val.m_value);
|
||||
}
|
||||
inline void eval_convert_to(boost::long_long_type* result, const number_backend_float_architype& val)
|
||||
inline void eval_convert_to(long long* result, const number_backend_float_architype& val)
|
||||
{
|
||||
*result = static_cast<boost::long_long_type>(val.m_value);
|
||||
*result = static_cast<long long>(val.m_value);
|
||||
}
|
||||
inline void eval_convert_to(long double* result, number_backend_float_architype& val)
|
||||
{
|
||||
@@ -197,44 +209,46 @@ inline void eval_sqrt(number_backend_float_architype& result, const number_backe
|
||||
|
||||
inline int eval_fpclassify(const number_backend_float_architype& arg)
|
||||
{
|
||||
return (boost::math::fpclassify)(arg.m_value);
|
||||
return BOOST_MP_FPCLASSIFY(arg.m_value);
|
||||
}
|
||||
|
||||
inline std::size_t hash_value(const number_backend_float_architype& v)
|
||||
{
|
||||
boost::hash<long double> hasher;
|
||||
std::hash<long double> hasher;
|
||||
return hasher(v.m_value);
|
||||
}
|
||||
|
||||
typedef boost::multiprecision::number<number_backend_float_architype> mp_number_float_architype;
|
||||
using mp_number_float_architype = boost::multiprecision::number<number_backend_float_architype>;
|
||||
|
||||
} // namespace
|
||||
} // namespace concepts
|
||||
|
||||
template<>
|
||||
struct number_category<concepts::number_backend_float_architype> : public mpl::int_<number_kind_floating_point>{};
|
||||
template <>
|
||||
struct number_category<concepts::number_backend_float_architype> : public std::integral_constant<int, number_kind_floating_point>
|
||||
{};
|
||||
|
||||
}} // namespaces
|
||||
}} // namespace boost::multiprecision
|
||||
|
||||
namespace std{
|
||||
namespace std {
|
||||
|
||||
template <boost::multiprecision::expression_template_option ExpressionTemplates>
|
||||
class numeric_limits<boost::multiprecision::number<boost::multiprecision::concepts::number_backend_float_architype, ExpressionTemplates> > : public std::numeric_limits<long double>
|
||||
{
|
||||
typedef std::numeric_limits<long double> base_type;
|
||||
typedef boost::multiprecision::number<boost::multiprecision::concepts::number_backend_float_architype, ExpressionTemplates> number_type;
|
||||
public:
|
||||
static number_type (min)() BOOST_NOEXCEPT { return (base_type::min)(); }
|
||||
static number_type (max)() BOOST_NOEXCEPT { return (base_type::max)(); }
|
||||
static number_type lowest() BOOST_NOEXCEPT { return -(max)(); }
|
||||
static number_type epsilon() BOOST_NOEXCEPT { return base_type::epsilon(); }
|
||||
static number_type round_error() BOOST_NOEXCEPT { return base_type::round_error(); }
|
||||
static number_type infinity() BOOST_NOEXCEPT { return base_type::infinity(); }
|
||||
static number_type quiet_NaN() BOOST_NOEXCEPT { return base_type::quiet_NaN(); }
|
||||
static number_type signaling_NaN() BOOST_NOEXCEPT { return base_type::signaling_NaN(); }
|
||||
static number_type denorm_min() BOOST_NOEXCEPT { return base_type::denorm_min(); }
|
||||
using base_type = std::numeric_limits<long double> ;
|
||||
using number_type = boost::multiprecision::number<boost::multiprecision::concepts::number_backend_float_architype, ExpressionTemplates>;
|
||||
|
||||
public:
|
||||
static number_type(min)() noexcept { return (base_type::min)(); }
|
||||
static number_type(max)() noexcept { return (base_type::max)(); }
|
||||
static number_type lowest() noexcept { return -(max)(); }
|
||||
static number_type epsilon() noexcept { return base_type::epsilon(); }
|
||||
static number_type round_error() noexcept { return base_type::round_error(); }
|
||||
static number_type infinity() noexcept { return base_type::infinity(); }
|
||||
static number_type quiet_NaN() noexcept { return base_type::quiet_NaN(); }
|
||||
static number_type signaling_NaN() noexcept { return base_type::signaling_NaN(); }
|
||||
static number_type denorm_min() noexcept { return base_type::denorm_min(); }
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace std
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
|
||||
Reference in New Issue
Block a user