2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

Merge pull request #541 from boostorg/e_float_2021

Re-vitalize e_float (2021) bindings for c++11
This commit is contained in:
Christopher Kormanyos
2021-02-24 20:16:13 +01:00
committed by GitHub
7 changed files with 38 additions and 915 deletions

View File

@@ -8,7 +8,6 @@ import path ;
local ntl-path = [ modules.peek : NTL_PATH ] ;
local gmp_path = [ modules.peek : GMP_PATH ] ;
local e_float_path = [ modules.peek : E_FLOAT_PATH ] ;
lib quadmath ;
lib fftw3 ;
@@ -26,7 +25,6 @@ obj has_gmpxx : has_gmpxx.cpp :
<include>$(gmp_path) <include>$(gmp_path)/mpfr <include>$(gmp_path)/gmpfrxx ;
obj has_gcc_visibility : has_gcc_visibility.cpp :
<toolset>gcc:<cxxflags>-fvisibility=hidden <toolset>gcc:<cxxflags>-Werror ;
obj has_e_float : has_e_float.cpp : <include>$(e_float_path) ;
exe has_float128 : has_float128.cpp quadmath ;
exe has_fftw3 : has_fftw3.cpp fftw3 fftw3f fftw3l ;
exe has_intel_quad : has_intel_quad.cpp : <cxxflags>-Qoption,cpp,--extended_float_type ;
@@ -44,7 +42,6 @@ explicit has_mpreal ;
explicit has_ntl_rr ;
explicit has_gmpxx ;
explicit has_gcc_visibility ;
explicit has_e_float ;
explicit has_float128 ;
explicit has_intel_quad ;
explicit has_128bit_floatmax_t ;

View File

@@ -1,15 +0,0 @@
// Copyright John Maddock 2011.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifdef _MSC_VER
# pragma warning (disable : 4100) // unreferenced formal parameter
#endif
#define E_FLOAT_TYPE_EFX
#include <e_float/e_float.h>
#include <functions/functions.h>

View File

@@ -197,18 +197,11 @@ There is a concept checking test program for mpfr support
__multiprecision was a development from the __e_float library by Christopher Kormanyos.
e_float can still be used with Boost.Math library via the header:
The e_float library can still be used with Boost.Math.
The [@http://github.com/ckormanyos/e_float-2021/blob/main/libs/math/include/boost/math/bindings/e_float.hpp/ e_float bindings header]
has been relocated to the [@http://github/ckormanyos/e_float-2021/ e_float-2021 repository].
<boost/math/bindings/e_float.hpp>
And the type `boost::math::ef::e_float`:
this type is a thin wrapper class around ::e_float which provides the necessary
syntactic sugar to make everything "just work".
There is also a concept checking test program for e_float support
[@../../../../libs/math/test/e_float_concept_check.cpp here].
[*New projects are recommended to use __multiprecision with `cpp_float` backend instead.]
[*New projects are recommended to use __multiprecision with one of its backends such as `cpp_bin_float` or `cpp_dec_float` instead.]
[endsect] [/section:e_float Using e_float Library]

View File

@@ -1,809 +0,0 @@
// Copyright John Maddock 2008.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Wrapper that works with mpfr_class defined in gmpfrxx.h
// See http://math.berkeley.edu/~wilken/code/gmpfrxx/
// Also requires the gmp and mpfr libraries.
//
#ifndef BOOST_MATH_E_FLOAT_BINDINGS_HPP
#define BOOST_MATH_E_FLOAT_BINDINGS_HPP
#include <boost/config.hpp>
#include <e_float/e_float.h>
#include <functions/functions.h>
#include <boost/math/tools/precision.hpp>
#include <boost/math/tools/real_cast.hpp>
#include <boost/math/policies/policy.hpp>
#include <boost/math/distributions/fwd.hpp>
#include <boost/math/special_functions/math_fwd.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include <boost/math/bindings/detail/big_digamma.hpp>
#include <boost/math/bindings/detail/big_lanczos.hpp>
#include <boost/lexical_cast.hpp>
#include <type_traits>
namespace boost{ namespace math{ namespace ef{
class e_float
{
public:
// Constructors:
e_float() {}
e_float(const ::e_float& c) : m_value(c){}
e_float(char c)
{
m_value = ::e_float(c);
}
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
e_float(wchar_t c)
{
m_value = ::e_float(c);
}
#endif
e_float(unsigned char c)
{
m_value = ::e_float(c);
}
e_float(signed char c)
{
m_value = ::e_float(c);
}
e_float(unsigned short c)
{
m_value = ::e_float(c);
}
e_float(short c)
{
m_value = ::e_float(c);
}
e_float(unsigned int c)
{
m_value = ::e_float(c);
}
e_float(int c)
{
m_value = ::e_float(c);
}
e_float(unsigned long c)
{
m_value = ::e_float((UINT64)c);
}
e_float(long c)
{
m_value = ::e_float((INT64)c);
}
#ifdef BOOST_HAS_LONG_LONG
e_float(boost::ulong_long_type c)
{
m_value = ::e_float(c);
}
e_float(boost::long_long_type c)
{
m_value = ::e_float(c);
}
#endif
e_float(float c)
{
assign_large_real(c);
}
e_float(double c)
{
assign_large_real(c);
}
e_float(long double c)
{
assign_large_real(c);
}
// Assignment:
e_float& operator=(char c) { m_value = ::e_float(c); return *this; }
e_float& operator=(unsigned char c) { m_value = ::e_float(c); return *this; }
e_float& operator=(signed char c) { m_value = ::e_float(c); return *this; }
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
e_float& operator=(wchar_t c) { m_value = ::e_float(c); return *this; }
#endif
e_float& operator=(short c) { m_value = ::e_float(c); return *this; }
e_float& operator=(unsigned short c) { m_value = ::e_float(c); return *this; }
e_float& operator=(int c) { m_value = ::e_float(c); return *this; }
e_float& operator=(unsigned int c) { m_value = ::e_float(c); return *this; }
e_float& operator=(long c) { m_value = ::e_float((INT64)c); return *this; }
e_float& operator=(unsigned long c) { m_value = ::e_float((UINT64)c); return *this; }
#ifdef BOOST_HAS_LONG_LONG
e_float& operator=(boost::long_long_type c) { m_value = ::e_float(c); return *this; }
e_float& operator=(boost::ulong_long_type c) { m_value = ::e_float(c); return *this; }
#endif
e_float& operator=(float c) { assign_large_real(c); return *this; }
e_float& operator=(double c) { assign_large_real(c); return *this; }
e_float& operator=(long double c) { assign_large_real(c); return *this; }
// Access:
::e_float& value(){ return m_value; }
::e_float const& value()const{ return m_value; }
// Member arithmetic:
e_float& operator+=(const e_float& other)
{ m_value += other.value(); return *this; }
e_float& operator-=(const e_float& other)
{ m_value -= other.value(); return *this; }
e_float& operator*=(const e_float& other)
{ m_value *= other.value(); return *this; }
e_float& operator/=(const e_float& other)
{ m_value /= other.value(); return *this; }
e_float operator-()const
{ return -m_value; }
e_float const& operator+()const
{ return *this; }
private:
::e_float m_value;
template <class V>
void assign_large_real(const V& a)
{
using std::frexp;
using std::ldexp;
using std::floor;
if (a == 0) {
m_value = ::ef::zero();
return;
}
if (a == 1) {
m_value = ::ef::one();
return;
}
if ((boost::math::isinf)(a))
{
m_value = a > 0 ? m_value.my_value_inf() : -m_value.my_value_inf();
return;
}
if((boost::math::isnan)(a))
{
m_value = m_value.my_value_nan();
return;
}
int e;
long double f, term;
::e_float t;
m_value = ::ef::zero();
f = frexp(a, &e);
::e_float shift = ::ef::pow2(30);
while(f)
{
// extract 30 bits from f:
f = ldexp(f, 30);
term = floor(f);
e -= 30;
m_value *= shift;
m_value += ::e_float(static_cast<INT64>(term));
f -= term;
}
m_value *= ::ef::pow2(e);
}
};
// Non-member arithmetic:
inline e_float operator+(const e_float& a, const e_float& b)
{
e_float result(a);
result += b;
return result;
}
inline e_float operator-(const e_float& a, const e_float& b)
{
e_float result(a);
result -= b;
return result;
}
inline e_float operator*(const e_float& a, const e_float& b)
{
e_float result(a);
result *= b;
return result;
}
inline e_float operator/(const e_float& a, const e_float& b)
{
e_float result(a);
result /= b;
return result;
}
// Comparison:
inline bool operator == (const e_float& a, const e_float& b)
{ return a.value() == b.value() ? true : false; }
inline bool operator != (const e_float& a, const e_float& b)
{ return a.value() != b.value() ? true : false;}
inline bool operator < (const e_float& a, const e_float& b)
{ return a.value() < b.value() ? true : false; }
inline bool operator <= (const e_float& a, const e_float& b)
{ return a.value() <= b.value() ? true : false; }
inline bool operator > (const e_float& a, const e_float& b)
{ return a.value() > b.value() ? true : false; }
inline bool operator >= (const e_float& a, const e_float& b)
{ return a.value() >= b.value() ? true : false; }
std::istream& operator >> (std::istream& is, e_float& f)
{
return is >> f.value();
}
std::ostream& operator << (std::ostream& os, const e_float& f)
{
return os << f.value();
}
inline e_float fabs(const e_float& v)
{
return ::ef::fabs(v.value());
}
inline e_float abs(const e_float& v)
{
return ::ef::fabs(v.value());
}
inline e_float floor(const e_float& v)
{
return ::ef::floor(v.value());
}
inline e_float ceil(const e_float& v)
{
return ::ef::ceil(v.value());
}
inline e_float pow(const e_float& v, const e_float& w)
{
return ::ef::pow(v.value(), w.value());
}
inline e_float pow(const e_float& v, int i)
{
return ::ef::pow(v.value(), ::e_float(i));
}
inline e_float exp(const e_float& v)
{
return ::ef::exp(v.value());
}
inline e_float log(const e_float& v)
{
return ::ef::log(v.value());
}
inline e_float sqrt(const e_float& v)
{
return ::ef::sqrt(v.value());
}
inline e_float sin(const e_float& v)
{
return ::ef::sin(v.value());
}
inline e_float cos(const e_float& v)
{
return ::ef::cos(v.value());
}
inline e_float tan(const e_float& v)
{
return ::ef::tan(v.value());
}
inline e_float acos(const e_float& v)
{
return ::ef::acos(v.value());
}
inline e_float asin(const e_float& v)
{
return ::ef::asin(v.value());
}
inline e_float atan(const e_float& v)
{
return ::ef::atan(v.value());
}
inline e_float atan2(const e_float& v, const e_float& u)
{
return ::ef::atan2(v.value(), u.value());
}
inline e_float ldexp(const e_float& v, int e)
{
return v.value() * ::ef::pow2(e);
}
inline e_float frexp(const e_float& v, int* expon)
{
double d;
INT64 i;
v.value().extract_parts(d, i);
*expon = static_cast<int>(i);
return v.value() * ::ef::pow2(-i);
}
inline e_float sinh (const e_float& x)
{
return ::ef::sinh(x.value());
}
inline e_float cosh (const e_float& x)
{
return ::ef::cosh(x.value());
}
inline e_float tanh (const e_float& x)
{
return ::ef::tanh(x.value());
}
inline e_float asinh (const e_float& x)
{
return ::ef::asinh(x.value());
}
inline e_float acosh (const e_float& x)
{
return ::ef::acosh(x.value());
}
inline e_float atanh (const e_float& x)
{
return ::ef::atanh(x.value());
}
e_float fmod(const e_float& v1, const e_float& v2)
{
e_float n;
if(v1 < 0)
n = ceil(v1 / v2);
else
n = floor(v1 / v2);
return v1 - n * v2;
}
} namespace detail{
template <>
inline int fpclassify_imp< boost::math::ef::e_float> BOOST_NO_MACRO_EXPAND(boost::math::ef::e_float x, const generic_tag<true>&)
{
if(x.value().isnan())
return FP_NAN;
if(x.value().isinf())
return FP_INFINITE;
if(x == 0)
return FP_ZERO;
return FP_NORMAL;
}
} namespace ef{
template <class Policy>
inline int itrunc(const e_float& v, const Policy& pol)
{
BOOST_MATH_STD_USING
e_float r = boost::math::trunc(v, pol);
if(fabs(r) > (std::numeric_limits<int>::max)())
return static_cast<int>(policies::raise_rounding_error("boost::math::itrunc<%1%>(%1%)", 0, 0, v, pol));
return static_cast<int>(r.value().extract_int64());
}
template <class Policy>
inline long ltrunc(const e_float& v, const Policy& pol)
{
BOOST_MATH_STD_USING
e_float r = boost::math::trunc(v, pol);
if(fabs(r) > (std::numeric_limits<long>::max)())
return static_cast<long>(policies::raise_rounding_error("boost::math::ltrunc<%1%>(%1%)", 0, 0L, v, pol));
return static_cast<long>(r.value().extract_int64());
}
#ifdef BOOST_HAS_LONG_LONG
template <class Policy>
inline boost::long_long_type lltrunc(const e_float& v, const Policy& pol)
{
BOOST_MATH_STD_USING
e_float r = boost::math::trunc(v, pol);
if(fabs(r) > (std::numeric_limits<boost::long_long_type>::max)())
return static_cast<boost::long_long_type>(policies::raise_rounding_error("boost::math::lltrunc<%1%>(%1%)", 0, v, 0LL, pol).value().extract_int64());
return static_cast<boost::long_long_type>(r.value().extract_int64());
}
#endif
template <class Policy>
inline int iround(const e_float& v, const Policy& pol)
{
BOOST_MATH_STD_USING
e_float r = boost::math::round(v, pol);
if(fabs(r) > (std::numeric_limits<int>::max)())
return static_cast<int>(policies::raise_rounding_error("boost::math::iround<%1%>(%1%)", 0, v, 0, pol).value().extract_int64());
return static_cast<int>(r.value().extract_int64());
}
template <class Policy>
inline long lround(const e_float& v, const Policy& pol)
{
BOOST_MATH_STD_USING
e_float r = boost::math::round(v, pol);
if(fabs(r) > (std::numeric_limits<long>::max)())
return static_cast<long int>(policies::raise_rounding_error("boost::math::lround<%1%>(%1%)", 0, v, 0L, pol).value().extract_int64());
return static_cast<long int>(r.value().extract_int64());
}
#ifdef BOOST_HAS_LONG_LONG
template <class Policy>
inline boost::long_long_type llround(const e_float& v, const Policy& pol)
{
BOOST_MATH_STD_USING
e_float r = boost::math::round(v, pol);
if(fabs(r) > (std::numeric_limits<boost::long_long_type>::max)())
return static_cast<boost::long_long_type>(policies::raise_rounding_error("boost::math::llround<%1%>(%1%)", 0, v, 0LL, pol).value().extract_int64());
return static_cast<boost::long_long_type>(r.value().extract_int64());
}
#endif
}}}
namespace std{
template<>
class numeric_limits< ::boost::math::ef::e_float> : public numeric_limits< ::e_float>
{
public:
static const ::boost::math::ef::e_float (min) (void)
{
return (numeric_limits< ::e_float>::min)();
}
static const ::boost::math::ef::e_float (max) (void)
{
return (numeric_limits< ::e_float>::max)();
}
static const ::boost::math::ef::e_float epsilon (void)
{
return (numeric_limits< ::e_float>::epsilon)();
}
static const ::boost::math::ef::e_float round_error(void)
{
return (numeric_limits< ::e_float>::round_error)();
}
static const ::boost::math::ef::e_float infinity (void)
{
return (numeric_limits< ::e_float>::infinity)();
}
static const ::boost::math::ef::e_float quiet_NaN (void)
{
return (numeric_limits< ::e_float>::quiet_NaN)();
}
//
// e_float's supplied digits member is wrong
// - it should be same the same as digits 10
// - given that radix is 10.
//
static const int digits = digits10;
};
} // namespace std
namespace boost{ namespace math{
namespace policies{
template <class Policy>
struct precision< ::boost::math::ef::e_float, Policy>
{
typedef typename Policy::precision_type precision_type;
typedef digits2<((::std::numeric_limits< ::boost::math::ef::e_float>::digits10 + 1) * 1000L) / 301L> digits_2;
typedef typename std::conditional<
((digits_2::value <= precision_type::value)
|| (Policy::precision_type::value <= 0)),
// Default case, full precision for RealType:
digits_2,
// User customised precision:
precision_type
>::type type;
};
}
namespace tools{
template <>
inline int digits< ::boost::math::ef::e_float>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC( ::boost::math::ef::e_float))
{
return ((::std::numeric_limits< ::boost::math::ef::e_float>::digits10 + 1) * 1000L) / 301L;
}
template <>
inline ::boost::math::ef::e_float root_epsilon< ::boost::math::ef::e_float>()
{
return detail::root_epsilon_imp(static_cast< ::boost::math::ef::e_float const*>(0), std::integral_constant<int, 0>());
}
template <>
inline ::boost::math::ef::e_float forth_root_epsilon< ::boost::math::ef::e_float>()
{
return detail::forth_root_epsilon_imp(static_cast< ::boost::math::ef::e_float const*>(0), std::integral_constant<int, 0>());
}
}
namespace lanczos{
template<class Policy>
struct lanczos<boost::math::ef::e_float, Policy>
{
typedef typename std::conditional<
std::numeric_limits< ::e_float>::digits10 < 22,
lanczos13UDT,
typename std::conditional<
std::numeric_limits< ::e_float>::digits10 < 36,
lanczos22UDT,
typename std::conditional<
std::numeric_limits< ::e_float>::digits10 < 50,
lanczos31UDT,
typename std::conditional<
std::numeric_limits< ::e_float>::digits10 < 110,
lanczos61UDT,
undefined_lanczos
>::type
>::type
>::type
>::type type;
};
} // namespace lanczos
template <class Policy>
inline boost::math::ef::e_float skewness(const extreme_value_distribution<boost::math::ef::e_float, Policy>& /*dist*/)
{
//
// This is 12 * sqrt(6) * zeta(3) / pi^3:
// See http://mathworld.wolfram.com/ExtremeValueDistribution.html
//
return boost::lexical_cast<boost::math::ef::e_float>("1.1395470994046486574927930193898461120875997958366");
}
template <class Policy>
inline boost::math::ef::e_float skewness(const rayleigh_distribution<boost::math::ef::e_float, Policy>& /*dist*/)
{
// using namespace boost::math::constants;
return boost::lexical_cast<boost::math::ef::e_float>("0.63111065781893713819189935154422777984404221106391");
// Computed using NTL at 150 bit, about 50 decimal digits.
// return 2 * root_pi<RealType>() * pi_minus_three<RealType>() / pow23_four_minus_pi<RealType>();
}
template <class Policy>
inline boost::math::ef::e_float kurtosis(const rayleigh_distribution<boost::math::ef::e_float, Policy>& /*dist*/)
{
// using namespace boost::math::constants;
return boost::lexical_cast<boost::math::ef::e_float>("3.2450893006876380628486604106197544154170667057995");
// Computed using NTL at 150 bit, about 50 decimal digits.
// return 3 - (6 * pi<RealType>() * pi<RealType>() - 24 * pi<RealType>() + 16) /
// (four_minus_pi<RealType>() * four_minus_pi<RealType>());
}
template <class Policy>
inline boost::math::ef::e_float kurtosis_excess(const rayleigh_distribution<boost::math::ef::e_float, Policy>& /*dist*/)
{
//using namespace boost::math::constants;
// Computed using NTL at 150 bit, about 50 decimal digits.
return boost::lexical_cast<boost::math::ef::e_float>("0.2450893006876380628486604106197544154170667057995");
// return -(6 * pi<RealType>() * pi<RealType>() - 24 * pi<RealType>() + 16) /
// (four_minus_pi<RealType>() * four_minus_pi<RealType>());
} // kurtosis
namespace detail{
//
// Version of Digamma accurate to ~100 decimal digits.
//
template <class Policy>
boost::math::ef::e_float digamma_imp(boost::math::ef::e_float x, const std::integral_constant<int, 0>* , const Policy& pol)
{
//
// This handles reflection of negative arguments, and all our
// eboost::math::ef::e_floator handling, then forwards to the T-specific approximation.
//
BOOST_MATH_STD_USING // ADL of std functions.
boost::math::ef::e_float result = 0;
//
// Check for negative arguments and use reflection:
//
if(x < 0)
{
// Reflect:
x = 1 - x;
// Argument reduction for tan:
boost::math::ef::e_float remainder = x - floor(x);
// Shift to negative if > 0.5:
if(remainder > 0.5)
{
remainder -= 1;
}
//
// check for evaluation at a negative pole:
//
if(remainder == 0)
{
return policies::raise_pole_error<boost::math::ef::e_float>("boost::math::digamma<%1%>(%1%)", 0, (1-x), pol);
}
result = constants::pi<boost::math::ef::e_float>() / tan(constants::pi<boost::math::ef::e_float>() * remainder);
}
result += big_digamma(x);
return result;
}
boost::math::ef::e_float bessel_i0(boost::math::ef::e_float x)
{
static const boost::math::ef::e_float P1[] = {
boost::lexical_cast<boost::math::ef::e_float>("-2.2335582639474375249e+15"),
boost::lexical_cast<boost::math::ef::e_float>("-5.5050369673018427753e+14"),
boost::lexical_cast<boost::math::ef::e_float>("-3.2940087627407749166e+13"),
boost::lexical_cast<boost::math::ef::e_float>("-8.4925101247114157499e+11"),
boost::lexical_cast<boost::math::ef::e_float>("-1.1912746104985237192e+10"),
boost::lexical_cast<boost::math::ef::e_float>("-1.0313066708737980747e+08"),
boost::lexical_cast<boost::math::ef::e_float>("-5.9545626019847898221e+05"),
boost::lexical_cast<boost::math::ef::e_float>("-2.4125195876041896775e+03"),
boost::lexical_cast<boost::math::ef::e_float>("-7.0935347449210549190e+00"),
boost::lexical_cast<boost::math::ef::e_float>("-1.5453977791786851041e-02"),
boost::lexical_cast<boost::math::ef::e_float>("-2.5172644670688975051e-05"),
boost::lexical_cast<boost::math::ef::e_float>("-3.0517226450451067446e-08"),
boost::lexical_cast<boost::math::ef::e_float>("-2.6843448573468483278e-11"),
boost::lexical_cast<boost::math::ef::e_float>("-1.5982226675653184646e-14"),
boost::lexical_cast<boost::math::ef::e_float>("-5.2487866627945699800e-18"),
};
static const boost::math::ef::e_float Q1[] = {
boost::lexical_cast<boost::math::ef::e_float>("-2.2335582639474375245e+15"),
boost::lexical_cast<boost::math::ef::e_float>("7.8858692566751002988e+12"),
boost::lexical_cast<boost::math::ef::e_float>("-1.2207067397808979846e+10"),
boost::lexical_cast<boost::math::ef::e_float>("1.0377081058062166144e+07"),
boost::lexical_cast<boost::math::ef::e_float>("-4.8527560179962773045e+03"),
boost::lexical_cast<boost::math::ef::e_float>("1.0"),
};
static const boost::math::ef::e_float P2[] = {
boost::lexical_cast<boost::math::ef::e_float>("-2.2210262233306573296e-04"),
boost::lexical_cast<boost::math::ef::e_float>("1.3067392038106924055e-02"),
boost::lexical_cast<boost::math::ef::e_float>("-4.4700805721174453923e-01"),
boost::lexical_cast<boost::math::ef::e_float>("5.5674518371240761397e+00"),
boost::lexical_cast<boost::math::ef::e_float>("-2.3517945679239481621e+01"),
boost::lexical_cast<boost::math::ef::e_float>("3.1611322818701131207e+01"),
boost::lexical_cast<boost::math::ef::e_float>("-9.6090021968656180000e+00"),
};
static const boost::math::ef::e_float Q2[] = {
boost::lexical_cast<boost::math::ef::e_float>("-5.5194330231005480228e-04"),
boost::lexical_cast<boost::math::ef::e_float>("3.2547697594819615062e-02"),
boost::lexical_cast<boost::math::ef::e_float>("-1.1151759188741312645e+00"),
boost::lexical_cast<boost::math::ef::e_float>("1.3982595353892851542e+01"),
boost::lexical_cast<boost::math::ef::e_float>("-6.0228002066743340583e+01"),
boost::lexical_cast<boost::math::ef::e_float>("8.5539563258012929600e+01"),
boost::lexical_cast<boost::math::ef::e_float>("-3.1446690275135491500e+01"),
boost::lexical_cast<boost::math::ef::e_float>("1.0"),
};
boost::math::ef::e_float value, factor, r;
BOOST_MATH_STD_USING
using namespace boost::math::tools;
if (x < 0)
{
x = -x; // even function
}
if (x == 0)
{
return static_cast<boost::math::ef::e_float>(1);
}
if (x <= 15) // x in (0, 15]
{
boost::math::ef::e_float y = x * x;
value = evaluate_polynomial(P1, y) / evaluate_polynomial(Q1, y);
}
else // x in (15, \infty)
{
boost::math::ef::e_float y = 1 / x - boost::math::ef::e_float(1) / 15;
r = evaluate_polynomial(P2, y) / evaluate_polynomial(Q2, y);
factor = exp(x) / sqrt(x);
value = factor * r;
}
return value;
}
boost::math::ef::e_float bessel_i1(boost::math::ef::e_float x)
{
static const boost::math::ef::e_float P1[] = {
lexical_cast<boost::math::ef::e_float>("-1.4577180278143463643e+15"),
lexical_cast<boost::math::ef::e_float>("-1.7732037840791591320e+14"),
lexical_cast<boost::math::ef::e_float>("-6.9876779648010090070e+12"),
lexical_cast<boost::math::ef::e_float>("-1.3357437682275493024e+11"),
lexical_cast<boost::math::ef::e_float>("-1.4828267606612366099e+09"),
lexical_cast<boost::math::ef::e_float>("-1.0588550724769347106e+07"),
lexical_cast<boost::math::ef::e_float>("-5.1894091982308017540e+04"),
lexical_cast<boost::math::ef::e_float>("-1.8225946631657315931e+02"),
lexical_cast<boost::math::ef::e_float>("-4.7207090827310162436e-01"),
lexical_cast<boost::math::ef::e_float>("-9.1746443287817501309e-04"),
lexical_cast<boost::math::ef::e_float>("-1.3466829827635152875e-06"),
lexical_cast<boost::math::ef::e_float>("-1.4831904935994647675e-09"),
lexical_cast<boost::math::ef::e_float>("-1.1928788903603238754e-12"),
lexical_cast<boost::math::ef::e_float>("-6.5245515583151902910e-16"),
lexical_cast<boost::math::ef::e_float>("-1.9705291802535139930e-19"),
};
static const boost::math::ef::e_float Q1[] = {
lexical_cast<boost::math::ef::e_float>("-2.9154360556286927285e+15"),
lexical_cast<boost::math::ef::e_float>("9.7887501377547640438e+12"),
lexical_cast<boost::math::ef::e_float>("-1.4386907088588283434e+10"),
lexical_cast<boost::math::ef::e_float>("1.1594225856856884006e+07"),
lexical_cast<boost::math::ef::e_float>("-5.1326864679904189920e+03"),
lexical_cast<boost::math::ef::e_float>("1.0"),
};
static const boost::math::ef::e_float P2[] = {
lexical_cast<boost::math::ef::e_float>("1.4582087408985668208e-05"),
lexical_cast<boost::math::ef::e_float>("-8.9359825138577646443e-04"),
lexical_cast<boost::math::ef::e_float>("2.9204895411257790122e-02"),
lexical_cast<boost::math::ef::e_float>("-3.4198728018058047439e-01"),
lexical_cast<boost::math::ef::e_float>("1.3960118277609544334e+00"),
lexical_cast<boost::math::ef::e_float>("-1.9746376087200685843e+00"),
lexical_cast<boost::math::ef::e_float>("8.5591872901933459000e-01"),
lexical_cast<boost::math::ef::e_float>("-6.0437159056137599999e-02"),
};
static const boost::math::ef::e_float Q2[] = {
lexical_cast<boost::math::ef::e_float>("3.7510433111922824643e-05"),
lexical_cast<boost::math::ef::e_float>("-2.2835624489492512649e-03"),
lexical_cast<boost::math::ef::e_float>("7.4212010813186530069e-02"),
lexical_cast<boost::math::ef::e_float>("-8.5017476463217924408e-01"),
lexical_cast<boost::math::ef::e_float>("3.2593714889036996297e+00"),
lexical_cast<boost::math::ef::e_float>("-3.8806586721556593450e+00"),
lexical_cast<boost::math::ef::e_float>("1.0"),
};
boost::math::ef::e_float value, factor, r, w;
BOOST_MATH_STD_USING
using namespace boost::math::tools;
w = abs(x);
if (x == 0)
{
return static_cast<boost::math::ef::e_float>(0);
}
if (w <= 15) // w in (0, 15]
{
boost::math::ef::e_float y = x * x;
r = evaluate_polynomial(P1, y) / evaluate_polynomial(Q1, y);
factor = w;
value = factor * r;
}
else // w in (15, \infty)
{
boost::math::ef::e_float y = 1 / w - boost::math::ef::e_float(1) / 15;
r = evaluate_polynomial(P2, y) / evaluate_polynomial(Q2, y);
factor = exp(w) / sqrt(w);
value = factor * r;
}
if (x < 0)
{
value *= -value; // odd function
}
return value;
}
} // namespace detail
}}
#endif // BOOST_MATH_E_FLOAT_BINDINGS_HPP

View File

@@ -765,8 +765,7 @@ inline T constant_khinchin<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((s
template <class T>
template<int N>
inline T constant_extreme_value_skewness<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant<int, N>)))
{ // from e_float constants.cpp
// Mathematica: N[12 Sqrt[6] Zeta[3]/Pi^3, 1101]
{ // N[12 Sqrt[6] Zeta[3]/Pi^3, 1101]
BOOST_MATH_STD_USING
T ev(12 * sqrt(static_cast<T>(6)) * zeta_three<T, policies::policy<policies::digits2<N> > >()
/ pi_cubed<T, policies::policy<policies::digits2<N> > >() );
@@ -885,56 +884,55 @@ inline T constant_glaisher<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((s
v /= -12;
return exp(v);
/*
/*
// from http://mpmath.googlecode.com/svn/data/glaisher.txt
// 20,000 digits of the Glaisher-Kinkelin constant A = exp(1/2 - zeta'(-1))
// Computed using A = exp((6 (-zeta'(2))/pi^2 + log 2 pi + gamma)/12)
// with Euler-Maclaurin summation for zeta'(2).
T g(
"1.282427129100622636875342568869791727767688927325001192063740021740406308858826"
"46112973649195820237439420646120399000748933157791362775280404159072573861727522"
"14334327143439787335067915257366856907876561146686449997784962754518174312394652"
"76128213808180219264516851546143919901083573730703504903888123418813674978133050"
"93770833682222494115874837348064399978830070125567001286994157705432053927585405"
"81731588155481762970384743250467775147374600031616023046613296342991558095879293"
"36343887288701988953460725233184702489001091776941712153569193674967261270398013"
"52652668868978218897401729375840750167472114895288815996668743164513890306962645"
"59870469543740253099606800842447417554061490189444139386196089129682173528798629"
"88434220366989900606980888785849587494085307347117090132667567503310523405221054"
"14176776156308191919997185237047761312315374135304725819814797451761027540834943"
"14384965234139453373065832325673954957601692256427736926358821692159870775858274"
"69575162841550648585890834128227556209547002918593263079373376942077522290940187");
// with Euler-Maclaurin summation for zeta'(2).
T g(
"1.282427129100622636875342568869791727767688927325001192063740021740406308858826"
"46112973649195820237439420646120399000748933157791362775280404159072573861727522"
"14334327143439787335067915257366856907876561146686449997784962754518174312394652"
"76128213808180219264516851546143919901083573730703504903888123418813674978133050"
"93770833682222494115874837348064399978830070125567001286994157705432053927585405"
"81731588155481762970384743250467775147374600031616023046613296342991558095879293"
"36343887288701988953460725233184702489001091776941712153569193674967261270398013"
"52652668868978218897401729375840750167472114895288815996668743164513890306962645"
"59870469543740253099606800842447417554061490189444139386196089129682173528798629"
"88434220366989900606980888785849587494085307347117090132667567503310523405221054"
"14176776156308191919997185237047761312315374135304725819814797451761027540834943"
"14384965234139453373065832325673954957601692256427736926358821692159870775858274"
"69575162841550648585890834128227556209547002918593263079373376942077522290940187");
return g;
*/
return g;
*/
}
template <class T>
template<int N>
inline T constant_rayleigh_skewness<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant<int, N>)))
{ // From e_float
// 1100 digits of the Rayleigh distribution skewness
// Mathematica: N[2 Sqrt[Pi] (Pi - 3)/((4 - Pi)^(3/2)), 1100]
{ // 1100 digits of the Rayleigh distribution skewness
// N[2 Sqrt[Pi] (Pi - 3)/((4 - Pi)^(3/2)), 1100]
BOOST_MATH_STD_USING
T rs(2 * root_pi<T, policies::policy<policies::digits2<N> > >()
* pi_minus_three<T, policies::policy<policies::digits2<N> > >()
/ pow(four_minus_pi<T, policies::policy<policies::digits2<N> > >(), static_cast<T>(3./2))
);
// 6.31110657818937138191899351544227779844042203134719497658094585692926819617473725459905027032537306794400047264,
// 6.31110657818937138191899351544227779844042203134719497658094585692926819617473725459905027032537306794400047264,
//"0.6311106578189371381918993515442277798440422031347194976580945856929268196174737254599050270325373067"
//"9440004726436754739597525250317640394102954301685809920213808351450851396781817932734836994829371322"
//"5797376021347531983451654130317032832308462278373358624120822253764532674177325950686466133508511968"
//"2389168716630349407238090652663422922072397393006683401992961569208109477307776249225072042971818671"
//"4058887072693437217879039875871765635655476241624825389439481561152126886932506682176611183750503553"
//"1218982627032068396407180216351425758181396562859085306247387212297187006230007438534686340210168288"
//"8956816965453815849613622117088096547521391672977226658826566757207615552041767516828171274858145957"
//"6137539156656005855905288420585194082284972984285863898582313048515484073396332610565441264220790791"
//"0194897267890422924599776483890102027823328602965235306539844007677157873140562950510028206251529523"
//"7428049693650605954398446899724157486062545281504433364675815915402937209673727753199567661561209251"
//"4695589950526053470201635372590001578503476490223746511106018091907936826431407434894024396366284848"); ;
return rs;
//"0.6311106578189371381918993515442277798440422031347194976580945856929268196174737254599050270325373067"
//"9440004726436754739597525250317640394102954301685809920213808351450851396781817932734836994829371322"
//"5797376021347531983451654130317032832308462278373358624120822253764532674177325950686466133508511968"
//"2389168716630349407238090652663422922072397393006683401992961569208109477307776249225072042971818671"
//"4058887072693437217879039875871765635655476241624825389439481561152126886932506682176611183750503553"
//"1218982627032068396407180216351425758181396562859085306247387212297187006230007438534686340210168288"
//"8956816965453815849613622117088096547521391672977226658826566757207615552041767516828171274858145957"
//"6137539156656005855905288420585194082284972984285863898582313048515484073396332610565441264220790791"
//"0194897267890422924599776483890102027823328602965235306539844007677157873140562950510028206251529523"
//"7428049693650605954398446899724157486062545281504433364675815915402937209673727753199567661561209251"
//"4695589950526053470201635372590001578503476490223746511106018091907936826431407434894024396366284848"); ;
return rs;
}
template <class T>

View File

@@ -861,7 +861,6 @@ test-suite mp :
[ compile ntl_concept_check.cpp : [ check-target-builds ../config//has_ntl_rr : : <build>no ] <debug-symbols>off ]
[ compile mpfr_concept_check.cpp : [ check-target-builds ../config//has_mpfr_class : : <build>no ] <debug-symbols>off ]
[ compile mpreal_concept_check.cpp : [ check-target-builds ../config//has_mpreal : : <build>no ] <debug-symbols>off ]
[ compile e_float_concept_check.cpp : [ check-target-builds ../config//has_e_float : : <build>no ] <debug-symbols>off ]
;
test-suite misc :

View File

@@ -1,40 +0,0 @@
// Copyright John Maddock 2011.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// This tests two things: that e_float meets our
// conceptual requirements, and that we can instantiate
// all our distributions and special functions on this type.
//
#define BOOST_MATH_ASSERT_UNDEFINED_POLICY false
#define TEST_MPFR
#ifdef _MSC_VER
# pragma warning(disable:4800)
# pragma warning(disable:4512)
# pragma warning(disable:4127)
# pragma warning(disable:4512)
# pragma warning(disable:4503) // decorated name length exceeded, name was truncated
#endif
#define E_FLOAT_TYPE_EFX
#include <boost/math/bindings/e_float.hpp>
#include <boost/math/concepts/real_type_concept.hpp>
#include "compile_test/instantiate.hpp"
void foo()
{
instantiate(boost::math::ef::e_float());
}
int main()
{
BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::math::ef::e_float>));
}