diff options
Diffstat (limited to 'src/boost/libs/multiprecision/performance')
30 files changed, 6960 insertions, 0 deletions
diff --git a/src/boost/libs/multiprecision/performance/Jamfile.v2 b/src/boost/libs/multiprecision/performance/Jamfile.v2 new file mode 100644 index 00000000..d0e8721d --- /dev/null +++ b/src/boost/libs/multiprecision/performance/Jamfile.v2 @@ -0,0 +1,169 @@ +# copyright John Maddock 2012 +# 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_0.txt. + +import modules ; +import path ; + +local ntl-path = [ modules.peek : NTL_PATH ] ; +local gmp_path = [ modules.peek : GMP_PATH ] ; +local mpfr_path = [ modules.peek : MPFR_PATH ] ; +local tommath_path = [ modules.peek : TOMMATH_PATH ] ; + +project : requirements + <target-os>freebsd:<linkflags>"-lrt" + <target-os>linux:<linkflags>"-lrt" + <toolset>pgi:<linkflags>"-lrt" + <include>$(gmp_path) + <include>$(gmp_path)/mpfr + <include>$(gmp_path)/gmpfrxx + <include>$(mpfr_path) + <include>$(tommath_path) + <include>../../.. + <search>$(gmp_path) + <search>$(mpfr_path) + <search>$(mpfr_path)/build.vc10/lib/Win32/Debug + <search>$(tommath_path) + <link>static + <define>BOOST_ALL_NO_LIB + <debug-symbols>off + ; + + +lib gmp ; +lib mpfr ; + +if $(tommath_path) +{ + TOMMATH = [ GLOB $(tommath_path) : *.c ] ; +} +else +{ + lib tommath ; + TOMMATH = tommath ; +} + +exe performance_test : performance_test.cpp /boost/system//boost_system + : release + [ check-target-builds ../config//has_gmp : <define>TEST_MPF <define>TEST_MPZ <source>gmp : ] + [ check-target-builds ../config//has_mpfr : <define>TEST_MPFR <source>mpfr : ] + [ check-target-builds ../config//has_tommath : <define>TEST_TOMMATH <source>$(TOMMATH) : ] + <define>TEST_CPP_DEC_FLOAT + <define>TEST_CPP_INT + ; + +exe miller_rabin_performance : miller_rabin_performance.cpp /boost/system//boost_system /boost/chrono//boost_chrono + : release + [ check-target-builds ../config//has_gmp : <define>TEST_MPF <define>TEST_MPZ <source>gmp : ] + [ check-target-builds ../config//has_mpfr : <define>TEST_MPFR <source>mpfr : ] + #[ check-target-builds ../config//has_tommath : <define>TEST_TOMMATH <source>$(TOMMATH) : ] + <define>TEST_CPP_DEC_FLOAT + <define>TEST_CPP_INT + ; + +exe sf_performance : sf_performance.cpp sf_performance_basic.cpp sf_performance_bessel.cpp + sf_performance_bessel1.cpp sf_performance_bessel2.cpp sf_performance_bessel3.cpp + sf_performance_bessel4.cpp sf_performance_bessel5.cpp sf_performance_bessel6.cpp + sf_performance_nct.cpp sf_performance_nct1.cpp + sf_performance_nct2.cpp sf_performance_nct3.cpp sf_performance_nct4.cpp + sf_performance_nct5.cpp sf_performance_nct6.cpp + sf_performance_poly.cpp + /boost/system//boost_system /boost/chrono//boost_chrono /boost/thread//boost_thread + : release + [ check-target-builds ../config//has_gmp : <define>TEST_MPF <define>TEST_MPZ <source>gmp : ] + [ check-target-builds ../config//has_mpfr : <define>TEST_MPFR <source>mpfr : ] + <define>TEST_CPP_DEC_FLOAT + <toolset>msvc:<cxxflags>-bigobj + ; + +exe delaunay_test : delaunay_test.cpp /boost/system//boost_system /boost/chrono//boost_chrono ; + +obj obj_linpack_benchmark_mpfr : linpack-benchmark.cpp + : release + [ check-target-builds ../config//has_mpfr : : <build>no ] + <define>TEST_MPFR_50 + ; + +obj obj_linpack_benchmark_mpf : linpack-benchmark.cpp + : release + [ check-target-builds ../config//has_gmp : : <build>no ] + <define>TEST_MPF_50 + ; + +obj obj_linpack_benchmark_cpp_float : linpack-benchmark.cpp + : release + <define>TEST_CPP_DEC_FLOAT + ; + +obj obj_linpack_benchmark_double : linpack-benchmark.cpp + : release + ; + +obj obj_linpack_benchmark_native_float128 : linpack-benchmark.cpp + : release + <define>NATIVE_FLOAT128 + ; + +obj obj_linpack_benchmark_float128 : linpack-benchmark.cpp + : release + <define>TEST_FLOAT128 + ; + +obj obj_linpack_benchmark_cpp_float_quad : linpack-benchmark.cpp + : release + <define>TEST_CPP_BIN_FLOAT_QUAD + ; + +obj obj_linpack_benchmark_cpp_float_oct : linpack-benchmark.cpp + : release + <define>TEST_CPP_BIN_FLOAT_OCT + ; + +lib f2c ; + +exe linpack_benchmark_mpfr : obj_linpack_benchmark_mpfr mpfr f2c gmp + : release + [ check-target-builds ../config//has_mpfr : : <build>no ] + <define>TEST_MPFR_50 + ; + +exe linpack_benchmark_mpf : obj_linpack_benchmark_mpf gmp f2c + : release + [ check-target-builds ../config//has_gmp : : <build>no ] + <define>TEST_MPF_50 + ; + +exe linpack_benchmark_cpp_float : obj_linpack_benchmark_cpp_float f2c + : release + <define>TEST_CPP_DEC_FLOAT + ; + +exe linpack_benchmark_double : obj_linpack_benchmark_double f2c + : release + ; + +exe linpack_benchmark_native_float128 : obj_linpack_benchmark_native_float128 f2c + : release + ; + +exe linpack_benchmark_float128 : obj_linpack_benchmark_float128 f2c + : release + ; + +exe linpack_benchmark_cpp_quad_float : obj_linpack_benchmark_cpp_quad_float f2c + : release + ; + +exe linpack_benchmark_cpp_oct_float : obj_linpack_benchmark_cpp_oct_float f2c + : release + ; + +install miller_rabin_install : miller_rabin_performance : <location>. ; +install performance_test_install : performance_test : <location>. ; +install sf_performance_install : sf_performance : <location>. ; +install . : linpack_benchmark_double linpack_benchmark_cpp_float linpack_benchmark_mpf linpack_benchmark_mpfr ; +install delaunay_install : delaunay_test : <location>. ; + + + diff --git a/src/boost/libs/multiprecision/performance/arithmetic_backend.hpp b/src/boost/libs/multiprecision/performance/arithmetic_backend.hpp new file mode 100644 index 00000000..32a79a62 --- /dev/null +++ b/src/boost/libs/multiprecision/performance/arithmetic_backend.hpp @@ -0,0 +1,666 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2012 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#ifndef BOOST_MATH_FLOAT_BACKEND_HPP +#define BOOST_MATH_FLOAT_BACKEND_HPP + +#include <iostream> +#include <iomanip> +#include <sstream> +#include <boost/cstdint.hpp> +#include <boost/lexical_cast.hpp> +#include <boost/math/concepts/real_concept.hpp> +#include <boost/multiprecision/number.hpp> +#include <boost/integer/common_factor_rt.hpp> +#include <boost/type_traits/common_type.hpp> +#include <boost/container_hash/hash.hpp> + +namespace boost { +namespace multiprecision { +namespace backends { + +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable : 4389 4244 4018 4244 4127) +#endif + +template <class Arithmetic> +struct arithmetic_backend +{ + typedef mpl::list<short, int, long, long long> signed_types; + typedef mpl::list<unsigned short, unsigned, unsigned long, unsigned long long> unsigned_types; + typedef mpl::list<float, double, long double> float_types; + typedef int exponent_type; + + BOOST_MP_CXX14_CONSTEXPR arithmetic_backend() : m_value(0) {} + BOOST_MP_CXX14_CONSTEXPR arithmetic_backend(const arithmetic_backend& o) : m_value(o.m_value) {} + template <class A> + BOOST_MP_CXX14_CONSTEXPR arithmetic_backend(const A& o, const typename enable_if<is_arithmetic<A> >::type* = 0) : m_value(o) {} + template <class A> + BOOST_MP_CXX14_CONSTEXPR arithmetic_backend(const arithmetic_backend<A>& o) : m_value(o.data()) {} + BOOST_MP_CXX14_CONSTEXPR arithmetic_backend& operator=(const arithmetic_backend& o) + { + m_value = o.m_value; + return *this; + } + template <class A> + BOOST_MP_CXX14_CONSTEXPR typename enable_if<is_arithmetic<A>, arithmetic_backend&>::type operator=(A i) + { + m_value = i; + return *this; + } + template <class A> + BOOST_MP_CXX14_CONSTEXPR arithmetic_backend& operator=(const arithmetic_backend<A>& i) + { + m_value = i.data(); + return *this; + } + arithmetic_backend& operator=(const char* s) + { +#ifndef BOOST_NO_EXCEPTIONS + try + { +#endif + m_value = boost::lexical_cast<Arithmetic>(s); +#ifndef BOOST_NO_EXCEPTIONS + } + catch (const bad_lexical_cast&) + { + throw std::runtime_error(std::string("Unable to interpret the string provided: \"") + s + std::string("\" as a compatible number type.")); + } +#endif + return *this; + } + BOOST_MP_CXX14_CONSTEXPR void swap(arithmetic_backend& o) + { + std::swap(m_value, o.m_value); + } + std::string str(std::streamsize digits, std::ios_base::fmtflags f) const + { + std::stringstream ss; + ss.flags(f); + ss << std::setprecision(digits ? digits : std::numeric_limits<Arithmetic>::digits10 + 4) << m_value; + return ss.str(); + } + BOOST_MP_CXX14_CONSTEXPR void do_negate(const mpl::true_&) + { + m_value = 1 + ~m_value; + } + BOOST_MP_CXX14_CONSTEXPR void do_negate(const mpl::false_&) + { + m_value = -m_value; + } + BOOST_MP_CXX14_CONSTEXPR void negate() + { + do_negate(mpl::bool_<is_unsigned<Arithmetic>::value>()); + } + BOOST_MP_CXX14_CONSTEXPR int compare(const arithmetic_backend& o) const + { + return m_value > o.m_value ? 1 : (m_value < o.m_value ? -1 : 0); + } + template <class A> + BOOST_MP_CXX14_CONSTEXPR typename enable_if<is_arithmetic<A>, int>::type compare(A i) const + { + return m_value > static_cast<Arithmetic>(i) ? 1 : (m_value < static_cast<Arithmetic>(i) ? -1 : 0); + } + BOOST_MP_CXX14_CONSTEXPR Arithmetic& data() { return m_value; } + BOOST_MP_CXX14_CONSTEXPR const Arithmetic& data() const { return m_value; } + + private: + Arithmetic m_value; +}; + +template <class R, class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR typename enable_if_c<boost::is_integral<R>::value>::type eval_convert_to(R* result, const arithmetic_backend<Arithmetic>& backend) +{ + typedef typename boost::common_type<R, Arithmetic>::type c_type; + BOOST_CONSTEXPR const c_type max = static_cast<c_type>((std::numeric_limits<R>::max)()); + BOOST_CONSTEXPR const c_type min = static_cast<c_type>((std::numeric_limits<R>::min)()); + c_type ct = static_cast<c_type>(backend.data()); + if ((backend.data() < 0) && !std::numeric_limits<R>::is_signed) + BOOST_THROW_EXCEPTION(std::range_error("Attempt to convert negative number to unsigned type.")); + if (ct > max) + *result = boost::is_signed<R>::value ? (std::numeric_limits<R>::max)() : backend.data(); + else if (std::numeric_limits<Arithmetic>::is_signed && (ct < min)) + *result = (std::numeric_limits<R>::min)(); + else + *result = backend.data(); +} + +template <class R, class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR typename disable_if_c<boost::is_integral<R>::value>::type eval_convert_to(R* result, const arithmetic_backend<Arithmetic>& backend) +{ + *result = backend.data(); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR bool eval_eq(const arithmetic_backend<Arithmetic>& a, const arithmetic_backend<Arithmetic>& b) +{ + return a.data() == b.data(); +} +template <class Arithmetic, class A2> +inline BOOST_MP_CXX14_CONSTEXPR typename enable_if<is_arithmetic<A2>, bool>::type eval_eq(const arithmetic_backend<Arithmetic>& a, const A2& b) +{ + return a.data() == static_cast<Arithmetic>(b); +} +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR bool eval_lt(const arithmetic_backend<Arithmetic>& a, const arithmetic_backend<Arithmetic>& b) +{ + return a.data() < b.data(); +} +template <class Arithmetic, class A2> +inline BOOST_MP_CXX14_CONSTEXPR typename enable_if<is_arithmetic<A2>, bool>::type eval_lt(const arithmetic_backend<Arithmetic>& a, const A2& b) +{ + return a.data() < static_cast<Arithmetic>(b); +} +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR bool eval_gt(const arithmetic_backend<Arithmetic>& a, const arithmetic_backend<Arithmetic>& b) +{ + return a.data() > b.data(); +} +template <class Arithmetic, class A2> +inline BOOST_MP_CXX14_CONSTEXPR typename enable_if<is_arithmetic<A2>, bool>::type eval_gt(const arithmetic_backend<Arithmetic>& a, const A2& b) +{ + return a.data() > static_cast<Arithmetic>(b); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_add(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + result.data() += o.data(); +} +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_subtract(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + result.data() -= o.data(); +} +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_multiply(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + result.data() *= o.data(); +} +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR typename enable_if_c<std::numeric_limits<Arithmetic>::has_infinity>::type eval_divide(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + result.data() /= o.data(); +} +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR typename disable_if_c<std::numeric_limits<Arithmetic>::has_infinity>::type eval_divide(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + if (!o.data()) + BOOST_THROW_EXCEPTION(std::overflow_error("Divide by zero")); + result.data() /= o.data(); +} + +template <class Arithmetic, class A2> +inline BOOST_MP_CXX14_CONSTEXPR typename enable_if<is_arithmetic<A2> >::type eval_add(arithmetic_backend<Arithmetic>& result, const A2& o) +{ + result.data() += o; +} +template <class Arithmetic, class A2> +inline BOOST_MP_CXX14_CONSTEXPR typename enable_if<is_arithmetic<A2> >::type eval_subtract(arithmetic_backend<Arithmetic>& result, const A2& o) +{ + result.data() -= o; +} +template <class Arithmetic, class A2> +inline BOOST_MP_CXX14_CONSTEXPR typename enable_if<is_arithmetic<A2> >::type eval_multiply(arithmetic_backend<Arithmetic>& result, const A2& o) +{ + result.data() *= o; +} +template <class Arithmetic, class A2> +inline BOOST_MP_CXX14_CONSTEXPR typename enable_if_c<(is_arithmetic<A2>::value && !std::numeric_limits<Arithmetic>::has_infinity)>::type +eval_divide(arithmetic_backend<Arithmetic>& result, const A2& o) +{ + if (!o) + BOOST_THROW_EXCEPTION(std::overflow_error("Divide by zero")); + result.data() /= o; +} +template <class Arithmetic, class A2> +inline BOOST_MP_CXX14_CONSTEXPR typename enable_if_c<(is_arithmetic<A2>::value && std::numeric_limits<Arithmetic>::has_infinity)>::type +eval_divide(arithmetic_backend<Arithmetic>& result, const A2& o) +{ + result.data() /= o; +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_add(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a, const arithmetic_backend<Arithmetic>& b) +{ + result.data() = a.data() + b.data(); +} +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_subtract(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a, const arithmetic_backend<Arithmetic>& b) +{ + result.data() = a.data() - b.data(); +} +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_multiply(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a, const arithmetic_backend<Arithmetic>& b) +{ + result.data() = a.data() * b.data(); +} +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR typename enable_if_c<std::numeric_limits<Arithmetic>::has_infinity>::type eval_divide(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a, const arithmetic_backend<Arithmetic>& b) +{ + result.data() = a.data() / b.data(); +} +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR typename disable_if_c<std::numeric_limits<Arithmetic>::has_infinity>::type eval_divide(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a, const arithmetic_backend<Arithmetic>& b) +{ + if (!b.data()) + BOOST_THROW_EXCEPTION(std::overflow_error("Divide by zero")); + result.data() = a.data() / b.data(); +} + +template <class Arithmetic, class A2> +inline BOOST_MP_CXX14_CONSTEXPR typename enable_if<is_arithmetic<A2> >::type eval_add(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a, const A2& b) +{ + result.data() = a.data() + b; +} +template <class Arithmetic, class A2> +inline BOOST_MP_CXX14_CONSTEXPR typename enable_if<is_arithmetic<A2> >::type eval_subtract(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a, const A2& b) +{ + result.data() = a.data() - b; +} +template <class Arithmetic, class A2> +inline BOOST_MP_CXX14_CONSTEXPR typename enable_if<is_arithmetic<A2> >::type eval_multiply(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a, const A2& b) +{ + result.data() = a.data() * b; +} +template <class Arithmetic, class A2> +inline BOOST_MP_CXX14_CONSTEXPR typename enable_if_c<(is_arithmetic<A2>::value && !std::numeric_limits<Arithmetic>::has_infinity)>::type +eval_divide(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a, const A2& b) +{ + if (!b) + BOOST_THROW_EXCEPTION(std::overflow_error("Divide by zero")); + result.data() = a.data() / b; +} +template <class Arithmetic, class A2> +inline BOOST_MP_CXX14_CONSTEXPR typename enable_if_c<(is_arithmetic<A2>::value && std::numeric_limits<Arithmetic>::has_infinity)>::type +eval_divide(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a, const A2& b) +{ + result.data() = a.data() / b; +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR bool eval_is_zero(const arithmetic_backend<Arithmetic>& val) +{ + return val.data() == 0; +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR typename enable_if_c< + (!std::numeric_limits<Arithmetic>::is_specialized || std::numeric_limits<Arithmetic>::is_signed), int>::type +eval_get_sign(const arithmetic_backend<Arithmetic>& val) +{ + return val.data() == 0 ? 0 : val.data() < 0 ? -1 : 1; +} +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR typename disable_if_c< + (std::numeric_limits<Arithmetic>::is_specialized || std::numeric_limits<Arithmetic>::is_signed), int>::type +eval_get_sign(const arithmetic_backend<Arithmetic>& val) +{ + return val.data() == 0 ? 0 : 1; +} + +template <class T> +inline BOOST_MP_CXX14_CONSTEXPR typename enable_if<is_unsigned<T>, T>::type abs(T v) { return v; } + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_abs(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + using boost::multiprecision::backends::abs; + using std::abs; + result.data() = abs(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_fabs(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + result.data() = std::abs(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_floor(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + BOOST_MATH_STD_USING + result.data() = floor(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_ceil(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + BOOST_MATH_STD_USING + result.data() = ceil(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_sqrt(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + BOOST_MATH_STD_USING + result.data() = sqrt(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR int eval_fpclassify(const arithmetic_backend<Arithmetic>& o) +{ + return (boost::math::fpclassify)(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_trunc(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + BOOST_MATH_STD_USING + result.data() = trunc(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_round(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + BOOST_MATH_STD_USING + result.data() = round(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_frexp(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a, int* v) +{ + BOOST_MATH_STD_USING + result.data() = frexp(a.data(), v); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_ldexp(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a, int v) +{ + BOOST_MATH_STD_USING + result.data() = ldexp(a.data(), v); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_exp(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + BOOST_MATH_STD_USING + result.data() = exp(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_log(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + BOOST_MATH_STD_USING + result.data() = log(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_log10(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + BOOST_MATH_STD_USING + result.data() = log10(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_sin(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + BOOST_MATH_STD_USING + result.data() = sin(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_cos(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + BOOST_MATH_STD_USING + result.data() = cos(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_tan(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + BOOST_MATH_STD_USING + result.data() = tan(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_acos(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + BOOST_MATH_STD_USING + result.data() = acos(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_asin(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + BOOST_MATH_STD_USING + result.data() = asin(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_atan(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + BOOST_MATH_STD_USING + result.data() = atan(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_sinh(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + BOOST_MATH_STD_USING + result.data() = sinh(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_cosh(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + BOOST_MATH_STD_USING + result.data() = cosh(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_tanh(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& o) +{ + BOOST_MATH_STD_USING + result.data() = tanh(o.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_fmod(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a, const arithmetic_backend<Arithmetic>& b) +{ + BOOST_MATH_STD_USING + result.data() = fmod(a.data(), b.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_pow(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a, const arithmetic_backend<Arithmetic>& b) +{ + BOOST_MATH_STD_USING + result.data() = pow(a.data(), b.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_atan2(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a, const arithmetic_backend<Arithmetic>& b) +{ + BOOST_MATH_STD_USING + result.data() = atan2(a.data(), b.data()); +} + +template <class Arithmetic, class I> +inline BOOST_MP_CXX14_CONSTEXPR void eval_left_shift(arithmetic_backend<Arithmetic>& result, I val) +{ + result.data() <<= val; +} + +template <class Arithmetic, class I> +inline BOOST_MP_CXX14_CONSTEXPR void eval_right_shift(arithmetic_backend<Arithmetic>& result, I val) +{ + result.data() >>= val; +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_modulus(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a) +{ + result.data() %= a.data(); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_bitwise_and(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a) +{ + result.data() &= a.data(); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_bitwise_or(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a) +{ + result.data() |= a.data(); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_bitwise_xor(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a) +{ + result.data() ^= a.data(); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_complement(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a) +{ + result.data() = ~a.data(); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_gcd(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a, const arithmetic_backend<Arithmetic>& b) +{ + result.data() = boost::integer::gcd(a.data(), b.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR void eval_lcm(arithmetic_backend<Arithmetic>& result, const arithmetic_backend<Arithmetic>& a, const arithmetic_backend<Arithmetic>& b) +{ + result.data() = boost::integer::lcm(a.data(), b.data()); +} + +template <class Arithmetic> +inline BOOST_MP_CXX14_CONSTEXPR std::size_t hash_value(const arithmetic_backend<Arithmetic>& a) +{ + boost::hash<Arithmetic> hasher; + return hasher(a.data()); +} + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + +} // namespace backends + +using boost::multiprecision::backends::arithmetic_backend; + +template <class Arithmetic> +struct number_category<arithmetic_backend<Arithmetic> > : public mpl::int_<is_integral<Arithmetic>::value ? number_kind_integer : number_kind_floating_point> +{}; + +namespace detail { + +template <class Backend> +struct double_precision_type; + +template <class Arithmetic, boost::multiprecision::expression_template_option ET> +struct double_precision_type<number<arithmetic_backend<Arithmetic>, ET> > +{ + typedef number<arithmetic_backend<typename double_precision_type<Arithmetic>::type>, ET> type; +}; +template <> +struct double_precision_type<arithmetic_backend<boost::int32_t> > +{ + typedef arithmetic_backend<boost::int64_t> type; +}; + +} // namespace detail + +}} // namespace boost::multiprecision +#if !(defined(__SGI_STL_PORT) || defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS)) +// +// We shouldn't need these to get code to compile, however for the sake of +// "level playing field" performance comparisons they avoid the very slow +// lexical_cast's that would otherwise take place. Definition has to be guarded +// by the inverse of pp-logic in real_concept.hpp which defines these as a workaround +// for STLPort plus some other old/broken standartd libraries. +// +namespace boost { namespace math { namespace tools { + +template <> +inline unsigned int real_cast<unsigned int, concepts::real_concept>(concepts::real_concept r) +{ + return static_cast<unsigned int>(r.value()); +} + +template <> +inline int real_cast<int, concepts::real_concept>(concepts::real_concept r) +{ + return static_cast<int>(r.value()); +} + +template <> +inline long real_cast<long, concepts::real_concept>(concepts::real_concept r) +{ + return static_cast<long>(r.value()); +} + +// Converts from T to narrower floating-point types, float, double & long double. + +template <> +inline float real_cast<float, concepts::real_concept>(concepts::real_concept r) +{ + return static_cast<float>(r.value()); +} +template <> +inline double real_cast<double, concepts::real_concept>(concepts::real_concept r) +{ + return static_cast<double>(r.value()); +} +template <> +inline long double real_cast<long double, concepts::real_concept>(concepts::real_concept r) +{ + return r.value(); +} + +}}} // namespace boost::math::tools +#endif + +namespace std { + +template <class Arithmetic, boost::multiprecision::expression_template_option ExpressionTemplates> +class numeric_limits<boost::multiprecision::number<boost::multiprecision::arithmetic_backend<Arithmetic>, ExpressionTemplates> > : public std::numeric_limits<Arithmetic> +{ + typedef std::numeric_limits<Arithmetic> base_type; + typedef boost::multiprecision::number<boost::multiprecision::arithmetic_backend<Arithmetic>, ExpressionTemplates> number_type; + + public: + BOOST_STATIC_CONSTEXPR number_type(min)() BOOST_NOEXCEPT { return (base_type::min)(); } + BOOST_STATIC_CONSTEXPR number_type(max)() BOOST_NOEXCEPT { return (base_type::max)(); } + BOOST_STATIC_CONSTEXPR number_type lowest() BOOST_NOEXCEPT { return -(max)(); } + BOOST_STATIC_CONSTEXPR number_type epsilon() BOOST_NOEXCEPT { return base_type::epsilon(); } + BOOST_STATIC_CONSTEXPR number_type round_error() BOOST_NOEXCEPT { return epsilon() / 2; } + BOOST_STATIC_CONSTEXPR number_type infinity() BOOST_NOEXCEPT { return base_type::infinity(); } + BOOST_STATIC_CONSTEXPR number_type quiet_NaN() BOOST_NOEXCEPT { return base_type::quiet_NaN(); } + BOOST_STATIC_CONSTEXPR number_type signaling_NaN() BOOST_NOEXCEPT { return base_type::signaling_NaN(); } + BOOST_STATIC_CONSTEXPR number_type denorm_min() BOOST_NOEXCEPT { return base_type::denorm_min(); } +}; + +template <> +class numeric_limits<boost::math::concepts::real_concept> : public std::numeric_limits<long double> +{ + typedef std::numeric_limits<long double> base_type; + typedef boost::math::concepts::real_concept number_type; + + public: + static const number_type(min)() BOOST_NOEXCEPT { return (base_type::min)(); } + static const number_type(max)() BOOST_NOEXCEPT { return (base_type::max)(); } + static const number_type lowest() BOOST_NOEXCEPT { return -(max)(); } + static const number_type epsilon() BOOST_NOEXCEPT { return base_type::epsilon(); } + static const number_type round_error() BOOST_NOEXCEPT { return epsilon() / 2; } + static const number_type infinity() BOOST_NOEXCEPT { return base_type::infinity(); } + static const number_type quiet_NaN() BOOST_NOEXCEPT { return base_type::quiet_NaN(); } + static const number_type signaling_NaN() BOOST_NOEXCEPT { return base_type::signaling_NaN(); } + static const number_type denorm_min() BOOST_NOEXCEPT { return base_type::denorm_min(); } +}; + +} // namespace std + +#include <boost/multiprecision/detail/integer_ops.hpp> + +#endif diff --git a/src/boost/libs/multiprecision/performance/cpp_bin_float_conversion_performance.cpp b/src/boost/libs/multiprecision/performance/cpp_bin_float_conversion_performance.cpp new file mode 100644 index 00000000..64692b72 --- /dev/null +++ b/src/boost/libs/multiprecision/performance/cpp_bin_float_conversion_performance.cpp @@ -0,0 +1,159 @@ +// Copyright 2018 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_0.txt) + +#include <boost/multiprecision/cpp_bin_float.hpp> +#include <boost/math/special_functions.hpp> +#include <boost/chrono.hpp> +#include <boost/random/mersenne_twister.hpp> +#include <boost/random/uniform_int.hpp> + +template <class Clock> +struct stopwatch +{ + typedef typename Clock::duration duration; + stopwatch() + { + m_start = Clock::now(); + } + duration elapsed() + { + return Clock::now() - m_start; + } + void reset() + { + m_start = Clock::now(); + } + + private: + typename Clock::time_point m_start; +}; + +template <class T> +T generate_random() +{ + typedef int e_type; + static boost::random::mt19937 gen; + T val = gen(); + T prev_val = -1; + while (val != prev_val) + { + val *= (gen.max)(); + prev_val = val; + val += gen(); + } + e_type e; + val = frexp(val, &e); + + static boost::random::uniform_int_distribution<e_type> ui(-20, 20); + return ldexp(val, ui(gen)); +} + +template <typename T> +double my_convert_to_double(const T& x) +{ + double ret = 0; + if (isfinite(x)) + { + if (x.backend().exponent() >= -1023 - 52 && x != 0) + { + if (x.backend().exponent() <= 1023) + { + int e = x.backend().exponent(); + T y = ldexp(abs(x), 55 - e); + T t = trunc(y); + int64_t ti = t.template convert_to<int64_t>(); + if ((ti & 1) == 0) + { + if (t < y) + ti |= 1; + } + if (e >= -1023 + 1) + { + ret = ldexp(double(ti), e - 55); + } + else + { + // subnormal + typedef boost::multiprecision::number<boost::multiprecision::cpp_bin_float<128, boost::multiprecision::backends::digit_base_2> > cpp_bin_float128_t; + cpp_bin_float128_t sx = ldexp(cpp_bin_float128_t(ti), e - 55); + sx += DBL_MIN; + e = -1023 + 1; + cpp_bin_float128_t sy = ldexp(sx, 55 - e); + cpp_bin_float128_t st = trunc(sy); + ti = st.convert_to<int64_t>(); + if ((ti & 1) == 0) + { + if (st < sy) + ti |= 1; + } + ret = ldexp(double(ti), e - 55) - DBL_MIN; + } + } + else + { + // overflow + ret = HUGE_VAL; + } + } + } + else + { + if (isnan(x)) + return nan(""); + // inf + ret = HUGE_VAL; + } + return x.backend().sign() ? -ret : ret; +} + +template <class T> +void test_conversion_time(const char* name) +{ + std::cout << "Testing times for type: " << name << "\n"; + std::vector<T> values; + + for (unsigned i = 0; i < 10000000; ++i) + { + values.push_back(generate_random<T>()); + } + + boost::chrono::duration<double> time; + stopwatch<boost::chrono::high_resolution_clock> c; + + double total = 0; + + for (typename std::vector<T>::const_iterator i = values.begin(); i != values.end(); ++i) + { + total += my_convert_to_double(*i); + } + + time = c.elapsed(); + std::cout << std::setprecision(3) << std::fixed; + std::cout << "Reference time: " << std::setw(7) << std::right << time << " (total sum = " << total << ")" << std::endl; + + c.reset(); + + total = 0; + + for (typename std::vector<T>::const_iterator i = values.begin(); i != values.end(); ++i) + { + total += i->template convert_to<double>(); + } + + time = c.elapsed(); + std::cout << "Boost time: " << std::setw(7) << std::right << time << " (total sum = " << total << ")" << std::endl; +} + +int main() +{ + using namespace boost::multiprecision; + + test_conversion_time<cpp_bin_float_double>("cpp_bin_float_double"); + test_conversion_time<cpp_bin_float_quad>("cpp_bin_float_quad"); + test_conversion_time<cpp_bin_float_oct>("cpp_bin_float_oct"); + test_conversion_time<cpp_bin_float_50>("cpp_bin_float_50"); + test_conversion_time<cpp_bin_float_100>("cpp_bin_float_100"); + + return 0; +} diff --git a/src/boost/libs/multiprecision/performance/delaunay_test.cpp b/src/boost/libs/multiprecision/performance/delaunay_test.cpp new file mode 100644 index 00000000..1dcb4e6a --- /dev/null +++ b/src/boost/libs/multiprecision/performance/delaunay_test.cpp @@ -0,0 +1,308 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright 2012 John Maddock. +// Copyright 2012 Phil Endecott +// 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_0.txt) + +#include <boost/multiprecision/cpp_int.hpp> +#include "arithmetic_backend.hpp" +#include <boost/chrono.hpp> +#include <boost/random/mersenne_twister.hpp> +#include <boost/random/uniform_int_distribution.hpp> + +#include <fstream> +#include <iomanip> + +template <class Clock> +struct stopwatch +{ + typedef typename Clock::duration duration; + stopwatch() + { + m_start = Clock::now(); + } + duration elapsed() + { + return Clock::now() - m_start; + } + void reset() + { + m_start = Clock::now(); + } + + private: + typename Clock::time_point m_start; +}; + +// Custom 128-bit maths used for exact calculation of the Delaunay test. +// Only the few operators actually needed here are implemented. + +struct int128_t +{ + int64_t high; + uint64_t low; + + int128_t() {} + int128_t(int32_t i) : high(i >> 31), low(static_cast<int64_t>(i)) {} + int128_t(uint32_t i) : high(0), low(i) {} + int128_t(int64_t i) : high(i >> 63), low(i) {} + int128_t(uint64_t i) : high(0), low(i) {} +}; + +inline int128_t operator<<(int128_t val, int amt) +{ + int128_t r; + r.low = val.low << amt; + r.high = val.low >> (64 - amt); + r.high |= val.high << amt; + return r; +} + +inline int128_t& operator+=(int128_t& l, int128_t r) +{ + l.low += r.low; + bool carry = l.low < r.low; + l.high += r.high; + if (carry) + ++l.high; + return l; +} + +inline int128_t operator-(int128_t val) +{ + val.low = ~val.low; + val.high = ~val.high; + val.low += 1; + if (val.low == 0) + val.high += 1; + return val; +} + +inline int128_t operator+(int128_t l, int128_t r) +{ + l += r; + return l; +} + +inline bool operator<(int128_t l, int128_t r) +{ + if (l.high != r.high) + return l.high < r.high; + return l.low < r.low; +} + +inline int128_t mult_64x64_to_128(int64_t a, int64_t b) +{ + // Make life simple by dealing only with positive numbers: + bool neg = false; + if (a < 0) + { + neg = !neg; + a = -a; + } + if (b < 0) + { + neg = !neg; + b = -b; + } + + // Divide input into 32-bit halves: + uint32_t ah = a >> 32; + uint32_t al = a & 0xffffffff; + uint32_t bh = b >> 32; + uint32_t bl = b & 0xffffffff; + + // Long multiplication, with 64-bit temporaries: + + // ah al + // * bh bl + // ---------------- + // al*bl (t1) + // + ah*bl (t2) + // + al*bh (t3) + // + ah*bh (t4) + // ---------------- + + uint64_t t1 = static_cast<uint64_t>(al) * bl; + uint64_t t2 = static_cast<uint64_t>(ah) * bl; + uint64_t t3 = static_cast<uint64_t>(al) * bh; + uint64_t t4 = static_cast<uint64_t>(ah) * bh; + + int128_t r(t1); + r.high = t4; + r += int128_t(t2) << 32; + r += int128_t(t3) << 32; + + if (neg) + r = -r; + + return r; +} + +template <class R, class T> +BOOST_FORCEINLINE void mul_2n(R& r, const T& a, const T& b) +{ + r = a; + r *= b; +} + +template <class B, boost::multiprecision::expression_template_option ET, class T> +BOOST_FORCEINLINE void mul_2n(boost::multiprecision::number<B, ET>& r, const T& a, const T& b) +{ + multiply(r, a, b); +} + +BOOST_FORCEINLINE void mul_2n(int128_t& r, const boost::int64_t& a, const boost::int64_t& b) +{ + r = mult_64x64_to_128(a, b); +} + +template <class Traits> +inline bool delaunay_test(int32_t ax, int32_t ay, int32_t bx, int32_t by, + int32_t cx, int32_t cy, int32_t dx, int32_t dy) +{ + // Test whether the quadrilateral ABCD's diagonal AC should be flipped to BD. + // This is the Cline & Renka method. + // Flip if the sum of the angles ABC and CDA is greater than 180 degrees. + // Equivalently, flip if sin(ABC + CDA) < 0. + // Trig identity: cos(ABC) * sin(CDA) + sin(ABC) * cos(CDA) < 0 + // We can use scalar and vector products to find sin and cos, and simplify + // to the following code. + // Numerical robustness is important. This code addresses it by performing + // exact calculations with large integer types. + // + // NOTE: This routine is limited to inputs with up to 30 BIT PRECISION, which + // is to say all inputs must be in the range [INT_MIN/2, INT_MAX/2]. + + typedef typename Traits::i64_t i64; + typedef typename Traits::i128_t i128; + + i64 cos_abc, t; + mul_2n(cos_abc, (ax - bx), (cx - bx)); // subtraction yields 31-bit values, multiplied to give 62-bit values + mul_2n(t, (ay - by), (cy - by)); + cos_abc += t; // addition yields 63 bit value, leaving one left for the sign + + i64 cos_cda; + mul_2n(cos_cda, (cx - dx), (ax - dx)); + mul_2n(t, (cy - dy), (ay - dy)); + cos_cda += t; + + if (cos_abc >= 0 && cos_cda >= 0) + return false; + if (cos_abc < 0 && cos_cda < 0) + return true; + + i64 sin_abc; + mul_2n(sin_abc, (ax - bx), (cy - by)); + mul_2n(t, (cx - bx), (ay - by)); + sin_abc -= t; + + i64 sin_cda; + mul_2n(sin_cda, (cx - dx), (ay - dy)); + mul_2n(t, (ax - dx), (cy - dy)); + sin_cda -= t; + + i128 sin_sum, t128; + mul_2n(sin_sum, sin_abc, cos_cda); // 63-bit inputs multiplied to 126-bit output + mul_2n(t128, cos_abc, sin_cda); + sin_sum += t128; // Addition yields 127 bit result, leaving one bit for the sign + + return sin_sum < 0; +} + +struct dt_dat +{ + int32_t ax, ay, bx, by, cx, cy, dx, dy; +}; + +typedef std::vector<dt_dat> data_t; +data_t data; + +template <class Traits> +void do_calc(const char* name) +{ + std::cout << "Running calculations for: " << name << std::endl; + + stopwatch<boost::chrono::high_resolution_clock> w; + + boost::uint64_t flips = 0; + boost::uint64_t calcs = 0; + + for (int j = 0; j < 1000; ++j) + { + for (data_t::const_iterator i = data.begin(); i != data.end(); ++i) + { + const dt_dat& d = *i; + bool flip = delaunay_test<Traits>(d.ax, d.ay, d.bx, d.by, d.cx, d.cy, d.dx, d.dy); + if (flip) + ++flips; + ++calcs; + } + } + double t = boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + + std::cout << "Number of calculations = " << calcs << std::endl; + std::cout << "Number of flips = " << flips << std::endl; + std::cout << "Total execution time = " << t << std::endl; + std::cout << "Time per calculation = " << t / calcs << std::endl + << std::endl; +} + +template <class I64, class I128> +struct test_traits +{ + typedef I64 i64_t; + typedef I128 i128_t; +}; + +dt_dat generate_quadrilateral() +{ + static boost::random::mt19937 gen; + static boost::random::uniform_int_distribution<> dist(INT_MIN / 2, INT_MAX / 2); + + dt_dat result; + + result.ax = dist(gen); + result.ay = dist(gen); + result.bx = boost::random::uniform_int_distribution<>(result.ax, INT_MAX / 2)(gen); // bx is to the right of ax. + result.by = dist(gen); + result.cx = dist(gen); + result.cy = boost::random::uniform_int_distribution<>(result.cx > result.bx ? result.by : result.ay, INT_MAX / 2)(gen); // cy is below at least one of ay and by. + result.dx = boost::random::uniform_int_distribution<>(result.cx, INT_MAX / 2)(gen); // dx is to the right of cx. + result.dy = boost::random::uniform_int_distribution<>(result.cx > result.bx ? result.by : result.ay, INT_MAX / 2)(gen); // cy is below at least one of ay and by. + + return result; +} + +static void load_data() +{ + for (unsigned i = 0; i < 100000; ++i) + data.push_back(generate_quadrilateral()); +} + +int main() +{ + using namespace boost::multiprecision; + std::cout << "loading data...\n"; + load_data(); + + std::cout << "calculating...\n"; + + do_calc<test_traits<boost::int64_t, boost::int64_t> >("int64_t, int64_t"); + do_calc<test_traits<number<arithmetic_backend<boost::int64_t>, et_off>, number<arithmetic_backend<boost::int64_t>, et_off> > >("arithmetic_backend<int64_t>, arithmetic_backend<int64_t>"); + do_calc<test_traits<boost::int64_t, number<arithmetic_backend<boost::int64_t>, et_off> > >("int64_t, arithmetic_backend<int64_t>"); + do_calc<test_traits<number<cpp_int_backend<64, 64, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void>, et_off>, number<cpp_int_backend<64, 64, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void>, et_off> > >("multiprecision::int64_t, multiprecision::int64_t"); + + do_calc<test_traits<boost::int64_t, ::int128_t> >("int64_t, int128_t"); + do_calc<test_traits<boost::int64_t, boost::multiprecision::int128_t> >("int64_t, boost::multiprecision::int128_t"); + do_calc<test_traits<boost::int64_t, number<cpp_int_backend<128, 128, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void>, et_on> > >("int64_t, int128_t (ET)"); + do_calc<test_traits<number<cpp_int_backend<64, 64, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void>, et_off>, boost::multiprecision::int128_t> >("multiprecision::int64_t, multiprecision::int128_t"); + + do_calc<test_traits<boost::int64_t, cpp_int> >("int64_t, cpp_int"); + do_calc<test_traits<boost::int64_t, number<cpp_int_backend<>, et_off> > >("int64_t, cpp_int (no ET's)"); + do_calc<test_traits<boost::int64_t, number<cpp_int_backend<128> > > >("int64_t, cpp_int(128-bit cache)"); + do_calc<test_traits<boost::int64_t, number<cpp_int_backend<128>, et_off> > >("int64_t, cpp_int (128-bit Cache no ET's)"); + + return 0; +} diff --git a/src/boost/libs/multiprecision/performance/linpack-benchmark.cpp b/src/boost/libs/multiprecision/performance/linpack-benchmark.cpp new file mode 100644 index 00000000..7fc6a6ce --- /dev/null +++ b/src/boost/libs/multiprecision/performance/linpack-benchmark.cpp @@ -0,0 +1,1302 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright 2011 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_0.txt) + +/* 1000d.f -- translated by f2c (version 20050501). +You must link the resulting object file with libf2c: +on Microsoft Windows system, link with libf2c.lib; +on Linux or Unix systems, link with .../path/to/libf2c.a -lm +or, if you install libf2c.a in a standard place, with -lf2c -lm +-- in that order, at the end of the command line, as in +cc *.o -lf2c -lm +Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., + +http://www.netlib.org/f2c/libf2c.zip +*/ +#include <iostream> +#include <iomanip> +#include <cmath> + +#if defined(TEST_GMPXX) +#include <gmpxx.h> +typedef mpf_class real_type; +#elif defined(TEST_MPFRXX) +#include <gmpfrxx.h> +typedef mpfr_class real_type; +#elif defined(TEST_CPP_DEC_FLOAT) +#include <boost/multiprecision/cpp_dec_float.hpp> +typedef boost::multiprecision::cpp_dec_float_50 real_type; +#elif defined(TEST_MPFR_50) +#include <boost/multiprecision/mpfr.hpp> +typedef boost::multiprecision::mpfr_float_50 real_type; +#elif defined(TEST_MPF_50) +#include <boost/multiprecision/gmp.hpp> +typedef boost::multiprecision::mpf_float_50 real_type; +#elif defined(NATIVE_FLOAT128) +#include <boost/multiprecision/float128.hpp> +typedef __float128 real_type; + +std::ostream& operator<<(std::ostream& os, const __float128& f) +{ + return os << boost::multiprecision::float128(f); +} + +#include <boost/type_traits/has_left_shift.hpp> + +namespace boost { + +template <> +struct has_left_shift<std::basic_ostream<char>, __float128> : public mpl::true_ +{}; + +template <> +double lexical_cast<double, __float128>(const __float128& f) +{ + return f; +} + +} // namespace boost + +#elif defined(TEST_FLOAT128) +#include <boost/multiprecision/float128.hpp> +typedef boost::multiprecision::float128 real_type; +#elif defined(TEST_CPP_BIN_FLOAT_QUAD) +#include <boost/multiprecision/cpp_bin_float.hpp> +typedef boost::multiprecision::cpp_bin_float_quad real_type; +#elif defined(TEST_CPP_BIN_FLOAT_OCT) +#include <boost/multiprecision/cpp_bin_float.hpp> +typedef boost::multiprecision::cpp_bin_float_oct real_type; +#else +typedef double real_type; +#endif + +#include <boost/lexical_cast.hpp> + +#ifndef CAST_TO_RT +#define CAST_TO_RT(x) x +#endif + +extern "C" { +#include "f2c.h" +integer s_wsfe(cilist*), e_wsfe(void), do_fio(integer*, char*, ftnlen), + s_wsle(cilist*), do_lio(integer*, integer*, char*, ftnlen), + e_wsle(void); +/* Subroutine */ int s_stop(char*, ftnlen); + +#undef abs +#undef dabs +#define dabs abs +#undef dmin +#undef dmax +#define dmin min +#define dmax max +} +#include <time.h> + +using std::max; +using std::min; + +/* Table of constant values */ + +static integer c__0 = 0; +static real_type c_b7 = CAST_TO_RT(1); +static integer c__1 = 1; +static integer c__9 = 9; + +inline double second_(void) +{ + return ((double)(clock())) / CLOCKS_PER_SEC; +} + +int dgefa_(real_type*, integer*, integer*, integer*, integer*), dgesl_(real_type*, integer*, integer*, integer*, real_type*, integer*); +int dmxpy_(integer*, real_type*, integer*, integer*, real_type*, real_type*); +int matgen_(real_type*, integer*, integer*, real_type*, real_type*); +real_type epslon_(real_type*); +real_type ran_(integer*); +int dscal_(integer*, real_type*, real_type*, integer*); +int daxpy_(integer*, real_type*, real_type*, integer*, real_type*, integer*); +integer idamax_(integer*, real_type*, integer*); +real_type ddot_(integer*, real_type*, integer*, real_type*, integer*); +int daxpy_(integer*, real_type*, real_type*, integer*, real_type*, integer*); +int dmxpy_(integer*, real_type*, integer*, integer*, real_type*, real_type*); + +extern "C" int MAIN__() +{ +#ifdef TEST_MPF_50 + std::cout << "Testing number<mpf_float<50> >" << std::endl; +#elif defined(TEST_MPFR_50) + std::cout << "Testing number<mpf_float<50> >" << std::endl; +#elif defined(TEST_GMPXX) + std::cout << "Testing mpf_class at 50 decimal degits" << std::endl; + mpf_set_default_prec(((50 + 1) * 1000L) / 301L); +#elif defined(TEST_MPFRXX) + std::cout << "Testing mpfr_class at 50 decimal degits" << std::endl; + mpfr_set_default_prec(((50 + 1) * 1000L) / 301L); +#elif defined(TEST_CPP_DEC_FLOAT) + std::cout << "Testing number<cpp_dec_float<50> >" << std::endl; +#elif defined(NATIVE_FLOAT128) + std::cout << "Testing __float128" << std::endl; +#elif defined(TEST_FLOAT128) + std::cout << "Testing number<float128_backend, et_off>" << std::endl; +#else + std::cout << "Testing double" << std::endl; +#endif + + /* Format strings */ + static char fmt_1[] = "(\002 Please send the results of this run to:\002" + "//\002 Jack J. Dongarra\002/\002 Computer Science Department\002/" + "\002 University of Tennessee\002/\002 Knoxville, Tennessee 37996" + "-1300\002//\002 Fax: 615-974-8296\002//\002 Internet: dongarra@c" + "s.utk.edu\002/)"; + static char fmt_40[] = "(\002 norm. resid resid mac" + "hep\002,\002 x(1) x(n)\002)"; + static char fmt_50[] = "(1p5e16.8)"; + static char fmt_60[] = "(//\002 times are reported for matrices of or" + "der \002,i5)"; + static char fmt_70[] = "(6x,\002factor\002,5x,\002solve\002,6x,\002tota" + "l\002,5x,\002mflops\002,7x,\002unit\002,6x,\002ratio\002)"; + static char fmt_80[] = "(\002 times for array with leading dimension o" + "f\002,i4)"; + static char fmt_110[] = "(6(1pe11.3))"; + + /* System generated locals */ + integer i__1; + real_type d__1, d__2, d__3; + + /* Builtin functions */ + + /* Local variables */ + static real_type a[1001000] /* was [1001][1000] */, b[1000]; + static integer i__, n; + static real_type x[1000]; + static double t1; + static integer lda; + static double ops; + static real_type eps; + static integer info; + static double time[6], cray, total; + static integer ipvt[1000]; + static real_type resid, norma; + static real_type normx; + static real_type residn; + + /* Fortran I/O blocks */ + static cilist io___4 = {0, 6, 0, fmt_1, 0}; + static cilist io___20 = {0, 6, 0, fmt_40, 0}; + static cilist io___21 = {0, 6, 0, fmt_50, 0}; + static cilist io___22 = {0, 6, 0, fmt_60, 0}; + static cilist io___23 = {0, 6, 0, fmt_70, 0}; + static cilist io___24 = {0, 6, 0, fmt_80, 0}; + static cilist io___25 = {0, 6, 0, fmt_110, 0}; + static cilist io___26 = {0, 6, 0, 0, 0}; + + lda = 1001; + + /* this program was updated on 10/12/92 to correct a */ + /* problem with the random number generator. The previous */ + /* random number generator had a short period and produced */ + /* singular matrices occasionally. */ + + n = 1000; + cray = .056f; + s_wsfe(&io___4); + e_wsfe(); + /* Computing 3rd power */ + d__1 = (real_type)n; + /* Computing 2nd power */ + d__2 = (real_type)n; + ops = boost::lexical_cast<double>(real_type(d__1 * (d__1 * d__1) * 2. / 3. + d__2 * d__2 * 2.)); + + matgen_(a, &lda, &n, b, &norma); + + /* ****************************************************************** */ + /* ****************************************************************** */ + /* you should replace the call to dgefa and dgesl */ + /* by calls to your linear equation solver. */ + /* ****************************************************************** */ + /* ****************************************************************** */ + + t1 = second_(); + dgefa_(a, &lda, &n, ipvt, &info); + time[0] = second_() - t1; + t1 = second_(); + dgesl_(a, &lda, &n, ipvt, b, &c__0); + time[1] = second_() - t1; + total = time[0] + time[1]; + /* ****************************************************************** */ + /* ****************************************************************** */ + + /* compute a residual to verify results. */ + + i__1 = n; + for (i__ = 1; i__ <= i__1; ++i__) + { + x[i__ - 1] = b[i__ - 1]; + /* L10: */ + } + matgen_(a, &lda, &n, b, &norma); + i__1 = n; + for (i__ = 1; i__ <= i__1; ++i__) + { + b[i__ - 1] = -b[i__ - 1]; + /* L20: */ + } + dmxpy_(&n, b, &n, &lda, x, a); + resid = CAST_TO_RT(0); + normx = CAST_TO_RT(0); + i__1 = n; + for (i__ = 1; i__ <= i__1; ++i__) + { + /* Computing MAX */ + d__2 = resid, d__3 = (d__1 = b[i__ - 1], abs(d__1)); + resid = (max)(d__2, d__3); + /* Computing MAX */ + d__2 = normx, d__3 = (d__1 = x[i__ - 1], abs(d__1)); + normx = (max)(d__2, d__3); + /* L30: */ + } + eps = epslon_(&c_b7); + residn = resid / (n * norma * normx * eps); + s_wsfe(&io___20); + e_wsfe(); + s_wsfe(&io___21); + /* + do_fio(&c__1, (char *)&residn, (ftnlen)sizeof(real_type)); + do_fio(&c__1, (char *)&resid, (ftnlen)sizeof(real_type)); + do_fio(&c__1, (char *)&eps, (ftnlen)sizeof(real_type)); + do_fio(&c__1, (char *)&x[0], (ftnlen)sizeof(real_type)); + do_fio(&c__1, (char *)&x[n - 1], (ftnlen)sizeof(real_type)); + */ + std::cout << std::setw(12) << std::setprecision(5) << residn << " " << resid << " " << eps << " " << x[0] << " " << x[n - 1] << std::endl; + e_wsfe(); + + s_wsfe(&io___22); + do_fio(&c__1, (char*)&n, (ftnlen)sizeof(integer)); + e_wsfe(); + s_wsfe(&io___23); + e_wsfe(); + + time[2] = total; + time[3] = ops / (total * 1e6); + time[4] = 2. / time[3]; + time[5] = total / cray; + s_wsfe(&io___24); + do_fio(&c__1, (char*)&lda, (ftnlen)sizeof(integer)); + e_wsfe(); + s_wsfe(&io___25); + for (i__ = 1; i__ <= 6; ++i__) + { + // do_fio(&c__1, (char *)&time[i__ - 1], (ftnlen)sizeof(real_type)); + std::cout << std::setw(12) << std::setprecision(5) << time[i__ - 1]; + } + e_wsfe(); + s_wsle(&io___26); + do_lio(&c__9, &c__1, " end of tests -- this version dated 10/12/92", (ftnlen)44); + e_wsle(); + + s_stop("", (ftnlen)0); + return 0; +} /* MAIN__ */ + +/* Subroutine */ int matgen_(real_type* a, integer* lda, integer* n, + real_type* b, real_type* norma) +{ + /* System generated locals */ + integer a_dim1, a_offset, i__1, i__2; + real_type d__1, d__2; + + /* Local variables */ + static integer i__, j; + static integer init[4]; + + /* Parameter adjustments */ + a_dim1 = *lda; + a_offset = 1 + a_dim1; + a -= a_offset; + --b; + + /* Function Body */ + init[0] = 1; + init[1] = 2; + init[2] = 3; + init[3] = 1325; + *norma = CAST_TO_RT(0); + i__1 = *n; + for (j = 1; j <= i__1; ++j) + { + i__2 = *n; + for (i__ = 1; i__ <= i__2; ++i__) + { + a[i__ + j * a_dim1] = ran_(init) - .5f; + /* Computing MAX */ + d__2 = (d__1 = a[i__ + j * a_dim1], abs(d__1)); + *norma = (max)(d__2, *norma); + /* L20: */ + } + /* L30: */ + } + i__1 = *n; + for (i__ = 1; i__ <= i__1; ++i__) + { + b[i__] = CAST_TO_RT(0); + /* L35: */ + } + i__1 = *n; + for (j = 1; j <= i__1; ++j) + { + i__2 = *n; + for (i__ = 1; i__ <= i__2; ++i__) + { + b[i__] += a[i__ + j * a_dim1]; + /* L40: */ + } + /* L50: */ + } + return 0; +} /* matgen_ */ + +/* Subroutine */ int dgefa_(real_type* a, integer* lda, integer* n, integer* ipvt, integer* info) +{ + /* System generated locals */ + integer a_dim1, a_offset, i__1, i__2, i__3; + + /* Local variables */ + static integer j, k, l; + static real_type t; + static integer kp1, nm1; + + /* dgefa factors a double precision matrix by gaussian elimination. */ + + /* dgefa is usually called by dgeco, but it can be called */ + /* directly with a saving in time if rcond is not needed. */ + /* (time for dgeco) = (1 + 9/n)*(time for dgefa) . */ + + /* on entry */ + + /* a double precision(lda, n) */ + /* the matrix to be factored. */ + + /* lda integer */ + /* the leading dimension of the array a . */ + + /* n integer */ + /* the order of the matrix a . */ + + /* on return */ + + /* a an upper triangular matrix and the multipliers */ + /* which were used to obtain it. */ + /* the factorization can be written a = l*u where */ + /* l is a product of permutation and unit lower */ + /* triangular matrices and u is upper triangular. */ + + /* ipvt integer(n) */ + /* an integer vector of pivot indices. */ + + /* info integer */ + /* = 0 normal value. */ + /* = k if u(k,k) .eq. 0.0 . this is not an error */ + /* condition for this subroutine, but it does */ + /* indicate that dgesl or dgedi will divide by zero */ + /* if called. use rcond in dgeco for a reliable */ + /* indication of singularity. */ + + /* linpack. this version dated 08/14/78 . */ + /* cleve moler, university of new mexico, argonne national lab. */ + + /* subroutines and functions */ + + /* blas daxpy,dscal,idamax */ + + /* internal variables */ + + /* gaussian elimination with partial pivoting */ + + /* Parameter adjustments */ + a_dim1 = *lda; + a_offset = 1 + a_dim1; + a -= a_offset; + --ipvt; + + /* Function Body */ + *info = 0; + nm1 = *n - 1; + if (nm1 < 1) + { + goto L70; + } + i__1 = nm1; + for (k = 1; k <= i__1; ++k) + { + kp1 = k + 1; + + /* find l = pivot index */ + + i__2 = *n - k + 1; + l = idamax_(&i__2, &a[k + k * a_dim1], &c__1) + k - 1; + ipvt[k] = l; + + /* zero pivot implies this column already triangularized */ + + if (a[l + k * a_dim1] == 0.) + { + goto L40; + } + + /* interchange if necessary */ + + if (l == k) + { + goto L10; + } + t = a[l + k * a_dim1]; + a[l + k * a_dim1] = a[k + k * a_dim1]; + a[k + k * a_dim1] = t; + L10: + + /* compute multipliers */ + + t = -1. / a[k + k * a_dim1]; + i__2 = *n - k; + dscal_(&i__2, &t, &a[k + 1 + k * a_dim1], &c__1); + + /* row elimination with column indexing */ + + i__2 = *n; + for (j = kp1; j <= i__2; ++j) + { + t = a[l + j * a_dim1]; + if (l == k) + { + goto L20; + } + a[l + j * a_dim1] = a[k + j * a_dim1]; + a[k + j * a_dim1] = t; + L20: + i__3 = *n - k; + daxpy_(&i__3, &t, &a[k + 1 + k * a_dim1], &c__1, &a[k + 1 + j * a_dim1], &c__1); + /* L30: */ + } + goto L50; + L40: + *info = k; + L50: + /* L60: */ + ; + } +L70: + ipvt[*n] = *n; + if (a[*n + *n * a_dim1] == 0.) + { + *info = *n; + } + return 0; +} /* dgefa_ */ + +/* Subroutine */ int dgesl_(real_type* a, integer* lda, integer* n, integer* ipvt, real_type* b, integer* job) +{ + /* System generated locals */ + integer a_dim1, a_offset, i__1, i__2; + + /* Local variables */ + static integer k, l; + static real_type t; + static integer kb, nm1; + + /* dgesl solves the double precision system */ + /* a * x = b or trans(a) * x = b */ + /* using the factors computed by dgeco or dgefa. */ + + /* on entry */ + + /* a double precision(lda, n) */ + /* the output from dgeco or dgefa. */ + + /* lda integer */ + /* the leading dimension of the array a . */ + + /* n integer */ + /* the order of the matrix a . */ + + /* ipvt integer(n) */ + /* the pivot vector from dgeco or dgefa. */ + + /* b double precision(n) */ + /* the right hand side vector. */ + + /* job integer */ + /* = 0 to solve a*x = b , */ + /* = nonzero to solve trans(a)*x = b where */ + /* trans(a) is the transpose. */ + + /* on return */ + + /* b the solution vector x . */ + + /* error condition */ + + /* a division by zero will occur if the input factor contains a */ + /* zero on the diagonal. technically this indicates singularity */ + /* but it is often caused by improper arguments or improper */ + /* setting of lda . it will not occur if the subroutines are */ + /* called correctly and if dgeco has set rcond .gt. 0.0 */ + /* or dgefa has set info .eq. 0 . */ + + /* to compute inverse(a) * c where c is a matrix */ + /* with p columns */ + /* call dgeco(a,lda,n,ipvt,rcond,z) */ + /* if (rcond is too small) go to ... */ + /* do 10 j = 1, p */ + /* call dgesl(a,lda,n,ipvt,c(1,j),0) */ + /* 10 continue */ + + /* linpack. this version dated 08/14/78 . */ + /* cleve moler, university of new mexico, argonne national lab. */ + + /* subroutines and functions */ + + /* blas daxpy,ddot */ + + /* internal variables */ + + /* Parameter adjustments */ + a_dim1 = *lda; + a_offset = 1 + a_dim1; + a -= a_offset; + --ipvt; + --b; + + /* Function Body */ + nm1 = *n - 1; + if (*job != 0) + { + goto L50; + } + + /* job = 0 , solve a * x = b */ + /* first solve l*y = b */ + + if (nm1 < 1) + { + goto L30; + } + i__1 = nm1; + for (k = 1; k <= i__1; ++k) + { + l = ipvt[k]; + t = b[l]; + if (l == k) + { + goto L10; + } + b[l] = b[k]; + b[k] = t; + L10: + i__2 = *n - k; + daxpy_(&i__2, &t, &a[k + 1 + k * a_dim1], &c__1, &b[k + 1], &c__1); + /* L20: */ + } +L30: + + /* now solve u*x = y */ + + i__1 = *n; + for (kb = 1; kb <= i__1; ++kb) + { + k = *n + 1 - kb; + b[k] /= a[k + k * a_dim1]; + t = -b[k]; + i__2 = k - 1; + daxpy_(&i__2, &t, &a[k * a_dim1 + 1], &c__1, &b[1], &c__1); + /* L40: */ + } + goto L100; +L50: + + /* job = nonzero, solve trans(a) * x = b */ + /* first solve trans(u)*y = b */ + + i__1 = *n; + for (k = 1; k <= i__1; ++k) + { + i__2 = k - 1; + t = ddot_(&i__2, &a[k * a_dim1 + 1], &c__1, &b[1], &c__1); + b[k] = (b[k] - t) / a[k + k * a_dim1]; + /* L60: */ + } + + /* now solve trans(l)*x = y */ + + if (nm1 < 1) + { + goto L90; + } + i__1 = nm1; + for (kb = 1; kb <= i__1; ++kb) + { + k = *n - kb; + i__2 = *n - k; + b[k] += ddot_(&i__2, &a[k + 1 + k * a_dim1], &c__1, &b[k + 1], &c__1); + l = ipvt[k]; + if (l == k) + { + goto L70; + } + t = b[l]; + b[l] = b[k]; + b[k] = t; + L70: + /* L80: */ + ; + } +L90: +L100: + return 0; +} /* dgesl_ */ + +/* Subroutine */ int daxpy_(integer* n, real_type* da, real_type* dx, + integer* incx, real_type* dy, integer* incy) +{ + /* System generated locals */ + integer i__1; + + /* Local variables */ + static integer i__, m, ix, iy, mp1; + + /* constant times a vector plus a vector. */ + /* uses unrolled loops for increments equal to one. */ + /* jack dongarra, linpack, 3/11/78. */ + + /* Parameter adjustments */ + --dy; + --dx; + + /* Function Body */ + if (*n <= 0) + { + return 0; + } + if (*da == 0.) + { + return 0; + } + if (*incx == 1 && *incy == 1) + { + goto L20; + } + + /* code for unequal increments or equal increments */ + /* not equal to 1 */ + + ix = 1; + iy = 1; + if (*incx < 0) + { + ix = (-(*n) + 1) * *incx + 1; + } + if (*incy < 0) + { + iy = (-(*n) + 1) * *incy + 1; + } + i__1 = *n; + for (i__ = 1; i__ <= i__1; ++i__) + { + dy[iy] += *da * dx[ix]; + ix += *incx; + iy += *incy; + /* L10: */ + } + return 0; + + /* code for both increments equal to 1 */ + + /* clean-up loop */ + +L20: + m = *n % 4; + if (m == 0) + { + goto L40; + } + i__1 = m; + for (i__ = 1; i__ <= i__1; ++i__) + { + dy[i__] += *da * dx[i__]; + /* L30: */ + } + if (*n < 4) + { + return 0; + } +L40: + mp1 = m + 1; + i__1 = *n; + for (i__ = mp1; i__ <= i__1; i__ += 4) + { + dy[i__] += *da * dx[i__]; + dy[i__ + 1] += *da * dx[i__ + 1]; + dy[i__ + 2] += *da * dx[i__ + 2]; + dy[i__ + 3] += *da * dx[i__ + 3]; + /* L50: */ + } + return 0; +} /* daxpy_ */ + +real_type ddot_(integer* n, real_type* dx, integer* incx, real_type* dy, + integer* incy) +{ + /* System generated locals */ + integer i__1; + real_type ret_val; + + /* Local variables */ + static integer i__, m, ix, iy, mp1; + static real_type dtemp; + + /* forms the dot product of two vectors. */ + /* uses unrolled loops for increments equal to one. */ + /* jack dongarra, linpack, 3/11/78. */ + + /* Parameter adjustments */ + --dy; + --dx; + + /* Function Body */ + ret_val = CAST_TO_RT(0); + dtemp = CAST_TO_RT(0); + if (*n <= 0) + { + return ret_val; + } + if (*incx == 1 && *incy == 1) + { + goto L20; + } + + /* code for unequal increments or equal increments */ + /* not equal to 1 */ + + ix = 1; + iy = 1; + if (*incx < 0) + { + ix = (-(*n) + 1) * *incx + 1; + } + if (*incy < 0) + { + iy = (-(*n) + 1) * *incy + 1; + } + i__1 = *n; + for (i__ = 1; i__ <= i__1; ++i__) + { + dtemp += dx[ix] * dy[iy]; + ix += *incx; + iy += *incy; + /* L10: */ + } + ret_val = dtemp; + return ret_val; + + /* code for both increments equal to 1 */ + + /* clean-up loop */ + +L20: + m = *n % 5; + if (m == 0) + { + goto L40; + } + i__1 = m; + for (i__ = 1; i__ <= i__1; ++i__) + { + dtemp += dx[i__] * dy[i__]; + /* L30: */ + } + if (*n < 5) + { + goto L60; + } +L40: + mp1 = m + 1; + i__1 = *n; + for (i__ = mp1; i__ <= i__1; i__ += 5) + { + dtemp = dtemp + dx[i__] * dy[i__] + dx[i__ + 1] * dy[i__ + 1] + dx[i__ + 2] * dy[i__ + 2] + dx[i__ + 3] * dy[i__ + 3] + dx[i__ + 4] * dy[i__ + 4]; + /* L50: */ + } +L60: + ret_val = dtemp; + return ret_val; +} /* ddot_ */ + +/* Subroutine */ int dscal_(integer* n, real_type* da, real_type* dx, + integer* incx) +{ + /* System generated locals */ + integer i__1, i__2; + + /* Local variables */ + static integer i__, m, mp1, nincx; + + /* scales a vector by a constant. */ + /* uses unrolled loops for increment equal to one. */ + /* jack dongarra, linpack, 3/11/78. */ + + /* Parameter adjustments */ + --dx; + + /* Function Body */ + if (*n <= 0) + { + return 0; + } + if (*incx == 1) + { + goto L20; + } + + /* code for increment not equal to 1 */ + + nincx = *n * *incx; + i__1 = nincx; + i__2 = *incx; + for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) + { + dx[i__] = *da * dx[i__]; + /* L10: */ + } + return 0; + + /* code for increment equal to 1 */ + + /* clean-up loop */ + +L20: + m = *n % 5; + if (m == 0) + { + goto L40; + } + i__2 = m; + for (i__ = 1; i__ <= i__2; ++i__) + { + dx[i__] = *da * dx[i__]; + /* L30: */ + } + if (*n < 5) + { + return 0; + } +L40: + mp1 = m + 1; + i__2 = *n; + for (i__ = mp1; i__ <= i__2; i__ += 5) + { + dx[i__] = *da * dx[i__]; + dx[i__ + 1] = *da * dx[i__ + 1]; + dx[i__ + 2] = *da * dx[i__ + 2]; + dx[i__ + 3] = *da * dx[i__ + 3]; + dx[i__ + 4] = *da * dx[i__ + 4]; + /* L50: */ + } + return 0; +} /* dscal_ */ + +integer idamax_(integer* n, real_type* dx, integer* incx) +{ + /* System generated locals */ + integer ret_val, i__1; + real_type d__1; + + /* Local variables */ + static integer i__, ix; + static real_type dmax__; + + /* finds the index of element having max. dabsolute value. */ + /* jack dongarra, linpack, 3/11/78. */ + + /* Parameter adjustments */ + --dx; + + /* Function Body */ + ret_val = 0; + if (*n < 1) + { + return ret_val; + } + ret_val = 1; + if (*n == 1) + { + return ret_val; + } + if (*incx == 1) + { + goto L20; + } + + /* code for increment not equal to 1 */ + + ix = 1; + dmax__ = abs(dx[1]); + ix += *incx; + i__1 = *n; + for (i__ = 2; i__ <= i__1; ++i__) + { + if ((d__1 = dx[ix], abs(d__1)) <= dmax__) + { + goto L5; + } + ret_val = i__; + dmax__ = (d__1 = dx[ix], abs(d__1)); + L5: + ix += *incx; + /* L10: */ + } + return ret_val; + + /* code for increment equal to 1 */ + +L20: + dmax__ = abs(dx[1]); + i__1 = *n; + for (i__ = 2; i__ <= i__1; ++i__) + { + if ((d__1 = dx[i__], abs(d__1)) <= dmax__) + { + goto L30; + } + ret_val = i__; + dmax__ = (d__1 = dx[i__], abs(d__1)); + L30:; + } + return ret_val; +} /* idamax_ */ + +real_type epslon_(real_type* x) +{ +#if defined(TEST_MPF_100) || defined(TEST_MPFR_100) || defined(TEST_GMPXX) || defined(TEST_MPFRXX) + return std::ldexp(1.0, 1 - ((100 + 1) * 1000L) / 301L); +#elif defined(TEST_CPP_DEC_FLOAT_BN) + return std::pow(10.0, 1 - std::numeric_limits<efx::cpp_dec_float_50>::digits10); +#elif defined(NATIVE_FLOAT128) + return FLT128_EPSILON; +#else + return CAST_TO_RT(std::numeric_limits<real_type>::epsilon()); +#endif +} /* epslon_ */ + +/* Subroutine */ int mm_(real_type* a, integer* lda, integer* n1, integer* n3, real_type* b, integer* ldb, integer* n2, real_type* c__, + integer* ldc) +{ + /* System generated locals */ + integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2; + + /* Local variables */ + static integer i__, j; + + /* purpose: */ + /* multiply matrix b times matrix c and store the result in matrix a. */ + + /* parameters: */ + + /* a double precision(lda,n3), matrix of n1 rows and n3 columns */ + + /* lda integer, leading dimension of array a */ + + /* n1 integer, number of rows in matrices a and b */ + + /* n3 integer, number of columns in matrices a and c */ + + /* b double precision(ldb,n2), matrix of n1 rows and n2 columns */ + + /* ldb integer, leading dimension of array b */ + + /* n2 integer, number of columns in matrix b, and number of rows in */ + /* matrix c */ + + /* c double precision(ldc,n3), matrix of n2 rows and n3 columns */ + + /* ldc integer, leading dimension of array c */ + + /* ---------------------------------------------------------------------- */ + + /* Parameter adjustments */ + a_dim1 = *lda; + a_offset = 1 + a_dim1; + a -= a_offset; + b_dim1 = *ldb; + b_offset = 1 + b_dim1; + b -= b_offset; + c_dim1 = *ldc; + c_offset = 1 + c_dim1; + c__ -= c_offset; + + /* Function Body */ + i__1 = *n3; + for (j = 1; j <= i__1; ++j) + { + i__2 = *n1; + for (i__ = 1; i__ <= i__2; ++i__) + { + a[i__ + j * a_dim1] = CAST_TO_RT(0); + /* L10: */ + } + dmxpy_(n2, &a[j * a_dim1 + 1], n1, ldb, &c__[j * c_dim1 + 1], &b[b_offset]); + /* L20: */ + } + + return 0; +} /* mm_ */ + +/* Subroutine */ int dmxpy_(integer* n1, real_type* y, integer* n2, integer* ldm, real_type* x, real_type* m) +{ + /* System generated locals */ + integer m_dim1, m_offset, i__1, i__2; + + /* Local variables */ + static integer i__, j, jmin; + + /* purpose: */ + /* multiply matrix m times vector x and add the result to vector y. */ + + /* parameters: */ + + /* n1 integer, number of elements in vector y, and number of rows in */ + /* matrix m */ + + /* y double precision(n1), vector of length n1 to which is added */ + /* the product m*x */ + + /* n2 integer, number of elements in vector x, and number of columns */ + /* in matrix m */ + + /* ldm integer, leading dimension of array m */ + + /* x double precision(n2), vector of length n2 */ + + /* m double precision(ldm,n2), matrix of n1 rows and n2 columns */ + + /* ---------------------------------------------------------------------- */ + + /* cleanup odd vector */ + + /* Parameter adjustments */ + --y; + m_dim1 = *ldm; + m_offset = 1 + m_dim1; + m -= m_offset; + --x; + + /* Function Body */ + j = *n2 % 2; + if (j >= 1) + { + i__1 = *n1; + for (i__ = 1; i__ <= i__1; ++i__) + { + y[i__] += x[j] * m[i__ + j * m_dim1]; + /* L10: */ + } + } + + /* cleanup odd group of two vectors */ + + j = *n2 % 4; + if (j >= 2) + { + i__1 = *n1; + for (i__ = 1; i__ <= i__1; ++i__) + { + y[i__] = y[i__] + x[j - 1] * m[i__ + (j - 1) * m_dim1] + x[j] * m[i__ + j * m_dim1]; + /* L20: */ + } + } + + /* cleanup odd group of four vectors */ + + j = *n2 % 8; + if (j >= 4) + { + i__1 = *n1; + for (i__ = 1; i__ <= i__1; ++i__) + { + y[i__] = y[i__] + x[j - 3] * m[i__ + (j - 3) * m_dim1] + x[j - 2] * m[i__ + (j - 2) * m_dim1] + x[j - 1] * m[i__ + (j - 1) * m_dim1] + x[j] * m[i__ + j * m_dim1]; + /* L30: */ + } + } + + /* cleanup odd group of eight vectors */ + + j = *n2 % 16; + if (j >= 8) + { + i__1 = *n1; + for (i__ = 1; i__ <= i__1; ++i__) + { + y[i__] = y[i__] + x[j - 7] * m[i__ + (j - 7) * m_dim1] + x[j - 6] * m[i__ + (j - 6) * m_dim1] + x[j - 5] * m[i__ + (j - 5) * m_dim1] + x[j - 4] * m[i__ + (j - 4) * m_dim1] + x[j - 3] * m[i__ + (j - 3) * m_dim1] + x[j - 2] * m[i__ + (j - 2) * m_dim1] + x[j - 1] * m[i__ + (j - 1) * m_dim1] + x[j] * m[i__ + j * m_dim1]; + /* L40: */ + } + } + + /* main loop - groups of sixteen vectors */ + + jmin = j + 16; + i__1 = *n2; + for (j = jmin; j <= i__1; j += 16) + { + i__2 = *n1; + for (i__ = 1; i__ <= i__2; ++i__) + { + y[i__] = y[i__] + x[j - 15] * m[i__ + (j - 15) * m_dim1] + x[j - 14] * m[i__ + (j - 14) * m_dim1] + x[j - 13] * m[i__ + (j - 13) * m_dim1] + x[j - 12] * m[i__ + (j - 12) * m_dim1] + x[j - 11] * m[i__ + (j - 11) * m_dim1] + x[j - 10] * m[i__ + (j - 10) * m_dim1] + x[j - 9] * m[i__ + (j - 9) * m_dim1] + x[j - 8] * m[i__ + (j - 8) * m_dim1] + x[j - 7] * m[i__ + (j - 7) * m_dim1] + x[j - 6] * m[i__ + (j - 6) * m_dim1] + x[j - 5] * m[i__ + (j - 5) * m_dim1] + x[j - 4] * m[i__ + (j - 4) * m_dim1] + x[j - 3] * m[i__ + (j - 3) * m_dim1] + x[j - 2] * m[i__ + (j - 2) * m_dim1] + x[j - 1] * m[i__ + (j - 1) * m_dim1] + x[j] * m[i__ + j * m_dim1]; + /* L50: */ + } + /* L60: */ + } + return 0; +} /* dmxpy_ */ + +real_type ran_(integer* iseed) +{ + /* System generated locals */ + real_type ret_val; + + /* Local variables */ + static integer it1, it2, it3, it4; + + /* modified from the LAPACK auxiliary routine 10/12/92 JD */ + /* -- LAPACK auxiliary routine (version 1.0) -- */ + /* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */ + /* Courant Institute, Argonne National Lab, and Rice University */ + /* February 29, 1992 */ + + /* .. Array Arguments .. */ + /* .. */ + + /* Purpose */ + /* ======= */ + + /* DLARAN returns a random double number from a uniform (0,1) */ + /* distribution. */ + + /* Arguments */ + /* ========= */ + + /* ISEED (input/output) INTEGER array, dimension (4) */ + /* On entry, the seed of the random number generator; the array */ + /* elements must be between 0 and 4095, and ISEED(4) must be */ + /* odd. */ + /* On exit, the seed is updated. */ + + /* Further Details */ + /* =============== */ + + /* This routine uses a multiplicative congruential method with modulus */ + /* 2**48 and multiplier 33952834046453 (see G.S.Fishman, */ + /* 'Multiplicative congruential random number generators with modulus */ + /* 2**b: an exhaustive analysis for b = 32 and a partial analysis for */ + /* b = 48', Math. Comp. 189, pp 331-344, 1990). */ + + /* 48-bit integers are stored in 4 integer array elements with 12 bits */ + /* per element. Hence the routine is portable across machines with */ + /* integers of 32 bits or more. */ + + /* .. Parameters .. */ + /* .. */ + /* .. Local Scalars .. */ + /* .. */ + /* .. Intrinsic Functions .. */ + /* .. */ + /* .. Executable Statements .. */ + + /* multiply the seed by the multiplier modulo 2**48 */ + + /* Parameter adjustments */ + --iseed; + + /* Function Body */ + it4 = iseed[4] * 2549; + it3 = it4 / 4096; + it4 -= it3 << 12; + it3 = it3 + iseed[3] * 2549 + iseed[4] * 2508; + it2 = it3 / 4096; + it3 -= it2 << 12; + it2 = it2 + iseed[2] * 2549 + iseed[3] * 2508 + iseed[4] * 322; + it1 = it2 / 4096; + it2 -= it1 << 12; + it1 = it1 + iseed[1] * 2549 + iseed[2] * 2508 + iseed[3] * 322 + iseed[4] * 494; + it1 %= 4096; + + /* return updated seed */ + + iseed[1] = it1; + iseed[2] = it2; + iseed[3] = it3; + iseed[4] = it4; + + /* convert 48-bit integer to a double number in the interval (0,1) */ + + ret_val = ((real_type)it1 + ((real_type)it2 + ((real_type)it3 + (real_type)it4 * 2.44140625e-4) * 2.44140625e-4) * 2.44140625e-4) * 2.44140625e-4; + return ret_val; + + /* End of RAN */ + +} /* ran_ */ + +/* + +Double results: +~~~~~~~~~~~~~~ + +norm. resid resid machep x(1) x(n) +6.4915 7.207e-013 2.2204e-016 1 1 + + + +times are reported for matrices of order 1000 +factor solve total mflops unit ratio +times for array with leading dimension of1001 +1.443 0.003 1.446 462.43 0.004325 25.821 + + +mpf_class results: +~~~~~~~~~~~~~~~~~~ + +norm. resid resid machep x(1) x(n) +3.6575e-05 5.2257e-103 2.8575e-101 1 1 + + + +times are reported for matrices of order 1000 +factor solve total mflops unit ratio +times for array with leading dimension of1001 +266.45 0.798 267.24 2.5021 0.79933 4772.2 + + +number<gmp_float<100> >: +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + norm. resid resid machep x(1) x(n) + 0.36575e-4 0.52257e-102 0.28575e-100 0.1e1 0.1e1 + + + + times are reported for matrices of order 1000 + factor solve total mflops unit ratio + times for array with leading dimension of1001 + 279.96 0.84 280.8 2.3813 0.83988 5014.3 + +boost::multiprecision::ef::cpp_dec_float_50: +~~~~~~~~~~~~~~~~~~~~~~~~~ + + norm. resid resid machep x(1) x(n) + 2.551330735e-16 1.275665107e-112 1e-99 1 1 + + + + times are reported for matrices of order 1000 + factor solve total mflops unit ratio + times for array with leading dimension of1001 + 363.89 1.074 364.97 1.8321 1.0916 6517.3 +*/ diff --git a/src/boost/libs/multiprecision/performance/miller_rabin_performance.cpp b/src/boost/libs/multiprecision/performance/miller_rabin_performance.cpp new file mode 100644 index 00000000..bb21160b --- /dev/null +++ b/src/boost/libs/multiprecision/performance/miller_rabin_performance.cpp @@ -0,0 +1,166 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2012 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#define BOOST_CHRONO_HEADER_ONLY + +#if !defined(TEST_MPZ) && !defined(TEST_TOMMATH) && !defined(TEST_CPP_INT) +#define TEST_MPZ +#define TEST_TOMMATH +#define TEST_CPP_INT +#endif + +#ifdef TEST_MPZ +#include <boost/multiprecision/gmp.hpp> +#endif +#ifdef TEST_TOMMATH +#include <boost/multiprecision/tommath.hpp> +#endif +#ifdef TEST_CPP_INT +#include <boost/multiprecision/cpp_int.hpp> +#endif +#include <boost/multiprecision/miller_rabin.hpp> +#include <boost/chrono.hpp> +#include <map> + +template <class Clock> +struct stopwatch +{ + typedef typename Clock::duration duration; + stopwatch() + { + m_start = Clock::now(); + } + duration elapsed() + { + return Clock::now() - m_start; + } + void reset() + { + m_start = Clock::now(); + } + + private: + typename Clock::time_point m_start; +}; + +unsigned allocation_count = 0; + +void* (*alloc_func_ptr)(size_t); +void* (*realloc_func_ptr)(void*, size_t, size_t); +void (*free_func_ptr)(void*, size_t); + +void* alloc_func(size_t n) +{ + ++allocation_count; + return (*alloc_func_ptr)(n); +} + +void free_func(void* p, size_t n) +{ + (*free_func_ptr)(p, n); +} + +void* realloc_func(void* p, size_t old, size_t n) +{ + ++allocation_count; + return (*realloc_func_ptr)(p, old, n); +} + +#ifdef TEST_MPZ +boost::chrono::duration<double> test_miller_rabin_gmp() +{ + using namespace boost::random; + using namespace boost::multiprecision; + + stopwatch<boost::chrono::high_resolution_clock> c; + + independent_bits_engine<mt11213b, 256, mpz_int> gen; + + for (unsigned i = 0; i < 1000; ++i) + { + mpz_int n = gen(); + mpz_probab_prime_p(n.backend().data(), 25); + } + return c.elapsed(); +} +#endif + +std::map<std::string, double> results; +double min_time = (std::numeric_limits<double>::max)(); + +template <class IntType> +boost::chrono::duration<double> test_miller_rabin(const char* name) +{ + using namespace boost::random; + + stopwatch<boost::chrono::high_resolution_clock> c; + + independent_bits_engine<mt11213b, 256, IntType> gen; + // + // We must use a different generator for the tests and number generation, otherwise + // we get false positives. + // + mt19937 gen2; + unsigned result_count = 0; + + for (unsigned i = 0; i < 1000; ++i) + { + IntType n = gen(); + if (boost::multiprecision::miller_rabin_test(n, 25, gen2)) + ++result_count; + } + boost::chrono::duration<double> t = c.elapsed(); + double d = t.count(); + if (d < min_time) + min_time = d; + results[name] = d; + std::cout << "Time for " << std::setw(30) << std::left << name << " = " << d << std::endl; + std::cout << "Number of primes found = " << result_count << std::endl; + return t; +} + +void generate_quickbook() +{ + std::cout << "[table\n[[Integer Type][Relative Performance (Actual time in parenthesis)]]\n"; + + std::map<std::string, double>::const_iterator i(results.begin()), j(results.end()); + + while (i != j) + { + double rel = i->second / min_time; + std::cout << "[[" << i->first << "][" << rel << "(" << i->second << "s)]]\n"; + ++i; + } + + std::cout << "]\n"; +} + +int main() +{ + using namespace boost::multiprecision; +#ifdef TEST_CPP_INT + test_miller_rabin<number<cpp_int_backend<>, et_off> >("cpp_int (no Expression templates)"); + test_miller_rabin<cpp_int>("cpp_int"); + test_miller_rabin<number<cpp_int_backend<128> > >("cpp_int (128-bit cache)"); + test_miller_rabin<number<cpp_int_backend<256> > >("cpp_int (256-bit cache)"); + test_miller_rabin<number<cpp_int_backend<512> > >("cpp_int (512-bit cache)"); + test_miller_rabin<number<cpp_int_backend<1024> > >("cpp_int (1024-bit cache)"); + test_miller_rabin<int1024_t>("int1024_t"); + test_miller_rabin<checked_int1024_t>("checked_int1024_t"); +#endif +#ifdef TEST_MPZ + test_miller_rabin<number<gmp_int, et_off> >("mpz_int (no Expression templates)"); + test_miller_rabin<mpz_int>("mpz_int"); + std::cout << "Time for mpz_int (native Miller Rabin Test) = " << test_miller_rabin_gmp() << std::endl; +#endif +#ifdef TEST_TOMMATH + test_miller_rabin<number<boost::multiprecision::tommath_int, et_off> >("tom_int (no Expression templates)"); + test_miller_rabin<boost::multiprecision::tom_int>("tom_int"); +#endif + + generate_quickbook(); + + return 0; +} diff --git a/src/boost/libs/multiprecision/performance/performance_test-gcc-linux.log b/src/boost/libs/multiprecision/performance/performance_test-gcc-linux.log new file mode 100644 index 00000000..83b15004 --- /dev/null +++ b/src/boost/libs/multiprecision/performance/performance_test-gcc-linux.log @@ -0,0 +1,718 @@ +gmp_float 50 + 0.0180885 +gmp_float 50 - 0.0227712 +gmp_float 50 * 0.0567584 +gmp_float 50 / 0.289062 +gmp_float 50 str 0.00354863 +gmp_float 50 +(int)0.0129337 +gmp_float 50 -(int)0.0256267 +gmp_float 50 *(int)0.0197258 +gmp_float 50 /(int)0.087785 +gmp_float 100 + 0.0196977 +gmp_float 100 - 0.024745 +gmp_float 100 * 0.0972 +gmp_float 100 / 0.393792 +gmp_float 100 str 0.00528245 +gmp_float 100 +(int)0.0154802 +gmp_float 100 -(int)0.0242376 +gmp_float 100 *(int)0.0251239 +gmp_float 100 /(int)0.100588 +gmp_float 500 + 0.034133 +gmp_float 500 - 0.0411447 +gmp_float 500 * 0.938779 +gmp_float 500 / 1.5973 +gmp_float 500 str 0.0406575 +gmp_float 500 +(int)0.0220839 +gmp_float 500 -(int)0.0310849 +gmp_float 500 *(int)0.046899 +gmp_float 500 /(int)0.240511 +gmp_int 128 + 0.0236625 +gmp_int 128 - 0.0255431 +gmp_int 128 * 0.0164612 +gmp_int 128 / 0.20205 +gmp_int 128 str 0.000397397 +gmp_int 128 +(int)0.00907029 +gmp_int 128 -(int)0.0120936 +gmp_int 128 *(int)0.0139764 +gmp_int 128 /(int)0.061181 +gmp_int 128 % 0.167724 +gmp_int 128 | 0.0126627 +gmp_int 128 & 0.0129377 +gmp_int 128 ^ 0.0136018 +gmp_int 128 << 0.0109566 +gmp_int 128 >> 0.0107283 +gmp_int 128 %(int)0.0408971 +gmp_int 128 |(int)0.0463637 +gmp_int 128 &(int)0.0502028 +gmp_int 128 ^(int)0.047593 +gmp_int 128 gcd 0.452707 +gmp_int 256 + 0.0257277 +gmp_int 256 - 0.0314085 +gmp_int 256 * 0.0495293 +gmp_int 256 / 0.242695 +gmp_int 256 str 0.000617745 +gmp_int 256 +(int)0.0129046 +gmp_int 256 -(int)0.0163165 +gmp_int 256 *(int)0.0153128 +gmp_int 256 /(int)0.0730963 +gmp_int 256 % 0.203102 +gmp_int 256 | 0.0149383 +gmp_int 256 & 0.0170717 +gmp_int 256 ^ 0.0160796 +gmp_int 256 << 0.0146023 +gmp_int 256 >> 0.010293 +gmp_int 256 %(int)0.0525884 +gmp_int 256 |(int)0.0501017 +gmp_int 256 &(int)0.0508389 +gmp_int 256 ^(int)0.0498771 +gmp_int 256 gcd 2.17179 +gmp_int 512 + 0.0283556 +gmp_int 512 - 0.0398509 +gmp_int 512 * 0.104633 +gmp_int 512 / 0.294206 +gmp_int 512 str 0.00125749 +gmp_int 512 +(int)0.0156938 +gmp_int 512 -(int)0.0204795 +gmp_int 512 *(int)0.0190714 +gmp_int 512 /(int)0.09638 +gmp_int 512 % 0.23687 +gmp_int 512 | 0.0244134 +gmp_int 512 & 0.0209509 +gmp_int 512 ^ 0.0266707 +gmp_int 512 << 0.0178981 +gmp_int 512 >> 0.0122496 +gmp_int 512 %(int)0.0655264 +gmp_int 512 |(int)0.0536497 +gmp_int 512 &(int)0.0532932 +gmp_int 512 ^(int)0.0540655 +gmp_int 512 gcd 4.86569 +gmp_int 1024 + 0.0417292 +gmp_int 1024 - 0.0504965 +gmp_int 1024 * 0.330741 +gmp_int 1024 / 0.376529 +gmp_int 1024 str 0.00295526 +gmp_int 1024 +(int)0.0258726 +gmp_int 1024 -(int)0.0235972 +gmp_int 1024 *(int)0.0326542 +gmp_int 1024 /(int)0.148103 +gmp_int 1024 % 0.301177 +gmp_int 1024 | 0.0262977 +gmp_int 1024 & 0.0235786 +gmp_int 1024 ^ 0.0254182 +gmp_int 1024 << 0.0206225 +gmp_int 1024 >> 0.012848 +gmp_int 1024 %(int)0.0765616 +gmp_int 1024 |(int)0.0495613 +gmp_int 1024 &(int)0.0512979 +gmp_int 1024 ^(int)0.0491785 +gmp_int 1024 gcd 10.2899 +cpp_int 128 + 0.0226262 +cpp_int 128 - 0.0256171 +cpp_int 128 * 0.0363846 +cpp_int 128 / 0.227187 +cpp_int 128 str 0.000703371 +cpp_int 128 +(int)0.0156956 +cpp_int 128 -(int)0.0122229 +cpp_int 128 *(int)0.0257193 +cpp_int 128 /(int)0.129609 +cpp_int 128 % 0.226534 +cpp_int 128 | 0.0242976 +cpp_int 128 & 0.0244482 +cpp_int 128 ^ 0.0243197 +cpp_int 128 << 0.0182175 +cpp_int 128 >> 0.0215535 +cpp_int 128 %(int)0.181554 +cpp_int 128 |(int)0.0454215 +cpp_int 128 &(int)0.0426893 +cpp_int 128 ^(int)0.0404509 +cpp_int 128 gcd 4.16823 +cpp_int 256 + 0.0275581 +cpp_int 256 - 0.0305114 +cpp_int 256 * 0.100083 +cpp_int 256 / 0.467116 +cpp_int 256 str 0.00181769 +cpp_int 256 +(int)0.017033 +cpp_int 256 -(int)0.0143035 +cpp_int 256 *(int)0.0294836 +cpp_int 256 /(int)0.303922 +cpp_int 256 % 0.435207 +cpp_int 256 | 0.0281237 +cpp_int 256 & 0.028049 +cpp_int 256 ^ 0.0280192 +cpp_int 256 << 0.0210768 +cpp_int 256 >> 0.0175781 +cpp_int 256 %(int)0.279274 +cpp_int 256 |(int)0.0323883 +cpp_int 256 &(int)0.0338674 +cpp_int 256 ^(int)0.0299941 +cpp_int 256 gcd 8.51244 +cpp_int 512 + 0.033691 +cpp_int 512 - 0.0422701 +cpp_int 512 * 0.343683 +cpp_int 512 / 0.755608 +cpp_int 512 str 0.00434022 +cpp_int 512 +(int)0.0196755 +cpp_int 512 -(int)0.0171212 +cpp_int 512 *(int)0.039305 +cpp_int 512 /(int)0.535727 +cpp_int 512 % 0.719958 +cpp_int 512 | 0.0339623 +cpp_int 512 & 0.0342017 +cpp_int 512 ^ 0.033929 +cpp_int 512 << 0.0269161 +cpp_int 512 >> 0.0216914 +cpp_int 512 %(int)0.53345 +cpp_int 512 |(int)0.0324562 +cpp_int 512 &(int)0.0424884 +cpp_int 512 ^(int)0.0323887 +cpp_int 512 gcd 19.489 +cpp_int 1024 + 0.0456764 +cpp_int 1024 - 0.0574919 +cpp_int 1024 * 1.28548 +cpp_int 1024 / 1.30086 +cpp_int 1024 str 0.0122363 +cpp_int 1024 +(int)0.0241476 +cpp_int 1024 -(int)0.0212992 +cpp_int 1024 *(int)0.0540818 +cpp_int 1024 /(int)1.00179 +cpp_int 1024 % 1.27181 +cpp_int 1024 | 0.0457886 +cpp_int 1024 & 0.0456006 +cpp_int 1024 ^ 0.0456494 +cpp_int 1024 << 0.0394128 +cpp_int 1024 >> 0.0294462 +cpp_int 1024 %(int)0.962651 +cpp_int 1024 |(int)0.0372077 +cpp_int 1024 &(int)0.0577198 +cpp_int 1024 ^(int)0.0372218 +cpp_int 1024 gcd 47.7651 +cpp_int(fixed) 128 + 0.0183948 +cpp_int(fixed) 128 - 0.0182905 +cpp_int(fixed) 128 * 0.0201727 +cpp_int(fixed) 128 / 0.206852 +cpp_int(fixed) 128 str 0.000630107 +cpp_int(fixed) 128 +(int)0.00967714 +cpp_int(fixed) 128 -(int)0.00810627 +cpp_int(fixed) 128 *(int)0.0183201 +cpp_int(fixed) 128 /(int)0.111309 +cpp_int(fixed) 128 % 0.204164 +cpp_int(fixed) 128 | 0.0136789 +cpp_int(fixed) 128 & 0.0143848 +cpp_int(fixed) 128 ^ 0.0137773 +cpp_int(fixed) 128 << 0.0131154 +cpp_int(fixed) 128 >> 0.00912176 +cpp_int(fixed) 128 %(int)0.115583 +cpp_int(fixed) 128 |(int)0.0164462 +cpp_int(fixed) 128 &(int)0.0169816 +cpp_int(fixed) 128 ^(int)0.014607 +cpp_int(fixed) 128 gcd 2.87326 +cpp_int(fixed) 256 + 0.0217614 +cpp_int(fixed) 256 - 0.0208437 +cpp_int(fixed) 256 * 0.0385279 +cpp_int(fixed) 256 / 0.321272 +cpp_int(fixed) 256 str 0.00149991 +cpp_int(fixed) 256 +(int)0.0102395 +cpp_int(fixed) 256 -(int)0.00923316 +cpp_int(fixed) 256 *(int)0.021549 +cpp_int(fixed) 256 /(int)0.219146 +cpp_int(fixed) 256 % 0.321039 +cpp_int(fixed) 256 | 0.0154596 +cpp_int(fixed) 256 & 0.0156443 +cpp_int(fixed) 256 ^ 0.015493 +cpp_int(fixed) 256 << 0.0169546 +cpp_int(fixed) 256 >> 0.0114138 +cpp_int(fixed) 256 %(int)0.238857 +cpp_int(fixed) 256 |(int)0.015725 +cpp_int(fixed) 256 &(int)0.021641 +cpp_int(fixed) 256 ^(int)0.0163443 +cpp_int(fixed) 256 gcd 6.68597 +cpp_int(fixed) 512 + 0.0284799 +cpp_int(fixed) 512 - 0.028304 +cpp_int(fixed) 512 * 0.119904 +cpp_int(fixed) 512 / 0.616699 +cpp_int(fixed) 512 str 0.00415653 +cpp_int(fixed) 512 +(int)0.0122821 +cpp_int(fixed) 512 -(int)0.0110103 +cpp_int(fixed) 512 *(int)0.0283635 +cpp_int(fixed) 512 /(int)0.451373 +cpp_int(fixed) 512 % 0.620217 +cpp_int(fixed) 512 | 0.0189862 +cpp_int(fixed) 512 & 0.0192657 +cpp_int(fixed) 512 ^ 0.018973 +cpp_int(fixed) 512 << 0.0188263 +cpp_int(fixed) 512 >> 0.0152103 +cpp_int(fixed) 512 %(int)0.491398 +cpp_int(fixed) 512 |(int)0.0182191 +cpp_int(fixed) 512 &(int)0.0277722 +cpp_int(fixed) 512 ^(int)0.0182565 +cpp_int(fixed) 512 gcd 16.1788 +cpp_int(fixed) 1024 + 0.0396571 +cpp_int(fixed) 1024 - 0.0413187 +cpp_int(fixed) 1024 * 0.371065 +cpp_int(fixed) 1024 / 1.09072 +cpp_int(fixed) 1024 str 0.011546 +cpp_int(fixed) 1024 +(int)0.0254102 +cpp_int(fixed) 1024 -(int)0.020939 +cpp_int(fixed) 1024 *(int)0.0494233 +cpp_int(fixed) 1024 /(int)0.870306 +cpp_int(fixed) 1024 % 1.09888 +cpp_int(fixed) 1024 | 0.0393824 +cpp_int(fixed) 1024 & 0.0397966 +cpp_int(fixed) 1024 ^ 0.0394082 +cpp_int(fixed) 1024 << 0.0392477 +cpp_int(fixed) 1024 >> 0.0214742 +cpp_int(fixed) 1024 %(int)0.941513 +cpp_int(fixed) 1024 |(int)0.0304613 +cpp_int(fixed) 1024 &(int)0.0497983 +cpp_int(fixed) 1024 ^(int)0.0333848 +cpp_int(fixed) 1024 gcd 41.9178 +cpp_rational 128 + 8.33358 +cpp_rational 128 - 8.3543 +cpp_rational 128 * 15.3196 +cpp_rational 128 / 31.794 +cpp_rational 128 str 0.00980984 +cpp_rational 128 +(int)1.14042 +cpp_rational 128 -(int)1.13947 +cpp_rational 128 *(int)1.3425 +cpp_rational 128 /(int)1.35276 +cpp_rational 256 + 24.5753 +cpp_rational 256 - 24.3831 +cpp_rational 256 * 45.9283 +cpp_rational 256 / 80.7871 +cpp_rational 256 str 0.0288878 +cpp_rational 256 +(int)1.54697 +cpp_rational 256 -(int)1.55711 +cpp_rational 256 *(int)2.05921 +cpp_rational 256 /(int)2.12933 +cpp_rational 512 + 58.1983 +cpp_rational 512 - 58.3044 +cpp_rational 512 * 111.528 +cpp_rational 512 / 184.73 +cpp_rational 512 str 0.067039 +cpp_rational 512 +(int)1.83113 +cpp_rational 512 -(int)1.82889 +cpp_rational 512 *(int)2.75206 +cpp_rational 512 /(int)2.75885 +cpp_rational 1024 + 139.884 +cpp_rational 1024 - 139.665 +cpp_rational 1024 * 270.253 +cpp_rational 1024 / 436.471 +cpp_rational 1024 str 0.165057 +cpp_rational 1024 +(int)2.65768 +cpp_rational 1024 -(int)2.68279 +cpp_rational 1024 *(int)4.26866 +cpp_rational 1024 /(int)4.27228 +mpq_rational 128 + 0.518878 +mpq_rational 128 - 0.520249 +mpq_rational 128 * 0.940549 +mpq_rational 128 / 2.63335 +mpq_rational 128 str 0.000732008 +mpq_rational 128 +(int)0.145745 +mpq_rational 128 -(int)0.142505 +mpq_rational 128 *(int)0.173305 +mpq_rational 128 /(int)0.178914 +mpq_rational 256 + 2.2747 +mpq_rational 256 - 2.27886 +mpq_rational 256 * 4.27402 +mpq_rational 256 / 8.07149 +mpq_rational 256 str 0.00123256 +mpq_rational 256 +(int)0.164417 +mpq_rational 256 -(int)0.161741 +mpq_rational 256 *(int)0.193095 +mpq_rational 256 /(int)0.202255 +mpq_rational 512 + 5.09463 +mpq_rational 512 - 5.09757 +mpq_rational 512 * 9.6481 +mpq_rational 512 / 16.9064 +mpq_rational 512 str 0.00244388 +mpq_rational 512 +(int)0.202901 +mpq_rational 512 -(int)0.200644 +mpq_rational 512 *(int)0.248942 +mpq_rational 512 /(int)0.251928 +mpq_rational 1024 + 11.2492 +mpq_rational 1024 - 11.2528 +mpq_rational 1024 * 21.0227 +mpq_rational 1024 / 35.7647 +mpq_rational 1024 str 0.00559869 +mpq_rational 1024 +(int)0.287349 +mpq_rational 1024 -(int)0.28136 +mpq_rational 1024 *(int)0.337805 +mpq_rational 1024 /(int)0.351164 +tommath_int 128 + 0.0169999 +tommath_int 128 - 0.025088 +tommath_int 128 * 0.0608098 +tommath_int 128 / 1.14807 +tommath_int 128 str 0.00864677 +tommath_int 128 +(int)0.170239 +tommath_int 128 -(int)0.169805 +tommath_int 128 *(int)0.18998 +tommath_int 128 /(int)0.936106 +tommath_int 128 % 1.10993 +tommath_int 128 | 0.0742258 +tommath_int 128 & 0.0747022 +tommath_int 128 ^ 0.0734074 +tommath_int 128 << 0.0316344 +tommath_int 128 >> 0.139155 +tommath_int 128 %(int)0.871093 +tommath_int 128 |(int)0.249135 +tommath_int 128 &(int)0.224394 +tommath_int 128 ^(int)0.248407 +tommath_int 128 gcd 7.6073 +tommath_int 256 + 0.0191462 +tommath_int 256 - 0.0267191 +tommath_int 256 * 0.0843842 +tommath_int 256 / 1.34052 +tommath_int 256 str 0.0212684 +tommath_int 256 +(int)0.173633 +tommath_int 256 -(int)0.173084 +tommath_int 256 *(int)0.20074 +tommath_int 256 /(int)1.17192 +tommath_int 256 % 1.33781 +tommath_int 256 | 0.0740269 +tommath_int 256 & 0.0747001 +tommath_int 256 ^ 0.0741847 +tommath_int 256 << 0.0379471 +tommath_int 256 >> 0.14164 +tommath_int 256 %(int)1.52193 +tommath_int 256 |(int)0.251418 +tommath_int 256 &(int)0.230435 +tommath_int 256 ^(int)0.249516 +tommath_int 256 gcd 15.8851 +tommath_int 512 + 0.0241933 +tommath_int 512 - 0.032154 +tommath_int 512 * 0.195855 +tommath_int 512 / 2.061 +tommath_int 512 str 0.0827649 +tommath_int 512 +(int)0.25223 +tommath_int 512 -(int)0.25482 +tommath_int 512 *(int)0.305608 +tommath_int 512 /(int)1.76155 +tommath_int 512 % 1.97453 +tommath_int 512 | 0.0795209 +tommath_int 512 & 0.0815029 +tommath_int 512 ^ 0.0793004 +tommath_int 512 << 0.0449753 +tommath_int 512 >> 0.149597 +tommath_int 512 %(int)1.74258 +tommath_int 512 |(int)0.253519 +tommath_int 512 &(int)0.235246 +tommath_int 512 ^(int)0.261762 +tommath_int 512 gcd 33.8904 +tommath_int 1024 + 0.0356467 +tommath_int 1024 - 0.0426379 +tommath_int 1024 * 0.563154 +tommath_int 1024 / 3.3106 +tommath_int 1024 str 0.200351 +tommath_int 1024 +(int)0.183982 +tommath_int 1024 -(int)0.182348 +tommath_int 1024 *(int)0.265242 +tommath_int 1024 /(int)2.99248 +tommath_int 1024 % 3.36442 +tommath_int 1024 | 0.0935681 +tommath_int 1024 & 0.0990244 +tommath_int 1024 ^ 0.0948247 +tommath_int 1024 << 0.0671463 +tommath_int 1024 >> 0.167341 +tommath_int 1024 %(int)2.8911 +tommath_int 1024 |(int)0.26358 +tommath_int 1024 &(int)0.244976 +tommath_int 1024 ^(int)0.261357 +tommath_int 1024 gcd 67.1657 +cpp_dec_float 50 + 0.0139248 +cpp_dec_float 50 - 0.0142418 +cpp_dec_float 50 * 0.118247 +cpp_dec_float 50 / 1.82747 +cpp_dec_float 50 str 0.00932849 +cpp_dec_float 50 +(int)0.0253923 +cpp_dec_float 50 -(int)0.0248418 +cpp_dec_float 50 *(int)0.0371704 +cpp_dec_float 50 /(int)0.199883 +cpp_dec_float 100 + 0.0171021 +cpp_dec_float 100 - 0.0176287 +cpp_dec_float 100 * 0.237033 +cpp_dec_float 100 / 3.63766 +cpp_dec_float 100 str 0.0201057 +cpp_dec_float 100 +(int)0.0330663 +cpp_dec_float 100 -(int)0.0332922 +cpp_dec_float 100 *(int)0.0606472 +cpp_dec_float 100 /(int)0.343778 +cpp_dec_float 500 + 0.043194 +cpp_dec_float 500 - 0.0443422 +cpp_dec_float 500 * 2.12299 +cpp_dec_float 500 / 25.7245 +cpp_dec_float 500 str 0.0655127 +cpp_dec_float 500 +(int)0.0706977 +cpp_dec_float 500 -(int)0.0727089 +cpp_dec_float 500 *(int)0.239796 +cpp_dec_float 500 /(int)1.39609 +mpfr_float 50 + 0.019179 +mpfr_float 50 - 0.0225632 +mpfr_float 50 * 0.0588765 +mpfr_float 50 / 0.317276 +mpfr_float 50 str 0.00725414 +mpfr_float 50 +(int)0.0286079 +mpfr_float 50 -(int)0.0465151 +mpfr_float 50 *(int)0.0362579 +mpfr_float 50 /(int)0.0888645 +mpfr_float 100 + 0.0210236 +mpfr_float 100 - 0.0250703 +mpfr_float 100 * 0.0946262 +mpfr_float 100 / 0.456375 +mpfr_float 100 str 0.00900848 +mpfr_float 100 +(int)0.0320443 +mpfr_float 100 -(int)0.0487733 +mpfr_float 100 *(int)0.0437034 +mpfr_float 100 /(int)0.154203 +mpfr_float 500 + 0.033691 +mpfr_float 500 - 0.0371954 +mpfr_float 500 * 0.851721 +mpfr_float 500 / 2.7946 +mpfr_float 500 str 0.0342011 +mpfr_float 500 +(int)0.0414774 +mpfr_float 500 -(int)0.0616173 +mpfr_float 500 *(int)0.0826485 +mpfr_float 500 /(int)0.254227 +[section:float_performance Float Type Perfomance] +[table Operator * +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][2.08334 (0.118247s)][2.50494 (0.237033s)][2.49259 (2.12299s)]] +[[gmp_float][[*1] (0.0567584s)][1.0272 (0.0972s)][1.10221 (0.938779s)]] +[[mpfr_float][1.03732 (0.0588765s)][[*1] (0.0946262s)][[*1] (0.851721s)]] +] +[table Operator *(int) +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][1.88436 (0.0371704s)][2.41392 (0.0606472s)][5.11303 (0.239796s)]] +[[gmp_float][[*1] (0.0197258s)][[*1] (0.0251239s)][[*1] (0.046899s)]] +[[mpfr_float][1.8381 (0.0362579s)][1.73951 (0.0437034s)][1.76227 (0.0826485s)]] +] +[table Operator + +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][[*1] (0.0139248s)][[*1] (0.0171021s)][1.28206 (0.043194s)]] +[[gmp_float][1.29901 (0.0180885s)][1.15177 (0.0196977s)][1.01312 (0.034133s)]] +[[mpfr_float][1.37732 (0.019179s)][1.2293 (0.0210236s)][[*1] (0.033691s)]] +] +[table Operator +(int) +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][1.96327 (0.0253923s)][2.13604 (0.0330663s)][3.20133 (0.0706977s)]] +[[gmp_float][[*1] (0.0129337s)][[*1] (0.0154802s)][[*1] (0.0220839s)]] +[[mpfr_float][2.21189 (0.0286079s)][2.07002 (0.0320443s)][1.87818 (0.0414774s)]] +] +[table Operator - +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][[*1] (0.0142418s)][[*1] (0.0176287s)][1.19214 (0.0443422s)]] +[[gmp_float][1.5989 (0.0227712s)][1.40368 (0.024745s)][1.10618 (0.0411447s)]] +[[mpfr_float][1.5843 (0.0225632s)][1.42213 (0.0250703s)][[*1] (0.0371954s)]] +] +[table Operator -(int) +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][[*1] (0.0248418s)][1.37357 (0.0332922s)][2.33904 (0.0727089s)]] +[[gmp_float][1.03159 (0.0256267s)][[*1] (0.0242376s)][[*1] (0.0310849s)]] +[[mpfr_float][1.87245 (0.0465151s)][2.0123 (0.0487733s)][1.98223 (0.0616173s)]] +] +[table Operator / +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][6.32206 (1.82747s)][9.23752 (3.63766s)][16.1049 (25.7245s)]] +[[gmp_float][[*1] (0.289062s)][[*1] (0.393792s)][[*1] (1.5973s)]] +[[mpfr_float][1.09761 (0.317276s)][1.15892 (0.456375s)][1.74957 (2.7946s)]] +] +[table Operator /(int) +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][2.27696 (0.199883s)][3.41769 (0.343778s)][5.8047 (1.39609s)]] +[[gmp_float][[*1] (0.087785s)][[*1] (0.100588s)][[*1] (0.240511s)]] +[[mpfr_float][1.0123 (0.0888645s)][1.53302 (0.154203s)][1.05703 (0.254227s)]] +] +[table Operator str +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][2.62876 (0.00932849s)][3.80613 (0.0201057s)][1.91552 (0.0655127s)]] +[[gmp_float][[*1] (0.00354863s)][[*1] (0.00528245s)][1.18878 (0.0406575s)]] +[[mpfr_float][2.04421 (0.00725414s)][1.70536 (0.00900848s)][[*1] (0.0342011s)]] +] +[endsect] +[section:integer_performance Integer Type Perfomance] +[table Operator % +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][1.35064 (0.226534s)][2.1428 (0.435207s)][3.03946 (0.719958s)][4.22281 (1.27181s)]] +[[cpp_int(fixed)][1.21726 (0.204164s)][1.58068 (0.321039s)][2.61838 (0.620217s)][3.6486 (1.09888s)]] +[[gmp_int][[*1] (0.167724s)][[*1] (0.203102s)][[*1] (0.23687s)][[*1] (0.301177s)]] +[[tommath_int][6.61759 (1.10993s)][6.58689 (1.33781s)][8.33593 (1.97453s)][11.1709 (3.36442s)]] +] +[table Operator %(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][4.43928 (0.181554s)][5.31056 (0.279274s)][8.141 (0.53345s)][12.5735 (0.962651s)]] +[[cpp_int(fixed)][2.82619 (0.115583s)][4.54202 (0.238857s)][7.49924 (0.491398s)][12.2974 (0.941513s)]] +[[gmp_int][[*1] (0.0408971s)][[*1] (0.0525884s)][[*1] (0.0655264s)][[*1] (0.0765616s)]] +[[tommath_int][21.2996 (0.871093s)][28.9405 (1.52193s)][26.5936 (1.74258s)][37.7618 (2.8911s)]] +] +[table Operator & +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][1.88968 (0.0244482s)][1.79292 (0.028049s)][1.77526 (0.0342017s)][1.93398 (0.0456006s)]] +[[cpp_int(fixed)][1.11185 (0.0143848s)][[*1] (0.0156443s)][[*1] (0.0192657s)][1.68783 (0.0397966s)]] +[[gmp_int][[*1] (0.0129377s)][1.09124 (0.0170717s)][1.08747 (0.0209509s)][[*1] (0.0235786s)]] +[[tommath_int][5.77397 (0.0747022s)][4.7749 (0.0747001s)][4.23046 (0.0815029s)][4.19976 (0.0990244s)]] +] +[table Operator &(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][2.51385 (0.0426893s)][1.56497 (0.0338674s)][1.52989 (0.0424884s)][1.15907 (0.0577198s)]] +[[cpp_int(fixed)][[*1] (0.0169816s)][[*1] (0.021641s)][[*1] (0.0277722s)][[*1] (0.0497983s)]] +[[gmp_int][2.9563 (0.0502028s)][2.3492 (0.0508389s)][1.91894 (0.0532932s)][1.03011 (0.0512979s)]] +[[tommath_int][13.2139 (0.224394s)][10.6481 (0.230435s)][8.47057 (0.235246s)][4.91936 (0.244976s)]] +] +[table Operator * +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][2.21032 (0.0363846s)][2.59769 (0.100083s)][3.28466 (0.343683s)][3.88666 (1.28548s)]] +[[cpp_int(fixed)][1.22547 (0.0201727s)][[*1] (0.0385279s)][1.14595 (0.119904s)][1.12192 (0.371065s)]] +[[gmp_int][[*1] (0.0164612s)][1.28554 (0.0495293s)][[*1] (0.104633s)][[*1] (0.330741s)]] +[[tommath_int][3.69412 (0.0608098s)][2.19021 (0.0843842s)][1.87184 (0.195855s)][1.70271 (0.563154s)]] +] +[table Operator *(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][1.8402 (0.0257193s)][1.92542 (0.0294836s)][2.06094 (0.039305s)][1.6562 (0.0540818s)]] +[[cpp_int(fixed)][1.3108 (0.0183201s)][1.40725 (0.021549s)][1.48723 (0.0283635s)][1.51354 (0.0494233s)]] +[[gmp_int][[*1] (0.0139764s)][[*1] (0.0153128s)][[*1] (0.0190714s)][[*1] (0.0326542s)]] +[[tommath_int][13.593 (0.18998s)][13.1093 (0.20074s)][16.0244 (0.305608s)][8.12274 (0.265242s)]] +] +[table Operator + +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][1.33096 (0.0226262s)][1.43935 (0.0275581s)][1.39258 (0.033691s)][1.28136 (0.0456764s)]] +[[cpp_int(fixed)][1.08205 (0.0183948s)][1.13659 (0.0217614s)][1.17718 (0.0284799s)][1.1125 (0.0396571s)]] +[[gmp_int][1.39192 (0.0236625s)][1.34375 (0.0257277s)][1.17204 (0.0283556s)][1.17063 (0.0417292s)]] +[[tommath_int][[*1] (0.0169999s)][[*1] (0.0191462s)][[*1] (0.0241933s)][[*1] (0.0356467s)]] +] +[table Operator +(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][1.73044 (0.0156956s)][1.66346 (0.017033s)][1.60196 (0.0196755s)][[*1] (0.0241476s)]] +[[cpp_int(fixed)][1.06691 (0.00967714s)][[*1] (0.0102395s)][[*1] (0.0122821s)][1.05229 (0.0254102s)]] +[[gmp_int][[*1] (0.00907029s)][1.26028 (0.0129046s)][1.27777 (0.0156938s)][1.07144 (0.0258726s)]] +[[tommath_int][18.7688 (0.170239s)][16.9572 (0.173633s)][20.5363 (0.25223s)][7.61905 (0.183982s)]] +] +[table Operator - +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][1.40057 (0.0256171s)][1.46382 (0.0305114s)][1.49343 (0.0422701s)][1.39142 (0.0574919s)]] +[[cpp_int(fixed)][[*1] (0.0182905s)][[*1] (0.0208437s)][[*1] (0.028304s)][[*1] (0.0413187s)]] +[[gmp_int][1.39653 (0.0255431s)][1.50686 (0.0314085s)][1.40796 (0.0398509s)][1.22212 (0.0504965s)]] +[[tommath_int][1.37164 (0.025088s)][1.28188 (0.0267191s)][1.13602 (0.032154s)][1.03193 (0.0426379s)]] +] +[table Operator -(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][1.50784 (0.0122229s)][1.54914 (0.0143035s)][1.55501 (0.0171212s)][1.0172 (0.0212992s)]] +[[cpp_int(fixed)][[*1] (0.00810627s)][[*1] (0.00923316s)][[*1] (0.0110103s)][[*1] (0.020939s)]] +[[gmp_int][1.49189 (0.0120936s)][1.76716 (0.0163165s)][1.86002 (0.0204795s)][1.12695 (0.0235972s)]] +[[tommath_int][20.9474 (0.169805s)][18.7459 (0.173084s)][23.1437 (0.25482s)][8.70855 (0.182348s)]] +] +[table Operator / +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][1.12441 (0.227187s)][1.92471 (0.467116s)][2.5683 (0.755608s)][3.45487 (1.30086s)]] +[[cpp_int(fixed)][1.02377 (0.206852s)][1.32377 (0.321272s)][2.09615 (0.616699s)][2.89679 (1.09072s)]] +[[gmp_int][[*1] (0.20205s)][[*1] (0.242695s)][[*1] (0.294206s)][[*1] (0.376529s)]] +[[tommath_int][5.68214 (1.14807s)][5.52349 (1.34052s)][7.00529 (2.061s)][8.79242 (3.3106s)]] +] +[table Operator /(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][2.11845 (0.129609s)][4.15783 (0.303922s)][5.55849 (0.535727s)][6.76415 (1.00179s)]] +[[cpp_int(fixed)][1.81934 (0.111309s)][2.99804 (0.219146s)][4.68327 (0.451373s)][5.87635 (0.870306s)]] +[[gmp_int][[*1] (0.061181s)][[*1] (0.0730963s)][[*1] (0.09638s)][[*1] (0.148103s)]] +[[tommath_int][15.3006 (0.936106s)][16.0325 (1.17192s)][18.2771 (1.76155s)][20.2054 (2.99248s)]] +] +[table Operator << +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][1.66271 (0.0182175s)][1.44338 (0.0210768s)][1.50386 (0.0269161s)][1.91115 (0.0394128s)]] +[[cpp_int(fixed)][1.19703 (0.0131154s)][1.16109 (0.0169546s)][1.05186 (0.0188263s)][1.90315 (0.0392477s)]] +[[gmp_int][[*1] (0.0109566s)][[*1] (0.0146023s)][[*1] (0.0178981s)][[*1] (0.0206225s)]] +[[tommath_int][2.88726 (0.0316344s)][2.5987 (0.0379471s)][2.51285 (0.0449753s)][3.25597 (0.0671463s)]] +] +[table Operator >> +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][2.36287 (0.0215535s)][1.70778 (0.0175781s)][1.77078 (0.0216914s)][2.29189 (0.0294462s)]] +[[cpp_int(fixed)][[*1] (0.00912176s)][1.10889 (0.0114138s)][1.2417 (0.0152103s)][1.6714 (0.0214742s)]] +[[gmp_int][1.17612 (0.0107283s)][[*1] (0.010293s)][[*1] (0.0122496s)][[*1] (0.012848s)]] +[[tommath_int][15.2553 (0.139155s)][13.7608 (0.14164s)][12.2124 (0.149597s)][13.0247 (0.167341s)]] +] +[table Operator ^ +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][1.78798 (0.0243197s)][1.8085 (0.0280192s)][1.78828 (0.033929s)][1.79594 (0.0456494s)]] +[[cpp_int(fixed)][1.0129 (0.0137773s)][[*1] (0.015493s)][[*1] (0.018973s)][1.5504 (0.0394082s)]] +[[gmp_int][[*1] (0.0136018s)][1.03786 (0.0160796s)][1.40572 (0.0266707s)][[*1] (0.0254182s)]] +[[tommath_int][5.39689 (0.0734074s)][4.78827 (0.0741847s)][4.17964 (0.0793004s)][3.73059 (0.0948247s)]] +] +[table Operator ^(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][2.76928 (0.0404509s)][1.83515 (0.0299941s)][1.77409 (0.0323887s)][1.11493 (0.0372218s)]] +[[cpp_int(fixed)][[*1] (0.014607s)][[*1] (0.0163443s)][[*1] (0.0182565s)][[*1] (0.0333848s)]] +[[gmp_int][3.25823 (0.047593s)][3.05166 (0.0498771s)][2.96144 (0.0540655s)][1.47308 (0.0491785s)]] +[[tommath_int][17.006 (0.248407s)][15.2663 (0.249516s)][14.338 (0.261762s)][7.82864 (0.261357s)]] +] +[table Operator gcd +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][9.20736 (4.16823s)][3.91955 (8.51244s)][4.00539 (19.489s)][4.64192 (47.7651s)]] +[[cpp_int(fixed)][6.34685 (2.87326s)][3.07855 (6.68597s)][3.32507 (16.1788s)][4.07366 (41.9178s)]] +[[gmp_int][[*1] (0.452707s)][[*1] (2.17179s)][[*1] (4.86569s)][[*1] (10.2899s)]] +[[tommath_int][16.804 (7.6073s)][7.31428 (15.8851s)][6.96518 (33.8904s)][6.52732 (67.1657s)]] +] +[table Operator str +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][1.76995 (0.000703371s)][2.94246 (0.00181769s)][3.45149 (0.00434022s)][4.14052 (0.0122363s)]] +[[cpp_int(fixed)][1.58559 (0.000630107s)][2.42804 (0.00149991s)][3.30542 (0.00415653s)][3.90693 (0.011546s)]] +[[gmp_int][[*1] (0.000397397s)][[*1] (0.000617745s)][[*1] (0.00125749s)][[*1] (0.00295526s)]] +[[tommath_int][21.7585 (0.00864677s)][34.4291 (0.0212684s)][65.8175 (0.0827649s)][67.7946 (0.200351s)]] +] +[table Operator | +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][1.91883 (0.0242976s)][1.88265 (0.0281237s)][1.78879 (0.0339623s)][1.74117 (0.0457886s)]] +[[cpp_int(fixed)][1.08025 (0.0136789s)][1.03489 (0.0154596s)][[*1] (0.0189862s)][1.49756 (0.0393824s)]] +[[gmp_int][[*1] (0.0126627s)][[*1] (0.0149383s)][1.28585 (0.0244134s)][[*1] (0.0262977s)]] +[[tommath_int][5.86177 (0.0742258s)][4.9555 (0.0740269s)][4.18835 (0.0795209s)][3.55804 (0.0935681s)]] +] +[table Operator |(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][2.76183 (0.0454215s)][2.05967 (0.0323883s)][1.78143 (0.0324562s)][1.22147 (0.0372077s)]] +[[cpp_int(fixed)][[*1] (0.0164462s)][[*1] (0.015725s)][[*1] (0.0182191s)][[*1] (0.0304613s)]] +[[gmp_int][2.81912 (0.0463637s)][3.18611 (0.0501017s)][2.94469 (0.0536497s)][1.62702 (0.0495613s)]] +[[tommath_int][15.1485 (0.249135s)][15.9884 (0.251418s)][13.915 (0.253519s)][8.65293 (0.26358s)]] +] +[endsect] +[section:rational_performance Rational Type Perfomance] +[table Operator * +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][16.2879 (15.3196s)][10.7459 (45.9283s)][11.5596 (111.528s)][12.8553 (270.253s)]] +[[mpq_rational][[*1] (0.940549s)][[*1] (4.27402s)][[*1] (9.6481s)][[*1] (21.0227s)]] +] +[table Operator *(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][7.7465 (1.3425s)][10.6643 (2.05921s)][11.055 (2.75206s)][12.6365 (4.26866s)]] +[[mpq_rational][[*1] (0.173305s)][[*1] (0.193095s)][[*1] (0.248942s)][[*1] (0.337805s)]] +] +[table Operator + +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][16.0608 (8.33358s)][10.8037 (24.5753s)][11.4235 (58.1983s)][12.435 (139.884s)]] +[[mpq_rational][[*1] (0.518878s)][[*1] (2.2747s)][[*1] (5.09463s)][[*1] (11.2492s)]] +] +[table Operator +(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][7.82472 (1.14042s)][9.40883 (1.54697s)][9.02478 (1.83113s)][9.24894 (2.65768s)]] +[[mpq_rational][[*1] (0.145745s)][[*1] (0.164417s)][[*1] (0.202901s)][[*1] (0.287349s)]] +] +[table Operator - +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][16.0583 (8.3543s)][10.6997 (24.3831s)][11.4377 (58.3044s)][12.4116 (139.665s)]] +[[mpq_rational][[*1] (0.520249s)][[*1] (2.27886s)][[*1] (5.09757s)][[*1] (11.2528s)]] +] +[table Operator -(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][7.99602 (1.13947s)][9.62717 (1.55711s)][9.1151 (1.82889s)][9.53508 (2.68279s)]] +[[mpq_rational][[*1] (0.142505s)][[*1] (0.161741s)][[*1] (0.200644s)][[*1] (0.28136s)]] +] +[table Operator / +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][12.0736 (31.794s)][10.0089 (80.7871s)][10.9267 (184.73s)][12.204 (436.471s)]] +[[mpq_rational][[*1] (2.63335s)][[*1] (8.07149s)][[*1] (16.9064s)][[*1] (35.7647s)]] +] +[table Operator /(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][7.56092 (1.35276s)][10.5279 (2.12933s)][10.9509 (2.75885s)][12.166 (4.27228s)]] +[[mpq_rational][[*1] (0.178914s)][[*1] (0.202255s)][[*1] (0.251928s)][[*1] (0.351164s)]] +] +[table Operator str +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][13.4013 (0.00980984s)][23.4372 (0.0288878s)][27.4314 (0.067039s)][29.4814 (0.165057s)]] +[[mpq_rational][[*1] (0.000732008s)][[*1] (0.00123256s)][[*1] (0.00244388s)][[*1] (0.00559869s)]] +] +[endsect] diff --git a/src/boost/libs/multiprecision/performance/performance_test-intel-linux.log b/src/boost/libs/multiprecision/performance/performance_test-intel-linux.log new file mode 100644 index 00000000..e721729e --- /dev/null +++ b/src/boost/libs/multiprecision/performance/performance_test-intel-linux.log @@ -0,0 +1,422 @@ +gmp_int 64 + 0.016582 +gmp_int 64 - 0.0174517 +gmp_int 64 * 0.0112253 +gmp_int 64 / 0.170951 +gmp_int 64 str 0.000343689 +gmp_int 64 +(int)0.00688382 +gmp_int 64 -(int)0.00734613 +gmp_int 64 *(int)0.00881438 +gmp_int 64 /(int)0.0465651 +gmp_int 64 % 0.164576 +gmp_int 64 | 0.0101555 +gmp_int 64 & 0.00955666 +gmp_int 64 ^ 0.00987346 +gmp_int 64 << 0.0106043 +gmp_int 64 >> 0.0093887 +gmp_int 64 %(int)0.0297463 +gmp_int 64 |(int)0.0403338 +gmp_int 64 &(int)0.0417288 +gmp_int 64 ^(int)0.0405779 +gmp_int 64 gcd 0.173816 +gmp_int 128 + 0.0183088 +gmp_int 128 - 0.0189266 +gmp_int 128 * 0.0161084 +gmp_int 128 / 0.191775 +gmp_int 128 str 0.000374699 +gmp_int 128 +(int)0.00866339 +gmp_int 128 -(int)0.0089443 +gmp_int 128 *(int)0.0114143 +gmp_int 128 /(int)0.0534638 +gmp_int 128 % 0.161212 +gmp_int 128 | 0.0107201 +gmp_int 128 & 0.0113559 +gmp_int 128 ^ 0.0112116 +gmp_int 128 << 0.0103295 +gmp_int 128 >> 0.00813413 +gmp_int 128 %(int)0.03692 +gmp_int 128 |(int)0.0412168 +gmp_int 128 &(int)0.0428359 +gmp_int 128 ^(int)0.0418522 +gmp_int 128 gcd 0.43131 +gmp_int 256 + 0.0224834 +gmp_int 256 - 0.025062 +gmp_int 256 * 0.0417471 +gmp_int 256 / 0.233656 +gmp_int 256 str 0.00059903 +gmp_int 256 +(int)0.0112071 +gmp_int 256 -(int)0.0116302 +gmp_int 256 *(int)0.0137181 +gmp_int 256 /(int)0.0667669 +gmp_int 256 % 0.191884 +gmp_int 256 | 0.0129489 +gmp_int 256 & 0.012778 +gmp_int 256 ^ 0.0134548 +gmp_int 256 << 0.0121471 +gmp_int 256 >> 0.00832878 +gmp_int 256 %(int)0.0474363 +gmp_int 256 |(int)0.0425591 +gmp_int 256 &(int)0.0436742 +gmp_int 256 ^(int)0.0425636 +gmp_int 256 gcd 2.06855 +gmp_int 512 + 0.0277439 +gmp_int 512 - 0.0318874 +gmp_int 512 * 0.0991032 +gmp_int 512 / 0.274993 +gmp_int 512 str 0.00129458 +gmp_int 512 +(int)0.014283 +gmp_int 512 -(int)0.0149874 +gmp_int 512 *(int)0.0180512 +gmp_int 512 /(int)0.0906691 +gmp_int 512 % 0.222477 +gmp_int 512 | 0.0217103 +gmp_int 512 & 0.0165285 +gmp_int 512 ^ 0.0208848 +gmp_int 512 << 0.014839 +gmp_int 512 >> 0.00988994 +gmp_int 512 %(int)0.0605682 +gmp_int 512 |(int)0.0462909 +gmp_int 512 &(int)0.046599 +gmp_int 512 ^(int)0.0456608 +gmp_int 512 gcd 4.68499 +gmp_int 1024 + 0.0397479 +gmp_int 1024 - 0.042232 +gmp_int 1024 * 0.31703 +gmp_int 1024 / 0.345984 +gmp_int 1024 str 0.00271592 +gmp_int 1024 +(int)0.0189969 +gmp_int 1024 -(int)0.0195046 +gmp_int 1024 *(int)0.0260306 +gmp_int 1024 /(int)0.140151 +gmp_int 1024 % 0.286399 +gmp_int 1024 | 0.0261953 +gmp_int 1024 & 0.023083 +gmp_int 1024 ^ 0.0248084 +gmp_int 1024 << 0.0202635 +gmp_int 1024 >> 0.0127909 +gmp_int 1024 %(int)0.0761102 +gmp_int 1024 |(int)0.049175 +gmp_int 1024 &(int)0.0499195 +gmp_int 1024 ^(int)0.0487102 +gmp_int 1024 gcd 10.1127 +cpp_int 64 + 0.0152915 +cpp_int 64 - 0.0191821 +cpp_int 64 * 0.0326218 +cpp_int 64 / 0.0951094 +cpp_int 64 str 0.000428547 +cpp_int 64 +(int)0.0132027 +cpp_int 64 -(int)0.0126144 +cpp_int 64 *(int)0.0151037 +cpp_int 64 /(int)0.0491116 +cpp_int 64 % 0.0951581 +cpp_int 64 | 0.0199629 +cpp_int 64 & 0.0196969 +cpp_int 64 ^ 0.0208608 +cpp_int 64 << 0.0179372 +cpp_int 64 >> 0.0146206 +cpp_int 64 %(int)0.0229261 +cpp_int 64 |(int)0.0185797 +cpp_int 64 &(int)0.0225055 +cpp_int 64 ^(int)0.0191337 +cpp_int 64 gcd 1.50205 +cpp_int 128 + 0.0170788 +cpp_int 128 - 0.0228373 +cpp_int 128 * 0.0375831 +cpp_int 128 / 0.163958 +cpp_int 128 str 0.000744647 +cpp_int 128 +(int)0.0144833 +cpp_int 128 -(int)0.013922 +cpp_int 128 *(int)0.0176402 +cpp_int 128 /(int)0.0972057 +cpp_int 128 % 0.169015 +cpp_int 128 | 0.0229631 +cpp_int 128 & 0.023126 +cpp_int 128 ^ 0.0229278 +cpp_int 128 << 0.0215749 +cpp_int 128 >> 0.0149198 +cpp_int 128 %(int)0.0476063 +cpp_int 128 |(int)0.0194697 +cpp_int 128 &(int)0.0270183 +cpp_int 128 ^(int)0.0194481 +cpp_int 128 gcd 3.36986 +cpp_int 256 + 0.0231877 +cpp_int 256 - 0.0293424 +cpp_int 256 * 0.113247 +cpp_int 256 / 0.336287 +cpp_int 256 str 0.00190436 +cpp_int 256 +(int)0.0161733 +cpp_int 256 -(int)0.0173225 +cpp_int 256 *(int)0.0199426 +cpp_int 256 /(int)0.229286 +cpp_int 256 % 0.306542 +cpp_int 256 | 0.0257191 +cpp_int 256 & 0.0254172 +cpp_int 256 ^ 0.0259082 +cpp_int 256 << 0.0253994 +cpp_int 256 >> 0.0172635 +cpp_int 256 %(int)0.116093 +cpp_int 256 |(int)0.0233559 +cpp_int 256 &(int)0.0367792 +cpp_int 256 ^(int)0.0232914 +cpp_int 256 gcd 7.88882 +cpp_int 512 + 0.0291058 +cpp_int 512 - 0.0380025 +cpp_int 512 * 0.337161 +cpp_int 512 / 0.487075 +cpp_int 512 str 0.00494162 +cpp_int 512 +(int)0.0201989 +cpp_int 512 -(int)0.0200688 +cpp_int 512 *(int)0.0311497 +cpp_int 512 /(int)0.375279 +cpp_int 512 % 0.459737 +cpp_int 512 | 0.0297101 +cpp_int 512 & 0.0297235 +cpp_int 512 ^ 0.0296913 +cpp_int 512 << 0.0328422 +cpp_int 512 >> 0.0234706 +cpp_int 512 %(int)0.194709 +cpp_int 512 |(int)0.0258992 +cpp_int 512 &(int)0.0529542 +cpp_int 512 ^(int)0.0258749 +cpp_int 512 gcd 19.7141 +cpp_int 1024 + 0.0410101 +cpp_int 1024 - 0.0576733 +cpp_int 1024 * 1.19319 +cpp_int 1024 / 0.850798 +cpp_int 1024 str 0.0149378 +cpp_int 1024 +(int)0.0222435 +cpp_int 1024 -(int)0.0219408 +cpp_int 1024 *(int)0.0435058 +cpp_int 1024 /(int)0.6795 +cpp_int 1024 % 0.800961 +cpp_int 1024 | 0.0369613 +cpp_int 1024 & 0.0368423 +cpp_int 1024 ^ 0.0371252 +cpp_int 1024 << 0.0474759 +cpp_int 1024 >> 0.0297527 +cpp_int 1024 %(int)0.360619 +cpp_int 1024 |(int)0.0326194 +cpp_int 1024 &(int)0.0801744 +cpp_int 1024 ^(int)0.0319848 +cpp_int 1024 gcd 53.3224 +fixed_int 64 + 0.00207275 +fixed_int 64 - 0.00214524 +fixed_int 64 * 0.00391097 +fixed_int 64 / 0.0608466 +fixed_int 64 str 0.000292286 +fixed_int 64 +(int)0.00357336 +fixed_int 64 -(int)0.00352796 +fixed_int 64 *(int)0.00292725 +fixed_int 64 /(int)0.0243018 +fixed_int 64 % 0.0603067 +fixed_int 64 | 0.00258063 +fixed_int 64 & 0.00257379 +fixed_int 64 ^ 0.00258525 +fixed_int 64 << 0.00134947 +fixed_int 64 >> 0.00560378 +fixed_int 64 %(int)0.0241499 +fixed_int 64 |(int)0.00201939 +fixed_int 64 &(int)0.00206716 +fixed_int 64 ^(int)0.00201848 +fixed_int 64 gcd 0.82127 +fixed_int 128 + 0.00325349 +fixed_int 128 - 0.00366953 +fixed_int 128 * 0.010445 +fixed_int 128 / 0.113697 +fixed_int 128 str 0.000564877 +fixed_int 128 +(int)0.00377625 +fixed_int 128 -(int)0.00360179 +fixed_int 128 *(int)0.00418426 +fixed_int 128 /(int)0.091141 +fixed_int 128 % 0.113804 +fixed_int 128 | 0.00360961 +fixed_int 128 & 0.00359913 +fixed_int 128 ^ 0.00361317 +fixed_int 128 << 0.0065905 +fixed_int 128 >> 0.00654308 +fixed_int 128 %(int)0.0809135 +fixed_int 128 |(int)0.00237125 +fixed_int 128 &(int)0.00231056 +fixed_int 128 ^(int)0.00190464 +fixed_int 128 gcd 2.05126 +fixed_int 256 + 0.00785776 +fixed_int 256 - 0.00635884 +fixed_int 256 * 0.0323875 +fixed_int 256 / 0.203194 +fixed_int 256 str 0.0013816 +fixed_int 256 +(int)0.00413397 +fixed_int 256 -(int)0.00379699 +fixed_int 256 *(int)0.00852456 +fixed_int 256 /(int)0.183053 +fixed_int 256 % 0.200368 +fixed_int 256 | 0.0105747 +fixed_int 256 & 0.0105856 +fixed_int 256 ^ 0.0105755 +fixed_int 256 << 0.00874545 +fixed_int 256 >> 0.00906624 +fixed_int 256 %(int)0.152826 +fixed_int 256 |(int)0.00261619 +fixed_int 256 &(int)0.00424202 +fixed_int 256 ^(int)0.00263274 +fixed_int 256 gcd 5.42715 +fixed_int 512 + 0.0131311 +fixed_int 512 - 0.0122513 +fixed_int 512 * 0.205979 +fixed_int 512 / 0.383601 +fixed_int 512 str 0.0043558 +fixed_int 512 +(int)0.00639746 +fixed_int 512 -(int)0.00641876 +fixed_int 512 *(int)0.0152369 +fixed_int 512 /(int)0.363289 +fixed_int 512 % 0.38201 +fixed_int 512 | 0.0131075 +fixed_int 512 & 0.0131292 +fixed_int 512 ^ 0.01314 +fixed_int 512 << 0.0130248 +fixed_int 512 >> 0.0131451 +fixed_int 512 %(int)0.304714 +fixed_int 512 |(int)0.00574368 +fixed_int 512 &(int)0.00810836 +fixed_int 512 ^(int)0.00576694 +fixed_int 512 gcd 16.6269 +fixed_int 1024 + 0.0322386 +fixed_int 1024 - 0.0312142 +fixed_int 1024 * 0.716002 +fixed_int 1024 / 0.728338 +fixed_int 1024 str 0.0135445 +fixed_int 1024 +(int)0.011986 +fixed_int 1024 -(int)0.0119838 +fixed_int 1024 *(int)0.0349878 +fixed_int 1024 /(int)0.708856 +fixed_int 1024 % 0.723622 +fixed_int 1024 | 0.0181468 +fixed_int 1024 & 0.0182648 +fixed_int 1024 ^ 0.018185 +fixed_int 1024 << 0.0252997 +fixed_int 1024 >> 0.0257832 +fixed_int 1024 %(int)0.597535 +fixed_int 1024 |(int)0.0116417 +fixed_int 1024 &(int)0.0172111 +fixed_int 1024 ^(int)0.011526 +fixed_int 1024 gcd 70.6396 +[section:integer_performance Integer Type Perfomance] +[table Operator % +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][1.5779 (0.0951581s)][1.48514 (0.169015s)][1.59753 (0.306542s)][2.06645 (0.459737s)][2.79666 (0.800961s)]] +[[fixed_int][[*1] (0.0603067s)][[*1] (0.113804s)][1.04421 (0.200368s)][1.71708 (0.38201s)][2.52662 (0.723622s)]] +[[gmp_int][2.72898 (0.164576s)][1.41658 (0.161212s)][[*1] (0.191884s)][[*1] (0.222477s)][[*1] (0.286399s)]] +] +[table Operator %(int) +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][[*1] (0.0229261s)][1.28944 (0.0476063s)][2.44735 (0.116093s)][3.21471 (0.194709s)][4.73812 (0.360619s)]] +[[fixed_int][1.05338 (0.0241499s)][2.19159 (0.0809135s)][3.22171 (0.152826s)][5.03092 (0.304714s)][7.85093 (0.597535s)]] +[[gmp_int][1.29749 (0.0297463s)][[*1] (0.03692s)][[*1] (0.0474363s)][[*1] (0.0605682s)][[*1] (0.0761102s)]] +] +[table Operator & +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][7.65289 (0.0196969s)][6.42545 (0.023126s)][2.4011 (0.0254172s)][2.26393 (0.0297235s)][2.01712 (0.0368423s)]] +[[fixed_int][[*1] (0.00257379s)][[*1] (0.00359913s)][[*1] (0.0105856s)][[*1] (0.0131292s)][[*1] (0.0182648s)]] +[[gmp_int][3.71307 (0.00955666s)][3.15518 (0.0113559s)][1.2071 (0.012778s)][1.25891 (0.0165285s)][1.2638 (0.023083s)]] +] +[table Operator &(int) +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][10.8871 (0.0225055s)][11.6934 (0.0270183s)][8.67021 (0.0367792s)][6.53082 (0.0529542s)][4.65829 (0.0801744s)]] +[[fixed_int][[*1] (0.00206716s)][[*1] (0.00231056s)][[*1] (0.00424202s)][[*1] (0.00810836s)][[*1] (0.0172111s)]] +[[gmp_int][20.1865 (0.0417288s)][18.5392 (0.0428359s)][10.2956 (0.0436742s)][5.74703 (0.046599s)][2.90042 (0.0499195s)]] +] +[table Operator * +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][8.34111 (0.0326218s)][3.59818 (0.0375831s)][3.49662 (0.113247s)][3.40211 (0.337161s)][3.76364 (1.19319s)]] +[[fixed_int][[*1] (0.00391097s)][[*1] (0.010445s)][[*1] (0.0323875s)][2.07843 (0.205979s)][2.25847 (0.716002s)]] +[[gmp_int][2.87022 (0.0112253s)][1.54221 (0.0161084s)][1.28899 (0.0417471s)][[*1] (0.0991032s)][[*1] (0.31703s)]] +] +[table Operator *(int) +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][5.15967 (0.0151037s)][4.21584 (0.0176402s)][2.33943 (0.0199426s)][2.04436 (0.0311497s)][1.67133 (0.0435058s)]] +[[fixed_int][[*1] (0.00292725s)][[*1] (0.00418426s)][[*1] (0.00852456s)][[*1] (0.0152369s)][1.3441 (0.0349878s)]] +[[gmp_int][3.01114 (0.00881438s)][2.72791 (0.0114143s)][1.60924 (0.0137181s)][1.1847 (0.0180512s)][[*1] (0.0260306s)]] +] +[table Operator + +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][7.37741 (0.0152915s)][5.2494 (0.0170788s)][2.95092 (0.0231877s)][2.21655 (0.0291058s)][1.27208 (0.0410101s)]] +[[fixed_int][[*1] (0.00207275s)][[*1] (0.00325349s)][[*1] (0.00785776s)][[*1] (0.0131311s)][[*1] (0.0322386s)]] +[[gmp_int][7.99998 (0.016582s)][5.62745 (0.0183088s)][2.86129 (0.0224834s)][2.11283 (0.0277439s)][1.23293 (0.0397479s)]] +] +[table Operator +(int) +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][3.69474 (0.0132027s)][3.83536 (0.0144833s)][3.91229 (0.0161733s)][3.15733 (0.0201989s)][1.85579 (0.0222435s)]] +[[fixed_int][[*1] (0.00357336s)][[*1] (0.00377625s)][[*1] (0.00413397s)][[*1] (0.00639746s)][[*1] (0.011986s)]] +[[gmp_int][1.92643 (0.00688382s)][2.29418 (0.00866339s)][2.71097 (0.0112071s)][2.23261 (0.014283s)][1.58492 (0.0189969s)]] +] +[table Operator - +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][8.94166 (0.0191821s)][6.22351 (0.0228373s)][4.61443 (0.0293424s)][3.10192 (0.0380025s)][1.84766 (0.0576733s)]] +[[fixed_int][[*1] (0.00214524s)][[*1] (0.00366953s)][[*1] (0.00635884s)][[*1] (0.0122513s)][[*1] (0.0312142s)]] +[[gmp_int][8.13505 (0.0174517s)][5.15777 (0.0189266s)][3.94128 (0.025062s)][2.60278 (0.0318874s)][1.35297 (0.042232s)]] +] +[table Operator -(int) +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][3.57555 (0.0126144s)][3.86529 (0.013922s)][4.56215 (0.0173225s)][3.12658 (0.0200688s)][1.83087 (0.0219408s)]] +[[fixed_int][[*1] (0.00352796s)][[*1] (0.00360179s)][[*1] (0.00379699s)][[*1] (0.00641876s)][[*1] (0.0119838s)]] +[[gmp_int][2.08226 (0.00734613s)][2.4833 (0.0089443s)][3.063 (0.0116302s)][2.33493 (0.0149874s)][1.62759 (0.0195046s)]] +] +[table Operator / +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][1.5631 (0.0951094s)][1.44205 (0.163958s)][1.655 (0.336287s)][1.77123 (0.487075s)][2.45907 (0.850798s)]] +[[fixed_int][[*1] (0.0608466s)][[*1] (0.113697s)][[*1] (0.203194s)][1.39495 (0.383601s)][2.10512 (0.728338s)]] +[[gmp_int][2.80954 (0.170951s)][1.68671 (0.191775s)][1.14992 (0.233656s)][[*1] (0.274993s)][[*1] (0.345984s)]] +] +[table Operator /(int) +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][2.0209 (0.0491116s)][1.81816 (0.0972057s)][3.43412 (0.229286s)][4.13899 (0.375279s)][4.84836 (0.6795s)]] +[[fixed_int][[*1] (0.0243018s)][1.70472 (0.091141s)][2.74167 (0.183053s)][4.00675 (0.363289s)][5.05782 (0.708856s)]] +[[gmp_int][1.91611 (0.0465651s)][[*1] (0.0534638s)][[*1] (0.0667669s)][[*1] (0.0906691s)][[*1] (0.140151s)]] +] +[table Operator << +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][13.292 (0.0179372s)][3.27363 (0.0215749s)][2.9043 (0.0253994s)][2.52151 (0.0328422s)][2.34293 (0.0474759s)]] +[[fixed_int][[*1] (0.00134947s)][[*1] (0.0065905s)][[*1] (0.00874545s)][[*1] (0.0130248s)][1.24854 (0.0252997s)]] +[[gmp_int][7.85814 (0.0106043s)][1.56732 (0.0103295s)][1.38897 (0.0121471s)][1.13928 (0.014839s)][[*1] (0.0202635s)]] +] +[table Operator >> +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][2.60907 (0.0146206s)][2.28025 (0.0149198s)][2.07275 (0.0172635s)][2.37318 (0.0234706s)][2.32609 (0.0297527s)]] +[[fixed_int][[*1] (0.00560378s)][[*1] (0.00654308s)][1.08854 (0.00906624s)][1.32914 (0.0131451s)][2.01575 (0.0257832s)]] +[[gmp_int][1.67542 (0.0093887s)][1.24317 (0.00813413s)][[*1] (0.00832878s)][[*1] (0.00988994s)][[*1] (0.0127909s)]] +] +[table Operator ^ +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][8.06918 (0.0208608s)][6.34562 (0.0229278s)][2.44983 (0.0259082s)][2.25961 (0.0296913s)][2.04153 (0.0371252s)]] +[[fixed_int][[*1] (0.00258525s)][[*1] (0.00361317s)][[*1] (0.0105755s)][[*1] (0.01314s)][[*1] (0.018185s)]] +[[gmp_int][3.81916 (0.00987346s)][3.10299 (0.0112116s)][1.27226 (0.0134548s)][1.5894 (0.0208848s)][1.36422 (0.0248084s)]] +] +[table Operator ^(int) +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][9.47925 (0.0191337s)][10.2109 (0.0194481s)][8.84686 (0.0232914s)][4.48677 (0.0258749s)][2.775 (0.0319848s)]] +[[fixed_int][[*1] (0.00201848s)][[*1] (0.00190464s)][[*1] (0.00263274s)][[*1] (0.00576694s)][[*1] (0.011526s)]] +[[gmp_int][20.1032 (0.0405779s)][21.9738 (0.0418522s)][16.1671 (0.0425636s)][7.91768 (0.0456608s)][4.2261 (0.0487102s)]] +] +[table Operator gcd +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][8.64165 (1.50205s)][7.81307 (3.36986s)][3.81369 (7.88882s)][4.20792 (19.7141s)][5.27284 (53.3224s)]] +[[fixed_int][4.72495 (0.82127s)][4.75589 (2.05126s)][2.62364 (5.42715s)][3.54898 (16.6269s)][6.98527 (70.6396s)]] +[[gmp_int][[*1] (0.173816s)][[*1] (0.43131s)][[*1] (2.06855s)][[*1] (4.68499s)][[*1] (10.1127s)]] +] +[table Operator str +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][1.46619 (0.000428547s)][1.98732 (0.000744647s)][3.17907 (0.00190436s)][3.81717 (0.00494162s)][5.50009 (0.0149378s)]] +[[fixed_int][[*1] (0.000292286s)][1.50755 (0.000564877s)][2.30639 (0.0013816s)][3.36465 (0.0043558s)][4.98706 (0.0135445s)]] +[[gmp_int][1.17587 (0.000343689s)][[*1] (0.000374699s)][[*1] (0.00059903s)][[*1] (0.00129458s)][[*1] (0.00271592s)]] +] +[table Operator | +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][7.73565 (0.0199629s)][6.36166 (0.0229631s)][2.43214 (0.0257191s)][2.26665 (0.0297101s)][2.0368 (0.0369613s)]] +[[fixed_int][[*1] (0.00258063s)][[*1] (0.00360961s)][[*1] (0.0105747s)][[*1] (0.0131075s)][[*1] (0.0181468s)]] +[[gmp_int][3.9353 (0.0101555s)][2.96987 (0.0107201s)][1.22452 (0.0129489s)][1.65632 (0.0217103s)][1.44352 (0.0261953s)]] +] +[table Operator |(int) +[[Backend][64 Bits][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][9.20066 (0.0185797s)][8.21071 (0.0194697s)][8.92746 (0.0233559s)][4.50916 (0.0258992s)][2.80194 (0.0326194s)]] +[[fixed_int][[*1] (0.00201939s)][[*1] (0.00237125s)][[*1] (0.00261619s)][[*1] (0.00574368s)][[*1] (0.0116417s)]] +[[gmp_int][19.9733 (0.0403338s)][17.3819 (0.0412168s)][16.2676 (0.0425591s)][8.05945 (0.0462909s)][4.22404 (0.049175s)]] +] +[endsect] diff --git a/src/boost/libs/multiprecision/performance/performance_test-msvc-10.log b/src/boost/libs/multiprecision/performance/performance_test-msvc-10.log new file mode 100644 index 00000000..3e271ff9 --- /dev/null +++ b/src/boost/libs/multiprecision/performance/performance_test-msvc-10.log @@ -0,0 +1,1220 @@ +gmp_float 50 + 0.110988 +gmp_float 50 - 0.119898 +gmp_float 50 * 0.275044 +gmp_float 50 / 1.27708 +gmp_float 50 str 0.013276 +gmp_float 50 +(int)0.0330888 +gmp_float 50 -(int)0.134451 +gmp_float 50 *(int)0.0422135 +gmp_float 50 /(int)0.180393 +gmp_float 50 construct0.19737 +gmp_float 50 construct(unsigned)0.208078 +gmp_float 50 construct(unsigned long long)0.520025 +gmp_float 50 + 0.498089 +gmp_float 50 - 0.502235 +gmp_float 50 * 0.564768 +gmp_float 50 / 0.90324 +gmp_float 50 + 0.477999 +gmp_float 50 - 0.499682 +gmp_float 50 * 0.551747 +gmp_float 50 / 0.893752 +gmp_float 100 + 0.111217 +gmp_float 100 - 0.120498 +gmp_float 100 * 0.416175 +gmp_float 100 / 1.69515 +gmp_float 100 str 0.0202949 +gmp_float 100 +(int)0.0386882 +gmp_float 100 -(int)0.1351 +gmp_float 100 *(int)0.0493716 +gmp_float 100 /(int)0.23378 +gmp_float 100 construct0.196599 +gmp_float 100 construct(unsigned)0.207062 +gmp_float 100 construct(unsigned long long)0.51936 +gmp_float 100 + 0.517172 +gmp_float 100 - 0.509588 +gmp_float 100 * 0.575954 +gmp_float 100 / 1.04262 +gmp_float 100 + 0.476701 +gmp_float 100 - 0.503546 +gmp_float 100 * 0.564962 +gmp_float 100 / 1.03328 +gmp_float 500 + 0.15445 +gmp_float 500 - 0.164099 +gmp_float 500 * 3.32799 +gmp_float 500 / 8.12655 +gmp_float 500 str 0.141162 +gmp_float 500 +(int)0.0646201 +gmp_float 500 -(int)0.176876 +gmp_float 500 *(int)0.0857876 +gmp_float 500 /(int)0.710204 +gmp_float 500 construct0.206063 +gmp_float 500 construct(unsigned)0.217019 +gmp_float 500 construct(unsigned long long)0.538021 +gmp_float 500 + 0.552532 +gmp_float 500 - 0.555754 +gmp_float 500 * 0.717186 +gmp_float 500 / 2.24686 +gmp_float 500 + 0.490614 +gmp_float 500 - 0.547751 +gmp_float 500 * 0.700957 +gmp_float 500 / 2.24146 +gmp_int 128 + 0.0421662 +gmp_int 128 - 0.0411848 +gmp_int 128 * 0.0708996 +gmp_int 128 / 0.868916 +gmp_int 128 str 0.00185638 +gmp_int 128 +(int)0.0311237 +gmp_int 128 -(int)0.030585 +gmp_int 128 *(int)0.022756 +gmp_int 128 /(int)0.0560401 +gmp_int 128 construct0.196182 +gmp_int 128 construct(unsigned)0.206113 +gmp_int 128 construct(unsigned long long)0.719741 +gmp_int 128 % 0.64148 +gmp_int 128 | 0.0474678 +gmp_int 128 & 0.0538128 +gmp_int 128 ^ 0.0497194 +gmp_int 128 << 0.0273994 +gmp_int 128 >> 0.0288237 +gmp_int 128 %(int)0.0572117 +gmp_int 128 |(int)0.141119 +gmp_int 128 &(int)0.141306 +gmp_int 128 ^(int)0.143934 +gmp_int 128 gcd 2.45095 +gmp_int 128 + 0.71217 +gmp_int 128 - 0.687129 +gmp_int 128 * 0.716479 +gmp_int 128 / 1.04926 +gmp_int 128 + 0.68136 +gmp_int 128 - 0.681187 +gmp_int 128 * 3.1627 +gmp_int 128 / 0.685487 +gmp_int 256 + 0.0449584 +gmp_int 256 - 0.0461316 +gmp_int 256 * 0.134302 +gmp_int 256 / 0.951505 +gmp_int 256 str 0.00344576 +gmp_int 256 +(int)0.0428011 +gmp_int 256 -(int)0.0400434 +gmp_int 256 *(int)0.0282672 +gmp_int 256 /(int)0.0982823 +gmp_int 256 construct0.201199 +gmp_int 256 construct(unsigned)0.211295 +gmp_int 256 construct(unsigned long long)0.729487 +gmp_int 256 % 0.703592 +gmp_int 256 | 0.0618281 +gmp_int 256 & 0.0652169 +gmp_int 256 ^ 0.0630174 +gmp_int 256 << 0.031973 +gmp_int 256 >> 0.0310184 +gmp_int 256 %(int)0.10258 +gmp_int 256 |(int)0.142987 +gmp_int 256 &(int)0.139398 +gmp_int 256 ^(int)0.144825 +gmp_int 256 gcd 5.89505 +gmp_int 256 + 0.728978 +gmp_int 256 - 0.707806 +gmp_int 256 * 0.731454 +gmp_int 256 / 1.17203 +gmp_int 256 + 0.68929 +gmp_int 256 - 0.683532 +gmp_int 256 * 3.15114 +gmp_int 256 / 0.689516 +gmp_int 512 + 0.0522202 +gmp_int 512 - 0.0567637 +gmp_int 512 * 0.532277 +gmp_int 512 / 1.06442 +gmp_int 512 str 0.00618403 +gmp_int 512 +(int)0.0665539 +gmp_int 512 -(int)0.0578194 +gmp_int 512 *(int)0.0361075 +gmp_int 512 /(int)0.183564 +gmp_int 512 construct0.19783 +gmp_int 512 construct(unsigned)0.206944 +gmp_int 512 construct(unsigned long long)0.724649 +gmp_int 512 % 0.819828 +gmp_int 512 | 0.0856626 +gmp_int 512 & 0.092104 +gmp_int 512 ^ 0.0869819 +gmp_int 512 << 0.0471709 +gmp_int 512 >> 0.0337511 +gmp_int 512 %(int)0.188529 +gmp_int 512 |(int)0.155656 +gmp_int 512 &(int)0.142498 +gmp_int 512 ^(int)0.152773 +gmp_int 512 gcd 13.6993 +gmp_int 512 + 0.759532 +gmp_int 512 - 0.732529 +gmp_int 512 * 0.779921 +gmp_int 512 / 1.39149 +gmp_int 512 + 0.694235 +gmp_int 512 - 0.69246 +gmp_int 512 * 3.17094 +gmp_int 512 / 0.688995 +gmp_int 1024 + 0.0699873 +gmp_int 1024 - 0.0731244 +gmp_int 1024 * 1.57852 +gmp_int 1024 / 1.30215 +gmp_int 1024 str 0.0144523 +gmp_int 1024 +(int)0.108272 +gmp_int 1024 -(int)0.100541 +gmp_int 1024 *(int)0.0518882 +gmp_int 1024 /(int)0.352238 +gmp_int 1024 construct0.19744 +gmp_int 1024 construct(unsigned)0.216229 +gmp_int 1024 construct(unsigned long long)0.722262 +gmp_int 1024 % 1.01959 +gmp_int 1024 | 0.136082 +gmp_int 1024 & 0.144412 +gmp_int 1024 ^ 0.139109 +gmp_int 1024 << 0.0721984 +gmp_int 1024 >> 0.0388038 +gmp_int 1024 %(int)0.355222 +gmp_int 1024 |(int)0.163236 +gmp_int 1024 &(int)0.141249 +gmp_int 1024 ^(int)0.161662 +gmp_int 1024 gcd 33.2232 +gmp_int 1024 + 0.83035 +gmp_int 1024 - 0.78115 +gmp_int 1024 * 0.815503 +gmp_int 1024 / 1.84054 +gmp_int 1024 + 0.690013 +gmp_int 1024 - 0.690838 +gmp_int 1024 * 3.20893 +gmp_int 1024 / 0.707578 +cpp_int(unsigned, fixed)64 + 0.00232166 +cpp_int(unsigned, fixed)64 - 0.00234506 +cpp_int(unsigned, fixed)64 * 0.00470304 +cpp_int(unsigned, fixed)64 / 0.0714786 +cpp_int(unsigned, fixed)64 str 0.00256457 +cpp_int(unsigned, fixed)64 +(int)0.00162053 +cpp_int(unsigned, fixed)64 -(int)0.00163617 +cpp_int(unsigned, fixed)64 *(int)0.00236511 +cpp_int(unsigned, fixed)64 /(int)0.0299559 +cpp_int(unsigned, fixed)64 construct0.00111299 +cpp_int(unsigned, fixed)64 construct(unsigned)0.00110489 +cpp_int(unsigned, fixed)64 construct(unsigned long long)0.00240876 +cpp_int(unsigned, fixed)64 % 0.0702826 +cpp_int(unsigned, fixed)64 | 0.00265921 +cpp_int(unsigned, fixed)64 & 0.00261653 +cpp_int(unsigned, fixed)64 ^ 0.0040003 +cpp_int(unsigned, fixed)64 << 0.00161592 +cpp_int(unsigned, fixed)64 >> 0.00161599 +cpp_int(unsigned, fixed)64 %(int)0.0298064 +cpp_int(unsigned, fixed)64 |(int)0.00165538 +cpp_int(unsigned, fixed)64 &(int)0.00161431 +cpp_int(unsigned, fixed)64 ^(int)0.00184507 +cpp_int(unsigned, fixed)64 gcd 0.602722 +cpp_int(unsigned, fixed)64 + 0.00253726 +cpp_int(unsigned, fixed)64 - 0.00301519 +cpp_int(unsigned, fixed)64 * 0.00474872 +cpp_int(unsigned, fixed)64 / 0.0450108 +cpp_int(unsigned, fixed)64 + 0.0020173 +cpp_int(unsigned, fixed)64 - 0.00191079 +cpp_int(unsigned, fixed)64 * 0.00445077 +cpp_int(unsigned, fixed)64 / 0.0294528 +cpp_int(fixed) 64 + 0.00573474 +cpp_int(fixed) 64 - 0.0096272 +cpp_int(fixed) 64 * 0.00897607 +cpp_int(fixed) 64 / 0.0783882 +cpp_int(fixed) 64 str 0.00251659 +cpp_int(fixed) 64 +(int)0.00636247 +cpp_int(fixed) 64 -(int)0.00668367 +cpp_int(fixed) 64 *(int)0.00548722 +cpp_int(fixed) 64 /(int)0.0362985 +cpp_int(fixed) 64 construct0.00161745 +cpp_int(fixed) 64 construct(unsigned)0.00209147 +cpp_int(fixed) 64 construct(unsigned long long)0.00204998 +cpp_int(fixed) 64 % 0.0777437 +cpp_int(fixed) 64 | 0.0108982 +cpp_int(fixed) 64 & 0.0124165 +cpp_int(fixed) 64 ^ 0.0110313 +cpp_int(fixed) 64 << 0.00516511 +cpp_int(fixed) 64 >> 0.00399499 +cpp_int(fixed) 64 %(int)0.0341425 +cpp_int(fixed) 64 |(int)0.0111002 +cpp_int(fixed) 64 &(int)0.0104782 +cpp_int(fixed) 64 ^(int)0.0107199 +cpp_int(fixed) 64 gcd 0.604291 +cpp_int(fixed) 64 + 0.00605482 +cpp_int(fixed) 64 - 0.00714372 +cpp_int(fixed) 64 * 0.00873093 +cpp_int(fixed) 64 / 0.0510195 +cpp_int(fixed) 64 + 0.00430062 +cpp_int(fixed) 64 - 0.00387577 +cpp_int(fixed) 64 * 0.00567824 +cpp_int(fixed) 64 / 0.0320162 +cpp_int(fixed) 128 + 0.0358493 +cpp_int(fixed) 128 - 0.0397574 +cpp_int(fixed) 128 * 0.0672363 +cpp_int(fixed) 128 / 0.222933 +cpp_int(fixed) 128 str 0.0015613 +cpp_int(fixed) 128 +(int)0.0268311 +cpp_int(fixed) 128 -(int)0.0241848 +cpp_int(fixed) 128 *(int)0.0328109 +cpp_int(fixed) 128 /(int)0.137619 +cpp_int(fixed) 128 construct0.00164665 +cpp_int(fixed) 128 construct(unsigned)0.0015986 +cpp_int(fixed) 128 construct(unsigned long long)0.00312994 +cpp_int(fixed) 128 % 0.1971 +cpp_int(fixed) 128 | 0.0380136 +cpp_int(fixed) 128 & 0.0341411 +cpp_int(fixed) 128 ^ 0.0351059 +cpp_int(fixed) 128 << 0.0320915 +cpp_int(fixed) 128 >> 0.0293055 +cpp_int(fixed) 128 %(int)0.103684 +cpp_int(fixed) 128 |(int)0.0317854 +cpp_int(fixed) 128 &(int)0.0417383 +cpp_int(fixed) 128 ^(int)0.0312355 +cpp_int(fixed) 128 gcd 4.18006 +cpp_int(fixed) 128 + 0.0341301 +cpp_int(fixed) 128 - 0.0346952 +cpp_int(fixed) 128 * 0.0675308 +cpp_int(fixed) 128 / 0.466907 +cpp_int(fixed) 128 + 0.0168342 +cpp_int(fixed) 128 - 0.0169449 +cpp_int(fixed) 128 * 0.0673436 +cpp_int(fixed) 128 / 0.0327432 +cpp_int(fixed) 256 + 0.0552275 +cpp_int(fixed) 256 - 0.0560103 +cpp_int(fixed) 256 * 0.166666 +cpp_int(fixed) 256 / 0.349956 +cpp_int(fixed) 256 str 0.00297279 +cpp_int(fixed) 256 +(int)0.0410749 +cpp_int(fixed) 256 -(int)0.0368306 +cpp_int(fixed) 256 *(int)0.049867 +cpp_int(fixed) 256 /(int)0.253796 +cpp_int(fixed) 256 construct0.00363363 +cpp_int(fixed) 256 construct(unsigned)0.00370466 +cpp_int(fixed) 256 construct(unsigned long long)0.00388115 +cpp_int(fixed) 256 % 0.334027 +cpp_int(fixed) 256 | 0.0529581 +cpp_int(fixed) 256 & 0.0501131 +cpp_int(fixed) 256 ^ 0.0530521 +cpp_int(fixed) 256 << 0.0507053 +cpp_int(fixed) 256 >> 0.039006 +cpp_int(fixed) 256 %(int)0.200647 +cpp_int(fixed) 256 |(int)0.0466958 +cpp_int(fixed) 256 &(int)0.0539427 +cpp_int(fixed) 256 ^(int)0.0476923 +cpp_int(fixed) 256 gcd 10.2671 +cpp_int(fixed) 256 + 0.0452762 +cpp_int(fixed) 256 - 0.0444216 +cpp_int(fixed) 256 * 0.112885 +cpp_int(fixed) 256 / 1.36886 +cpp_int(fixed) 256 + 0.0170491 +cpp_int(fixed) 256 - 0.0176783 +cpp_int(fixed) 256 * 0.107306 +cpp_int(fixed) 256 / 0.0340708 +cpp_int(fixed) 512 + 0.0760722 +cpp_int(fixed) 512 - 0.0756027 +cpp_int(fixed) 512 * 0.500399 +cpp_int(fixed) 512 / 0.560837 +cpp_int(fixed) 512 str 0.00708386 +cpp_int(fixed) 512 +(int)0.0524416 +cpp_int(fixed) 512 -(int)0.0503396 +cpp_int(fixed) 512 *(int)0.0658566 +cpp_int(fixed) 512 /(int)0.446782 +cpp_int(fixed) 512 construct0.00576526 +cpp_int(fixed) 512 construct(unsigned)0.0058189 +cpp_int(fixed) 512 construct(unsigned long long)0.00556537 +cpp_int(fixed) 512 % 0.539708 +cpp_int(fixed) 512 | 0.0676884 +cpp_int(fixed) 512 & 0.0588367 +cpp_int(fixed) 512 ^ 0.0695132 +cpp_int(fixed) 512 << 0.0597514 +cpp_int(fixed) 512 >> 0.0515714 +cpp_int(fixed) 512 %(int)0.377704 +cpp_int(fixed) 512 |(int)0.0536974 +cpp_int(fixed) 512 &(int)0.070425 +cpp_int(fixed) 512 ^(int)0.0540962 +cpp_int(fixed) 512 gcd 26.2762 +cpp_int(fixed) 512 + 0.0571069 +cpp_int(fixed) 512 - 0.0563175 +cpp_int(fixed) 512 * 0.177444 +cpp_int(fixed) 512 / 3.1662 +cpp_int(fixed) 512 + 0.0172628 +cpp_int(fixed) 512 - 0.0180756 +cpp_int(fixed) 512 * 0.171821 +cpp_int(fixed) 512 / 0.0444905 +cpp_int(fixed) 1024 + 0.121124 +cpp_int(fixed) 1024 - 0.114246 +cpp_int(fixed) 1024 * 1.54633 +cpp_int(fixed) 1024 / 0.975643 +cpp_int(fixed) 1024 str 0.0172514 +cpp_int(fixed) 1024 +(int)0.0728817 +cpp_int(fixed) 1024 -(int)0.0621059 +cpp_int(fixed) 1024 *(int)0.0948565 +cpp_int(fixed) 1024 /(int)0.84764 +cpp_int(fixed) 1024 construct0.00535599 +cpp_int(fixed) 1024 construct(unsigned)0.00836042 +cpp_int(fixed) 1024 construct(unsigned long long)0.00577713 +cpp_int(fixed) 1024 % 0.94847 +cpp_int(fixed) 1024 | 0.100936 +cpp_int(fixed) 1024 & 0.0774574 +cpp_int(fixed) 1024 ^ 0.09783 +cpp_int(fixed) 1024 << 0.0677088 +cpp_int(fixed) 1024 >> 0.0626121 +cpp_int(fixed) 1024 %(int)0.743202 +cpp_int(fixed) 1024 |(int)0.0819107 +cpp_int(fixed) 1024 &(int)0.112823 +cpp_int(fixed) 1024 ^(int)0.0806317 +cpp_int(fixed) 1024 gcd 76.2849 +cpp_int(fixed) 1024 + 0.0636724 +cpp_int(fixed) 1024 - 0.06467 +cpp_int(fixed) 1024 * 0.303514 +cpp_int(fixed) 1024 / 8.04418 +cpp_int(fixed) 1024 + 0.0181245 +cpp_int(fixed) 1024 - 0.0190581 +cpp_int(fixed) 1024 * 0.299236 +cpp_int(fixed) 1024 / 0.106788 +cpp_int 128 + 0.0273725 +cpp_int 128 - 0.0303219 +cpp_int 128 * 0.0774619 +cpp_int 128 / 0.589941 +cpp_int 128 str 0.00189808 +cpp_int 128 +(int)0.0159069 +cpp_int 128 -(int)0.0151244 +cpp_int 128 *(int)0.0235876 +cpp_int 128 /(int)0.235955 +cpp_int 128 construct0.00293927 +cpp_int 128 construct(unsigned)0.00270684 +cpp_int 128 construct(unsigned long long)0.00719854 +cpp_int 128 % 0.37333 +cpp_int 128 | 0.030991 +cpp_int 128 & 0.031605 +cpp_int 128 ^ 0.0318172 +cpp_int 128 << 0.0256107 +cpp_int 128 >> 0.0237523 +cpp_int 128 %(int)0.104856 +cpp_int 128 |(int)0.0280516 +cpp_int 128 &(int)0.0377678 +cpp_int 128 ^(int)0.0283305 +cpp_int 128 gcd 4.98644 +cpp_int 128 + 0.0283071 +cpp_int 128 - 0.027289 +cpp_int 128 * 0.0584001 +cpp_int 128 / 0.733741 +cpp_int 128 + 0.0196594 +cpp_int 128 - 0.0210968 +cpp_int 128 * 7.6372 +cpp_int 128 / 0.0578293 +cpp_int 256 + 0.0384835 +cpp_int 256 - 0.0402028 +cpp_int 256 * 0.211395 +cpp_int 256 / 0.708882 +cpp_int 256 str 0.00391656 +cpp_int 256 +(int)0.0218386 +cpp_int 256 -(int)0.017199 +cpp_int 256 *(int)0.0318939 +cpp_int 256 /(int)0.35212 +cpp_int 256 construct0.00277479 +cpp_int 256 construct(unsigned)0.0030529 +cpp_int 256 construct(unsigned long long)0.00725455 +cpp_int 256 % 0.673748 +cpp_int 256 | 0.0429658 +cpp_int 256 & 0.0455929 +cpp_int 256 ^ 0.0425243 +cpp_int 256 << 0.0401135 +cpp_int 256 >> 0.0302534 +cpp_int 256 %(int)0.203012 +cpp_int 256 |(int)0.0363929 +cpp_int 256 &(int)0.0471524 +cpp_int 256 ^(int)0.0353555 +cpp_int 256 gcd 11.1816 +cpp_int 256 + 0.030223 +cpp_int 256 - 0.0319489 +cpp_int 256 * 0.0885733 +cpp_int 256 / 1.62706 +cpp_int 256 + 0.0215291 +cpp_int 256 - 0.0213343 +cpp_int 256 * 7.7121 +cpp_int 256 / 0.0615507 +cpp_int 512 + 0.0561351 +cpp_int 512 - 0.0543342 +cpp_int 512 * 0.703234 +cpp_int 512 / 0.924042 +cpp_int 512 str 0.00832019 +cpp_int 512 +(int)0.0316584 +cpp_int 512 -(int)0.0248084 +cpp_int 512 *(int)0.0427792 +cpp_int 512 /(int)0.568032 +cpp_int 512 construct0.0028102 +cpp_int 512 construct(unsigned)0.00288857 +cpp_int 512 construct(unsigned long long)0.00723891 +cpp_int 512 % 0.701584 +cpp_int 512 | 0.0537846 +cpp_int 512 & 0.0546439 +cpp_int 512 ^ 0.0542436 +cpp_int 512 << 0.0436188 +cpp_int 512 >> 0.0355247 +cpp_int 512 %(int)0.391566 +cpp_int 512 |(int)0.0418143 +cpp_int 512 &(int)0.0647085 +cpp_int 512 ^(int)0.041758 +cpp_int 512 gcd 27.2257 +cpp_int 512 + 0.0382495 +cpp_int 512 - 0.0386744 +cpp_int 512 * 0.14417 +cpp_int 512 / 3.61202 +cpp_int 512 + 0.0228565 +cpp_int 512 - 0.0222868 +cpp_int 512 * 7.72815 +cpp_int 512 / 0.0732298 +cpp_int 1024 + 0.0928746 +cpp_int 1024 - 0.0853837 +cpp_int 1024 * 2.6591 +cpp_int 1024 / 1.38142 +cpp_int 1024 str 0.0221599 +cpp_int 1024 +(int)0.0430289 +cpp_int 1024 -(int)0.0331224 +cpp_int 1024 *(int)0.0668616 +cpp_int 1024 /(int)0.989885 +cpp_int 1024 construct0.00277298 +cpp_int 1024 construct(unsigned)0.00265201 +cpp_int 1024 construct(unsigned long long)0.00732796 +cpp_int 1024 % 1.14369 +cpp_int 1024 | 0.0827684 +cpp_int 1024 & 0.0843863 +cpp_int 1024 ^ 0.08333 +cpp_int 1024 << 0.0628544 +cpp_int 1024 >> 0.044717 +cpp_int 1024 %(int)0.768511 +cpp_int 1024 |(int)0.0527075 +cpp_int 1024 &(int)0.10089 +cpp_int 1024 ^(int)0.0538323 +cpp_int 1024 gcd 73.3735 +cpp_int 1024 + 0.0463315 +cpp_int 1024 - 0.0468398 +cpp_int 1024 * 0.255279 +cpp_int 1024 / 8.42528 +cpp_int 1024 + 0.0227402 +cpp_int 1024 - 0.0234526 +cpp_int 1024 * 7.86395 +cpp_int 1024 / 0.123568 +cpp_rational 128 + 18.0021 +cpp_rational 128 - 18.0006 +cpp_rational 128 * 31.5924 +cpp_rational 128 / 65.714 +cpp_rational 128 str 0.020339 +cpp_rational 128 +(int)2.47739 +cpp_rational 128 -(int)2.47959 +cpp_rational 128 *(int)2.4377 +cpp_rational 128 /(int)2.50843 +cpp_rational 128 construct0.0102665 +cpp_rational 128 construct(unsigned)0.0624887 +cpp_rational 128 construct(unsigned long long)0.0658436 +cpp_rational 128 + 2.58812 +cpp_rational 128 - 2.60864 +cpp_rational 128 * 5.53837 +cpp_rational 128 / 5.63033 +cpp_rational 128 + 2.68363 +cpp_rational 128 - 2.72926 +cpp_rational 128 * 57.9393 +cpp_rational 128 / 58.0332 +cpp_rational 256 + 46.3981 +cpp_rational 256 - 46.4818 +cpp_rational 256 * 86.0189 +cpp_rational 256 / 172.8 +cpp_rational 256 str 0.0517328 +cpp_rational 256 +(int)2.92179 +cpp_rational 256 -(int)2.90579 +cpp_rational 256 *(int)2.91325 +cpp_rational 256 /(int)3.00689 +cpp_rational 256 construct0.0101737 +cpp_rational 256 construct(unsigned)0.0609531 +cpp_rational 256 construct(unsigned long long)0.0665504 +cpp_rational 256 + 3.0953 +cpp_rational 256 - 3.08277 +cpp_rational 256 * 6.78796 +cpp_rational 256 / 6.90941 +cpp_rational 256 + 3.15142 +cpp_rational 256 - 3.19882 +cpp_rational 256 * 59.3172 +cpp_rational 256 / 59.5431 +cpp_rational 512 + 108.57 +cpp_rational 512 - 108.81 +cpp_rational 512 * 202.007 +cpp_rational 512 / 348.46 +cpp_rational 512 str 0.119248 +cpp_rational 512 +(int)3.80252 +cpp_rational 512 -(int)3.80714 +cpp_rational 512 *(int)3.94768 +cpp_rational 512 /(int)4.00588 +cpp_rational 512 construct0.0101965 +cpp_rational 512 construct(unsigned)0.0613968 +cpp_rational 512 construct(unsigned long long)0.0659082 +cpp_rational 512 + 4.00751 +cpp_rational 512 - 4.0117 +cpp_rational 512 * 9.43852 +cpp_rational 512 / 9.39508 +cpp_rational 512 + 4.05684 +cpp_rational 512 - 4.08474 +cpp_rational 512 * 61.8998 +cpp_rational 512 / 61.9712 +cpp_rational 1024 + 252.723 +cpp_rational 1024 - 253.81 +cpp_rational 1024 * 484.128 +cpp_rational 1024 / 834.057 +cpp_rational 1024 str 0.286067 +cpp_rational 1024 +(int)5.51612 +cpp_rational 1024 -(int)5.51949 +cpp_rational 1024 *(int)5.87507 +cpp_rational 1024 /(int)5.92837 +cpp_rational 1024 construct0.0102909 +cpp_rational 1024 construct(unsigned)0.062674 +cpp_rational 1024 construct(unsigned long long)0.0659089 +cpp_rational 1024 + 5.7444 +cpp_rational 1024 - 5.73296 +cpp_rational 1024 * 15.1475 +cpp_rational 1024 / 14.9497 +cpp_rational 1024 + 5.80438 +cpp_rational 1024 - 5.86 +cpp_rational 1024 * 67.4139 +cpp_rational 1024 / 67.4254 +mpq_rational 128 + 3.16879 +mpq_rational 128 - 3.18835 +mpq_rational 128 * 5.96709 +mpq_rational 128 / 15.0571 +mpq_rational 128 str 0.0037011 +mpq_rational 128 +(int)0.669634 +mpq_rational 128 -(int)0.666993 +mpq_rational 128 *(int)1.18047 +mpq_rational 128 /(int)1.43177 +mpq_rational 128 construct0.383107 +mpq_rational 128 construct(unsigned)0.394551 +mpq_rational 128 construct(unsigned long long)2.13183 +mpq_rational 128 + 2.33701 +mpq_rational 128 - 2.33227 +mpq_rational 128 * 4.15268 +mpq_rational 128 / 4.26818 +mpq_rational 128 + 2.33097 +mpq_rational 128 - 2.31793 +mpq_rational 128 * 9.34086 +mpq_rational 128 / 9.74135 +mpq_rational 256 + 6.93507 +mpq_rational 256 - 6.90939 +mpq_rational 256 * 12.9674 +mpq_rational 256 / 27.1144 +mpq_rational 256 str 0.00573278 +mpq_rational 256 +(int)0.707818 +mpq_rational 256 -(int)0.719174 +mpq_rational 256 *(int)1.22229 +mpq_rational 256 /(int)1.46082 +mpq_rational 256 construct0.381537 +mpq_rational 256 construct(unsigned)0.390987 +mpq_rational 256 construct(unsigned long long)2.12727 +mpq_rational 256 + 2.4159 +mpq_rational 256 - 2.41594 +mpq_rational 256 * 4.3447 +mpq_rational 256 / 4.43342 +mpq_rational 256 + 2.40187 +mpq_rational 256 - 2.39792 +mpq_rational 256 * 9.51195 +mpq_rational 256 / 9.65697 +mpq_rational 512 + 16.0886 +mpq_rational 512 - 16.1169 +mpq_rational 512 * 29.597 +mpq_rational 512 / 54.8579 +mpq_rational 512 str 0.012222 +mpq_rational 512 +(int)0.812783 +mpq_rational 512 -(int)0.810939 +mpq_rational 512 *(int)1.37678 +mpq_rational 512 /(int)1.6328 +mpq_rational 512 construct0.381355 +mpq_rational 512 construct(unsigned)0.392309 +mpq_rational 512 construct(unsigned long long)2.1179 +mpq_rational 512 + 2.55999 +mpq_rational 512 - 2.52842 +mpq_rational 512 * 4.82251 +mpq_rational 512 / 4.88079 +mpq_rational 512 + 2.5091 +mpq_rational 512 - 2.50572 +mpq_rational 512 * 9.90285 +mpq_rational 512 / 10.0077 +mpq_rational 1024 + 38.8883 +mpq_rational 1024 - 38.9096 +mpq_rational 1024 * 71.0635 +mpq_rational 1024 / 123.985 +mpq_rational 1024 str 0.0291802 +mpq_rational 1024 +(int)0.906471 +mpq_rational 1024 -(int)0.908293 +mpq_rational 1024 *(int)1.52386 +mpq_rational 1024 /(int)1.78575 +mpq_rational 1024 construct0.383461 +mpq_rational 1024 construct(unsigned)0.393504 +mpq_rational 1024 construct(unsigned long long)2.12279 +mpq_rational 1024 + 2.67794 +mpq_rational 1024 - 2.65991 +mpq_rational 1024 * 5.4209 +mpq_rational 1024 / 5.47417 +mpq_rational 1024 + 2.66144 +mpq_rational 1024 - 2.64168 +mpq_rational 1024 * 10.4664 +mpq_rational 1024 / 10.6781 +tommath_int 128 + 0.0222815 +tommath_int 128 - 0.027712 +tommath_int 128 * 0.113094 +tommath_int 128 / 3.09636 +tommath_int 128 str 0.0175165 +tommath_int 128 +(int)0.205506 +tommath_int 128 -(int)0.203148 +tommath_int 128 *(int)0.245897 +tommath_int 128 /(int)2.08045 +tommath_int 128 construct0.207455 +tommath_int 128 construct(unsigned)0.477971 +tommath_int 128 construct(unsigned long long)0.709516 +tommath_int 128 % 3.15171 +tommath_int 128 | 0.153434 +tommath_int 128 & 0.153508 +tommath_int 128 ^ 0.153931 +tommath_int 128 << 0.0408165 +tommath_int 128 >> 0.324163 +tommath_int 128 %(int)2.11648 +tommath_int 128 |(int)0.376671 +tommath_int 128 &(int)0.389144 +tommath_int 128 ^(int)0.374303 +tommath_int 128 gcd 12.5322 +tommath_int 128 + 0.514965 +tommath_int 128 - 0.517555 +tommath_int 128 * 0.607102 +tommath_int 128 / 2.36098 +tommath_int 128 + 0.510608 +tommath_int 128 - 0.520979 +tommath_int 128 * 18.5642 +tommath_int 128 / 1.13357 +tommath_int 256 + 0.0322049 +tommath_int 256 - 0.0407704 +tommath_int 256 * 0.346903 +tommath_int 256 / 4.01311 +tommath_int 256 str 0.0409078 +tommath_int 256 +(int)0.211847 +tommath_int 256 -(int)0.206481 +tommath_int 256 *(int)0.26894 +tommath_int 256 /(int)2.7099 +tommath_int 256 construct0.208012 +tommath_int 256 construct(unsigned)0.470752 +tommath_int 256 construct(unsigned long long)0.709045 +tommath_int 256 % 4.08522 +tommath_int 256 | 0.170093 +tommath_int 256 & 0.176384 +tommath_int 256 ^ 0.172198 +tommath_int 256 << 0.0698155 +tommath_int 256 >> 0.383757 +tommath_int 256 %(int)2.74052 +tommath_int 256 |(int)0.375206 +tommath_int 256 &(int)0.389768 +tommath_int 256 ^(int)0.379255 +tommath_int 256 gcd 26.1755 +tommath_int 256 + 0.530504 +tommath_int 256 - 0.527832 +tommath_int 256 * 0.648438 +tommath_int 256 / 3.16803 +tommath_int 256 + 0.526199 +tommath_int 256 - 0.527479 +tommath_int 256 * 18.624 +tommath_int 256 / 1.1208 +tommath_int 512 + 0.0455267 +tommath_int 512 - 0.0515883 +tommath_int 512 * 0.999026 +tommath_int 512 / 5.95775 +tommath_int 512 str 0.111392 +tommath_int 512 +(int)0.227429 +tommath_int 512 -(int)0.219998 +tommath_int 512 *(int)0.31746 +tommath_int 512 /(int)4.1339 +tommath_int 512 construct0.205622 +tommath_int 512 construct(unsigned)0.473807 +tommath_int 512 construct(unsigned long long)0.703879 +tommath_int 512 % 5.70483 +tommath_int 512 | 0.179084 +tommath_int 512 & 0.182373 +tommath_int 512 ^ 0.183434 +tommath_int 512 << 0.0973643 +tommath_int 512 >> 0.398354 +tommath_int 512 %(int)3.96918 +tommath_int 512 |(int)0.381428 +tommath_int 512 &(int)0.40432 +tommath_int 512 ^(int)0.390434 +tommath_int 512 gcd 56.7747 +tommath_int 512 + 0.546222 +tommath_int 512 - 0.53408 +tommath_int 512 * 0.718764 +tommath_int 512 / 5.07545 +tommath_int 512 + 0.543084 +tommath_int 512 - 0.535411 +tommath_int 512 * 18.745 +tommath_int 512 / 1.15084 +tommath_int 1024 + 0.074223 +tommath_int 1024 - 0.0786205 +tommath_int 1024 * 3.20269 +tommath_int 1024 / 12.7383 +tommath_int 1024 str 0.345861 +tommath_int 1024 +(int)0.250477 +tommath_int 1024 -(int)0.2372 +tommath_int 1024 *(int)0.408933 +tommath_int 1024 /(int)9.04346 +tommath_int 1024 construct0.207377 +tommath_int 1024 construct(unsigned)0.475755 +tommath_int 1024 construct(unsigned long long)0.712949 +tommath_int 1024 % 12.6845 +tommath_int 1024 | 0.436588 +tommath_int 1024 & 0.429721 +tommath_int 1024 ^ 0.429478 +tommath_int 1024 << 0.167289 +tommath_int 1024 >> 0.570323 +tommath_int 1024 %(int)9.09202 +tommath_int 1024 |(int)0.622404 +tommath_int 1024 &(int)0.653128 +tommath_int 1024 ^(int)0.62285 +tommath_int 1024 gcd 132.299 +tommath_int 1024 + 0.578521 +tommath_int 1024 - 0.552649 +tommath_int 1024 * 0.871648 +tommath_int 1024 / 12.2672 +tommath_int 1024 + 0.568301 +tommath_int 1024 - 0.54931 +tommath_int 1024 * 19.0954 +tommath_int 1024 / 1.21165 +cpp_dec_float 50 + 0.0250949 +cpp_dec_float 50 - 0.0264782 +cpp_dec_float 50 * 0.163403 +cpp_dec_float 50 / 3.9502 +cpp_dec_float 50 str 0.0207318 +cpp_dec_float 50 +(int)0.0441266 +cpp_dec_float 50 -(int)0.0442578 +cpp_dec_float 50 *(int)0.234992 +cpp_dec_float 50 /(int)1.81469 +cpp_dec_float 50 construct0.00925753 +cpp_dec_float 50 construct(unsigned)0.0588752 +cpp_dec_float 50 construct(unsigned long long)0.0587691 +cpp_dec_float 50 + 0.0770875 +cpp_dec_float 50 - 0.0741921 +cpp_dec_float 50 * 0.329282 +cpp_dec_float 50 / 1.9701 +cpp_dec_float 50 + 0.0640148 +cpp_dec_float 50 - 0.0643402 +cpp_dec_float 50 * 0.321363 +cpp_dec_float 50 / 1.97464 +cpp_dec_float 100 + 0.0291508 +cpp_dec_float 100 - 0.0307447 +cpp_dec_float 100 * 0.284182 +cpp_dec_float 100 / 7.68823 +cpp_dec_float 100 str 0.0328218 +cpp_dec_float 100 +(int)0.0558389 +cpp_dec_float 100 -(int)0.0563278 +cpp_dec_float 100 *(int)0.460635 +cpp_dec_float 100 /(int)3.62471 +cpp_dec_float 100 construct0.0263234 +cpp_dec_float 100 construct(unsigned)0.0747853 +cpp_dec_float 100 construct(unsigned long long)0.076338 +cpp_dec_float 100 + 0.0845054 +cpp_dec_float 100 - 0.0844193 +cpp_dec_float 100 * 0.582119 +cpp_dec_float 100 / 3.8773 +cpp_dec_float 100 + 0.0708668 +cpp_dec_float 100 - 0.0730765 +cpp_dec_float 100 * 0.574512 +cpp_dec_float 100 / 3.83437 +cpp_dec_float 500 + 0.0630915 +cpp_dec_float 500 - 0.0651113 +cpp_dec_float 500 * 2.22501 +cpp_dec_float 500 / 50.6121 +cpp_dec_float 500 str 0.131293 +cpp_dec_float 500 +(int)0.0935946 +cpp_dec_float 500 -(int)0.0950432 +cpp_dec_float 500 *(int)4.36195 +cpp_dec_float 500 /(int)24.4855 +cpp_dec_float 500 construct0.0306104 +cpp_dec_float 500 construct(unsigned)0.114772 +cpp_dec_float 500 construct(unsigned long long)0.117075 +cpp_dec_float 500 + 0.12407 +cpp_dec_float 500 - 0.122646 +cpp_dec_float 500 * 4.75508 +cpp_dec_float 500 / 25.1602 +cpp_dec_float 500 + 0.0865073 +cpp_dec_float 500 - 0.0929075 +cpp_dec_float 500 * 4.74128 +cpp_dec_float 500 / 25.1175 +mpfr_float 50 + 0.0624318 +mpfr_float 50 - 0.0764497 +mpfr_float 50 * 0.342248 +mpfr_float 50 / 1.69721 +mpfr_float 50 str 0.0289013 +mpfr_float 50 +(int)0.121683 +mpfr_float 50 -(int)0.149605 +mpfr_float 50 *(int)0.1548 +mpfr_float 50 /(int)0.213367 +mpfr_float 50 construct0.214552 +mpfr_float 50 construct(unsigned)0.293892 +mpfr_float 50 construct(unsigned long long)0.638307 +mpfr_float 50 + 0.553442 +mpfr_float 50 - 0.565687 +mpfr_float 50 * 0.841214 +mpfr_float 50 / 1.26072 +mpfr_float 50 + 0.537349 +mpfr_float 50 - 0.561924 +mpfr_float 50 * 0.833423 +mpfr_float 50 / 1.25318 +mpfr_float 100 + 0.0669494 +mpfr_float 100 - 0.0820912 +mpfr_float 100 * 0.478422 +mpfr_float 100 / 2.33995 +mpfr_float 100 str 0.0390764 +mpfr_float 100 +(int)0.117387 +mpfr_float 100 -(int)0.150557 +mpfr_float 100 *(int)0.166496 +mpfr_float 100 /(int)0.267439 +mpfr_float 100 construct0.222594 +mpfr_float 100 construct(unsigned)0.297568 +mpfr_float 100 construct(unsigned long long)0.643108 +mpfr_float 100 + 0.573918 +mpfr_float 100 - 0.592139 +mpfr_float 100 * 0.978674 +mpfr_float 100 / 1.5879 +mpfr_float 100 + 0.561143 +mpfr_float 100 - 0.580528 +mpfr_float 100 * 0.97887 +mpfr_float 100 / 1.58378 +mpfr_float 500 + 0.0817812 +mpfr_float 500 - 0.0975533 +mpfr_float 500 * 3.8308 +mpfr_float 500 / 13.8283 +mpfr_float 500 str 0.156188 +mpfr_float 500 +(int)0.129266 +mpfr_float 500 -(int)0.16446 +mpfr_float 500 *(int)0.273431 +mpfr_float 500 /(int)0.731526 +mpfr_float 500 construct0.222587 +mpfr_float 500 construct(unsigned)0.311108 +mpfr_float 500 construct(unsigned long long)0.653074 +mpfr_float 500 + 0.667956 +mpfr_float 500 - 0.684152 +mpfr_float 500 * 1.2661 +mpfr_float 500 / 7.46167 +mpfr_float 500 + 0.642822 +mpfr_float 500 - 0.65164 +mpfr_float 500 * 1.25714 +mpfr_float 500 / 7.46171 +[section:float_performance Float Type Perfomance] +[table Operator * +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][[*1] (0.321363s)][1.0169 (0.574512s)][6.76401 (4.74128s)]] +[[gmp_float][1.7169 (0.551747s)][[*1] (0.564962s)][[*1] (0.700957s)]] +[[mpfr_float][2.5934 (0.833423s)][1.73263 (0.97887s)][1.79346 (1.25714s)]] +] +[table Operator *(int) +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][5.56675 (0.234992s)][9.32996 (0.460635s)][50.8459 (4.36195s)]] +[[gmp_float][[*1] (0.0422135s)][[*1] (0.0493716s)][[*1] (0.0857876s)]] +[[mpfr_float][3.66707 (0.1548s)][3.37231 (0.166496s)][3.1873 (0.273431s)]] +] +[table Operator + +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][[*1] (0.0640148s)][[*1] (0.0708668s)][[*1] (0.0865073s)]] +[[gmp_float][7.467 (0.477999s)][6.72671 (0.476701s)][5.67136 (0.490614s)]] +[[mpfr_float][8.39413 (0.537349s)][7.91828 (0.561143s)][7.43085 (0.642822s)]] +] +[table Operator +(int) +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][1.33358 (0.0441266s)][1.4433 (0.0558389s)][1.44838 (0.0935946s)]] +[[gmp_float][[*1] (0.0330888s)][[*1] (0.0386882s)][[*1] (0.0646201s)]] +[[mpfr_float][3.67747 (0.121683s)][3.03419 (0.117387s)][2.00041 (0.129266s)]] +] +[table Operator - +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][[*1] (0.0643402s)][[*1] (0.0730765s)][[*1] (0.0929075s)]] +[[gmp_float][7.76625 (0.499682s)][6.89067 (0.503546s)][5.89566 (0.547751s)]] +[[mpfr_float][8.73364 (0.561924s)][7.94411 (0.580528s)][7.01385 (0.65164s)]] +] +[table Operator -(int) +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][[*1] (0.0442578s)][[*1] (0.0563278s)][[*1] (0.0950432s)]] +[[gmp_float][3.0379 (0.134451s)][2.39847 (0.1351s)][1.86101 (0.176876s)]] +[[mpfr_float][3.38031 (0.149605s)][2.67288 (0.150557s)][1.73037 (0.16446s)]] +] +[table Operator / +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][2.20938 (1.97464s)][3.71086 (3.83437s)][11.2059 (25.1175s)]] +[[gmp_float][[*1] (0.893752s)][[*1] (1.03328s)][[*1] (2.24146s)]] +[[mpfr_float][1.40216 (1.25318s)][1.53276 (1.58378s)][3.32895 (7.46171s)]] +] +[table Operator /(int) +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][10.0596 (1.81469s)][15.5048 (3.62471s)][34.4767 (24.4855s)]] +[[gmp_float][[*1] (0.180393s)][[*1] (0.23378s)][[*1] (0.710204s)]] +[[mpfr_float][1.18279 (0.213367s)][1.14398 (0.267439s)][1.03002 (0.731526s)]] +] +[table Operator construct +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][[*1] (0.00925753s)][[*1] (0.0263234s)][[*1] (0.0306104s)]] +[[gmp_float][21.32 (0.19737s)][7.4686 (0.196599s)][6.73181 (0.206063s)]] +[[mpfr_float][23.176 (0.214552s)][8.45613 (0.222594s)][7.27162 (0.222587s)]] +] +[table Operator construct(unsigned long long) +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][[*1] (0.0587691s)][[*1] (0.076338s)][[*1] (0.117075s)]] +[[gmp_float][8.84863 (0.520025s)][6.80343 (0.51936s)][4.59554 (0.538021s)]] +[[mpfr_float][10.8613 (0.638307s)][8.42448 (0.643108s)][5.57826 (0.653074s)]] +] +[table Operator construct(unsigned) +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][[*1] (0.0588752s)][[*1] (0.0747853s)][[*1] (0.114772s)]] +[[gmp_float][3.53421 (0.208078s)][2.76875 (0.207062s)][1.89088 (0.217019s)]] +[[mpfr_float][4.99178 (0.293892s)][3.97896 (0.297568s)][2.71067 (0.311108s)]] +] +[table Operator str +[[Backend][50 Bits][100 Bits][500 Bits]] +[[cpp_dec_float][1.5616 (0.0207318s)][1.61725 (0.0328218s)][[*1] (0.131293s)]] +[[gmp_float][[*1] (0.013276s)][[*1] (0.0202949s)][1.07517 (0.141162s)]] +[[mpfr_float][2.17696 (0.0289013s)][1.92543 (0.0390764s)][1.18962 (0.156188s)]] +] +[endsect] +[section:integer_performance Integer Type Perfomance] +[table Operator % +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][5.31184 (0.37333s)][1.99944e+236 (0.673748s)][2.08204e+236 (0.701584s)][3.39405e+236 (1.14369s)]] +[[cpp_int(fixed)][1.10616 (0.0777437s)][5.8492e+235 (0.1971s)][9.91271e+235 (0.334027s)][1.60165e+236 (0.539708s)][-1.#INF (0.94847s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.0702826s)]] +[[gmp_int][9.12715 (0.64148s)][2.088e+236 (0.703592s)][2.43295e+236 (0.819828s)][3.02578e+236 (1.01959s)]] +[[tommath_int][44.8434 (3.15171s)][1.21234e+237 (4.08522s)][1.69298e+237 (5.70483s)][3.7643e+237 (12.6845s)]] +] +[table Operator %(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][3.51789 (0.104856s)][-1.#INF (0.203012s)][-1.#INF (0.391566s)][-1.#INF (0.768511s)]] +[[cpp_int(fixed)][1.14548 (0.0341425s)][-1.#INF (0.103684s)][-1.#INF (0.200647s)][-1.#INF (0.377704s)][-1.#INF (0.743202s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.0298064s)]] +[[gmp_int][1.91945 (0.0572117s)][-1.#INF (0.10258s)][-1.#INF (0.188529s)][-1.#INF (0.355222s)]] +[[tommath_int][71.0078 (2.11648s)][-1.#INF (2.74052s)][-1.#INF (3.96918s)][-1.#INF (9.09202s)]] +] +[table Operator & +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][12.079 (0.031605s)][-1.11772e+007 (0.0455929s)][-1.33961e+007 (0.0546439s)][-2.06875e+007 (0.0843863s)]] +[[cpp_int(fixed)][4.74538 (0.0124165s)][-8.36978e+006 (0.0341411s)][-1.22854e+007 (0.0501131s)][-1.4424e+007 (0.0588367s)][-1.#INF (0.0774574s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.00261653s)]] +[[gmp_int][20.5664 (0.0538128s)][-1.59881e+007 (0.0652169s)][-2.25796e+007 (0.092104s)][-3.5403e+007 (0.144412s)]] +[[tommath_int][58.6685 (0.153508s)][-4.3241e+007 (0.176384s)][-4.47093e+007 (0.182373s)][-1.05347e+008 (0.429721s)]] +] +[table Operator &(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][23.3956 (0.0377678s)][-7.85844e+307 (0.0471524s)][-1.07843e+308 (0.0647085s)][-1.68143e+308 (0.10089s)]] +[[cpp_int(fixed)][6.49083 (0.0104782s)][-6.95612e+307 (0.0417383s)][-8.99012e+307 (0.0539427s)][-1.17371e+308 (0.070425s)][-1.#INF (0.112823s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.00161431s)]] +[[gmp_int][87.5331 (0.141306s)][-1.#INF (0.139398s)][-1.#INF (0.142498s)][-1.#INF (0.141249s)]] +[[tommath_int][241.059 (0.389144s)][-1.#INF (0.389768s)][-1.#INF (0.40432s)][-1.#INF (0.653128s)]] +] +[table Operator * +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][1715.93 (7.6372s)][-4.15607e+276 (7.7121s)][-4.16472e+276 (7.72815s)][-4.23791e+276 (7.86395s)]] +[[cpp_int(fixed)][1.27579 (0.00567824s)][-3.62916e+274 (0.0673436s)][-5.78275e+274 (0.107306s)][-9.2595e+274 (0.171821s)][-1.#INF (0.299236s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.00445077s)]] +[[gmp_int][710.595 (3.1627s)][-1.69816e+276 (3.15114s)][-1.70883e+276 (3.17094s)][-1.7293e+276 (3.20893s)]] +[[tommath_int][4171.01 (18.5642s)][-1.00365e+277 (18.624s)][-1.01017e+277 (18.745s)][-1.02906e+277 (19.0954s)]] +] +[table Operator *(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][9.97316 (0.0235876s)][1.#INF (0.0318939s)][1.#INF (0.0427792s)][1.#INF (0.0668616s)]] +[[cpp_int(fixed)][2.32007 (0.00548722s)][1.#INF (0.0328109s)][1.#INF (0.049867s)][1.#INF (0.0658566s)][-1.#INF (0.0948565s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.00236511s)]] +[[gmp_int][9.62157 (0.022756s)][1.#INF (0.0282672s)][1.#INF (0.0361075s)][1.#INF (0.0518882s)]] +[[tommath_int][103.969 (0.245897s)][1.#INF (0.26894s)][1.#INF (0.31746s)][1.#INF (0.408933s)]] +] +[table Operator + +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][9.74543 (0.0196594s)][3.98952e+276 (0.0215291s)][4.2355e+276 (0.0228565s)][4.21393e+276 (0.0227402s)]] +[[cpp_int(fixed)][2.13187 (0.00430062s)][3.11951e+276 (0.0168342s)][3.15933e+276 (0.0170491s)][3.19893e+276 (0.0172628s)][-1.#INF (0.0181245s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.0020173s)]] +[[gmp_int][337.759 (0.68136s)][1.27731e+278 (0.68929s)][1.28647e+278 (0.694235s)][1.27865e+278 (0.690013s)]] +[[tommath_int][253.115 (0.510608s)][9.75089e+277 (0.526199s)][1.00638e+278 (0.543084s)][1.05311e+278 (0.568301s)]] +] +[table Operator +(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][9.81588 (0.0159069s)][-5.71737e+244 (0.0218386s)][-8.2882e+244 (0.0316584s)][-1.1265e+245 (0.0430289s)]] +[[cpp_int(fixed)][3.92617 (0.00636247s)][-7.02443e+244 (0.0268311s)][-1.07535e+245 (0.0410749s)][-1.37293e+245 (0.0524416s)][-1.#INF (0.0728817s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.00162053s)]] +[[gmp_int][19.2059 (0.0311237s)][-1.12054e+245 (0.0428011s)][-1.74239e+245 (0.0665539s)][-2.83458e+245 (0.108272s)]] +[[tommath_int][126.815 (0.205506s)][-5.54618e+245 (0.211847s)][-5.95413e+245 (0.227429s)][-6.55751e+245 (0.250477s)]] +] +[table Operator - +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][11.0409 (0.0210968s)][3.86227e+276 (0.0213343s)][4.03471e+276 (0.0222868s)][4.24576e+276 (0.0234526s)]] +[[cpp_int(fixed)][2.02836 (0.00387577s)][3.06763e+276 (0.0169449s)][3.2004e+276 (0.0176783s)][3.27232e+276 (0.0180756s)][-1.#INF (0.0190581s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.00191079s)]] +[[gmp_int][356.496 (0.681187s)][1.23744e+278 (0.683532s)][1.2536e+278 (0.69246s)][1.25066e+278 (0.690838s)]] +[[tommath_int][272.651 (0.520979s)][9.54925e+277 (0.527479s)][9.69283e+277 (0.535411s)][9.94446e+277 (0.54931s)]] +] +[table Operator -(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][9.24378 (0.0151244s)][-1.01975e-199 (0.017199s)][-1.47092e-199 (0.0248084s)][-1.96387e-199 (0.0331224s)]] +[[cpp_int(fixed)][4.08494 (0.00668367s)][-1.43394e-199 (0.0241848s)][-2.18373e-199 (0.0368306s)][-2.98469e-199 (0.0503396s)][-1.#INF (0.0621059s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.00163617s)]] +[[gmp_int][18.693 (0.030585s)][-2.37422e-199 (0.0400434s)][-3.42818e-199 (0.0578194s)][-5.96116e-199 (0.100541s)]] +[[tommath_int][124.161 (0.203148s)][-1.22425e-198 (0.206481s)][-1.30439e-198 (0.219998s)][-1.40639e-198 (0.2372s)]] +] +[table Operator / +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][1.96346 (0.0578293s)][-1.51814e+061 (0.0615507s)][-1.8062e+061 (0.0732298s)][-3.04778e+061 (0.123568s)]] +[[cpp_int(fixed)][1.08704 (0.0320162s)][-8.07606e+060 (0.0327432s)][-8.40351e+060 (0.0340708s)][-1.09735e+061 (0.0444905s)][-1.#INF (0.106788s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.0294528s)]] +[[gmp_int][23.2741 (0.685487s)][-1.70068e+062 (0.689516s)][-1.6994e+062 (0.688995s)][-1.74523e+062 (0.707578s)]] +[[tommath_int][38.4876 (1.13357s)][-2.76443e+062 (1.1208s)][-2.83854e+062 (1.15084s)][-2.98853e+062 (1.21165s)]] +] +[table Operator /(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][7.87676 (0.235955s)][1.#INF (0.35212s)][1.#INF (0.568032s)][1.#INF (0.989885s)]] +[[cpp_int(fixed)][1.21173 (0.0362985s)][1.#INF (0.137619s)][1.#INF (0.253796s)][1.#INF (0.446782s)][-1.#INF (0.84764s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.0299559s)]] +[[gmp_int][1.87075 (0.0560401s)][1.#INF (0.0982823s)][1.#INF (0.183564s)][1.#INF (0.352238s)]] +[[tommath_int][69.4504 (2.08045s)][1.#INF (2.7099s)][1.#INF (4.1339s)][1.#INF (9.04346s)]] +] +[table Operator << +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][15.849 (0.0256107s)][-5.85461e+126 (0.0401135s)][-6.36621e+126 (0.0436188s)][-9.17366e+126 (0.0628544s)]] +[[cpp_int(fixed)][3.19639 (0.00516511s)][-4.68379e+126 (0.0320915s)][-7.40049e+126 (0.0507053s)][-8.72078e+126 (0.0597514s)][-1.#INF (0.0677088s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.00161592s)]] +[[gmp_int][16.956 (0.0273994s)][-4.66649e+126 (0.031973s)][-6.88464e+126 (0.0471709s)][-1.05374e+127 (0.0721984s)]] +[[tommath_int][25.259 (0.0408165s)][-1.01897e+127 (0.0698155s)][-1.42104e+127 (0.0973643s)][-2.4416e+127 (0.167289s)]] +] +[table Operator >> +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][14.6983 (0.0237523s)][-2.28921e+307 (0.0302534s)][-2.68808e+307 (0.0355247s)][-3.38364e+307 (0.044717s)]] +[[cpp_int(fixed)][2.47217 (0.00399499s)][-2.21749e+307 (0.0293055s)][-2.9515e+307 (0.039006s)][-3.9023e+307 (0.0515714s)][-1.#INF (0.0626121s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.00161599s)]] +[[gmp_int][17.8366 (0.0288237s)][-2.3471e+307 (0.0310184s)][-2.55387e+307 (0.0337511s)][-2.9362e+307 (0.0388038s)]] +[[tommath_int][200.597 (0.324163s)][-1.#INF (0.383757s)][-1.#INF (0.398354s)][-1.#INF (0.570323s)]] +] +[table Operator ^ +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][7.95372 (0.0318172s)][1.21131 (0.0425243s)][1.02246 (0.0542436s)][1.19877 (0.08333s)]] +[[cpp_int(fixed)][2.75762 (0.0110313s)][[*1] (0.0351059s)][[*1] (0.0530521s)][[*1] (0.0695132s)][-1.#INF (0.09783s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.0040003s)]] +[[gmp_int][12.4289 (0.0497194s)][1.79507 (0.0630174s)][1.63955 (0.0869819s)][2.0012 (0.139109s)]] +[[tommath_int][38.4798 (0.153931s)][4.9051 (0.172198s)][3.45761 (0.183434s)][6.17837 (0.429478s)]] +] +[table Operator ^(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][15.3547 (0.0283305s)][-8.92021e+307 (0.0353555s)][-1.05356e+308 (0.041758s)][-1.35819e+308 (0.0538323s)]] +[[cpp_int(fixed)][5.81005 (0.0107199s)][-7.88073e+307 (0.0312355s)][-1.20328e+308 (0.0476923s)][-1.36485e+308 (0.0540962s)][-1.#INF (0.0806317s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.00184507s)]] +[[gmp_int][78.0102 (0.143934s)][-1.#INF (0.144825s)][-1.#INF (0.152773s)][-1.#INF (0.161662s)]] +[[tommath_int][202.867 (0.374303s)][-1.#INF (0.379255s)][-1.#INF (0.390434s)][-1.#INF (0.62285s)]] +] +[table Operator construct +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][2.64088 (0.00293927s)][1.47161e+238 (0.00277479s)][1.49039e+238 (0.0028102s)][1.47064e+238 (0.00277298s)]] +[[cpp_int(fixed)][1.45325 (0.00161745s)][8.73297e+237 (0.00164665s)][1.92709e+238 (0.00363363s)][3.0576e+238 (0.00576526s)][-1.#INF (0.00535599s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.00111299s)]] +[[gmp_int][176.266 (0.196182s)][1.06706e+240 (0.201199s)][1.04919e+240 (0.19783s)][1.04712e+240 (0.19744s)]] +[[tommath_int][186.394 (0.207455s)][1.10319e+240 (0.208012s)][1.09052e+240 (0.205622s)][1.09982e+240 (0.207377s)]] +] +[table Operator construct(unsigned long long) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][3.51152 (0.00719854s)][-2.80497e-148 (0.00725455s)][-2.79893e-148 (0.00723891s)][-2.83336e-148 (0.00732796s)]] +[[cpp_int(fixed)][[*1] (0.00204998s)][-1.21019e-148 (0.00312994s)][-1.50065e-148 (0.00388115s)][-2.15185e-148 (0.00556537s)][-1.#INF (0.00577713s)]] +[[cpp_int(unsigned, fixed)][1.17501 (0.00240876s)]] +[[gmp_int][351.097 (0.719741s)][-2.82056e-146 (0.729487s)][-2.80186e-146 (0.724649s)][-2.79263e-146 (0.722262s)]] +[[tommath_int][346.109 (0.709516s)][-2.74152e-146 (0.709045s)][-2.72155e-146 (0.703879s)][-2.75662e-146 (0.712949s)]] +] +[table Operator construct(unsigned) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][2.44987 (0.00270684s)][1.90974 (0.0030529s)][[*1] (0.00288857s)][[*1] (0.00265201s)]] +[[cpp_int(fixed)][1.89292 (0.00209147s)][[*1] (0.0015986s)][1.28253 (0.00370466s)][2.19414 (0.0058189s)][-1.#INF (0.00836042s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.00110489s)]] +[[gmp_int][186.546 (0.206113s)][132.175 (0.211295s)][71.6424 (0.206944s)][81.5339 (0.216229s)]] +[[tommath_int][432.596 (0.477971s)][294.478 (0.470752s)][164.029 (0.473807s)][179.394 (0.475755s)]] +] +[table Operator gcd +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][8.27321 (4.98644s)][-1.#INF (11.1816s)][-1.#INF (27.2257s)][-1.#INF (73.3735s)]] +[[cpp_int(fixed)][1.0026 (0.604291s)][-1.#INF (4.18006s)][-1.#INF (10.2671s)][-1.#INF (26.2762s)][-1.#INF (76.2849s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.602722s)]] +[[gmp_int][4.06647 (2.45095s)][-1.#INF (5.89505s)][-1.#INF (13.6993s)][-1.#INF (33.2232s)]] +[[tommath_int][20.7927 (12.5322s)][-1.#INF (26.1755s)][-1.#INF (56.7747s)][-1.#INF (132.299s)]] +] +[table Operator str +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][1.02246 (0.00189808s)][-3.42215e+178 (0.00391656s)][-7.26989e+178 (0.00832019s)][-1.93625e+179 (0.0221599s)]] +[[cpp_int(fixed)][1.35564 (0.00251659s)][-1.36421e+178 (0.0015613s)][-2.59752e+178 (0.00297279s)][-6.18963e+178 (0.00708386s)][-1.#INF (0.0172514s)]] +[[cpp_int(unsigned, fixed)][1.38149 (0.00256457s)]] +[[gmp_int][[*1] (0.00185638s)][-3.01078e+178 (0.00344576s)][-5.40339e+178 (0.00618403s)][-1.26279e+179 (0.0144523s)]] +[[tommath_int][9.43586 (0.0175165s)][-3.57438e+179 (0.0409078s)][-9.73304e+179 (0.111392s)][-3.02201e+180 (0.345861s)]] +] +[table Operator | +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][11.6542 (0.030991s)][-6.48076e+046 (0.0429658s)][-8.11261e+046 (0.0537846s)][-1.24844e+047 (0.0827684s)]] +[[cpp_int(fixed)][4.09831 (0.0108982s)][-5.73378e+046 (0.0380136s)][-7.98794e+046 (0.0529581s)][-1.02098e+047 (0.0676884s)][-1.#INF (0.100936s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.00265921s)]] +[[gmp_int][17.8503 (0.0474678s)][-9.32586e+046 (0.0618281s)][-1.29209e+047 (0.0856626s)][-2.0526e+047 (0.136082s)]] +[[tommath_int][57.6991 (0.153434s)][-2.5656e+047 (0.170093s)][-2.70121e+047 (0.179084s)][-6.58529e+047 (0.436588s)]] +] +[table Operator |(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_int][16.9457 (0.0280516s)][-4.17523e+307 (0.0363929s)][-4.79721e+307 (0.0418143s)][-6.04694e+307 (0.0527075s)]] +[[cpp_int(fixed)][6.70551 (0.0111002s)][-3.64663e+307 (0.0317854s)][-5.35725e+307 (0.0466958s)][-6.16052e+307 (0.0536974s)][-1.#INF (0.0819107s)]] +[[cpp_int(unsigned, fixed)][[*1] (0.00165538s)]] +[[gmp_int][85.2488 (0.141119s)][-1.64044e+308 (0.142987s)][-1.78579e+308 (0.155656s)][-1.#INF (0.163236s)]] +[[tommath_int][227.544 (0.376671s)][-1.#INF (0.375206s)][-1.#INF (0.381428s)][-1.#INF (0.622404s)]] +] +[endsect] +[section:rational_performance Rational Type Perfomance] +[table Operator * +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][6.20279 (57.9393s)][6.23608 (59.3172s)][6.25071 (61.8998s)][6.44097 (67.4139s)]] +[[mpq_rational][[*1] (9.34086s)][[*1] (9.51195s)][[*1] (9.90285s)][[*1] (10.4664s)]] +] +[table Operator *(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][2.06502 (2.4377s)][2.38344 (2.91325s)][2.86734 (3.94768s)][3.8554 (5.87507s)]] +[[mpq_rational][[*1] (1.18047s)][[*1] (1.22229s)][[*1] (1.37678s)][[*1] (1.52386s)]] +] +[table Operator + +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][1.1513 (2.68363s)][1.31207 (3.15142s)][1.61685 (4.05684s)][2.18092 (5.80438s)]] +[[mpq_rational][[*1] (2.33097s)][[*1] (2.40187s)][[*1] (2.5091s)][[*1] (2.66144s)]] +] +[table Operator +(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][3.69962 (2.47739s)][4.12788 (2.92179s)][4.67839 (3.80252s)][6.08526 (5.51612s)]] +[[mpq_rational][[*1] (0.669634s)][[*1] (0.707818s)][[*1] (0.812783s)][[*1] (0.906471s)]] +] +[table Operator - +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][1.17746 (2.72926s)][1.334 (3.19882s)][1.63017 (4.08474s)][2.21829 (5.86s)]] +[[mpq_rational][[*1] (2.31793s)][[*1] (2.39792s)][[*1] (2.50572s)][[*1] (2.64168s)]] +] +[table Operator -(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][3.71756 (2.47959s)][4.04045 (2.90579s)][4.69474 (3.80714s)][6.07677 (5.51949s)]] +[[mpq_rational][[*1] (0.666993s)][[*1] (0.719174s)][[*1] (0.810939s)][[*1] (0.908293s)]] +] +[table Operator / +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][5.95741 (58.0332s)][6.16582 (59.5431s)][6.19235 (61.9712s)][6.31439 (67.4254s)]] +[[mpq_rational][[*1] (9.74135s)][[*1] (9.65697s)][[*1] (10.0077s)][[*1] (10.6781s)]] +] +[table Operator /(int) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][1.75198 (2.50843s)][2.05836 (3.00689s)][2.45339 (4.00588s)][3.31983 (5.92837s)]] +[[mpq_rational][[*1] (1.43177s)][[*1] (1.46082s)][[*1] (1.6328s)][[*1] (1.78575s)]] +] +[table Operator construct +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][[*1] (0.0102665s)][[*1] (0.0101737s)][[*1] (0.0101965s)][[*1] (0.0102909s)]] +[[mpq_rational][37.3164 (0.383107s)][37.5023 (0.381537s)][37.4005 (0.381355s)][37.2621 (0.383461s)]] +] +[table Operator construct(unsigned long long) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][[*1] (0.0658436s)][[*1] (0.0665504s)][[*1] (0.0659082s)][[*1] (0.0659089s)]] +[[mpq_rational][32.3771 (2.13183s)][31.9648 (2.12727s)][32.1342 (2.1179s)][32.2079 (2.12279s)]] +] +[table Operator construct(unsigned) +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][[*1] (0.0624887s)][[*1] (0.0609531s)][[*1] (0.0613968s)][[*1] (0.062674s)]] +[[mpq_rational][6.31396 (0.394551s)][6.41455 (0.390987s)][6.38973 (0.392309s)][6.27858 (0.393504s)]] +] +[table Operator str +[[Backend][128 Bits][256 Bits][512 Bits][1024 Bits]] +[[cpp_rational][5.4954 (0.020339s)][9.02403 (0.0517328s)][9.75685 (0.119248s)][9.80346 (0.286067s)]] +[[mpq_rational][[*1] (0.0037011s)][[*1] (0.00573278s)][[*1] (0.012222s)][[*1] (0.0291802s)]] +] +[endsect] diff --git a/src/boost/libs/multiprecision/performance/performance_test.cpp b/src/boost/libs/multiprecision/performance/performance_test.cpp new file mode 100644 index 00000000..95a1efd6 --- /dev/null +++ b/src/boost/libs/multiprecision/performance/performance_test.cpp @@ -0,0 +1,851 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2011 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#define BOOST_CHRONO_HEADER_ONLY + +#ifdef _MSC_VER +#define _SCL_SECURE_NO_WARNINGS +#endif + +#if !defined(TEST_MPF) && !defined(TEST_MPZ) && \ + !defined(TEST_CPP_DEC_FLOAT) && !defined(TEST_MPFR) && !defined(TEST_MPQ) && !defined(TEST_TOMMATH) && !defined(TEST_TOMMATH_BOOST_RATIONAL) && !defined(TEST_MPZ_BOOST_RATIONAL) && !defined(TEST_CPP_INT) && !defined(TEST_CPP_INT_RATIONAL) && !defined(TEST_CPP_BIN_FLOAT) +#define TEST_MPF +#define TEST_MPZ +#define TEST_MPQ +#define TEST_MPFR +#define TEST_CPP_DEC_FLOAT +#define TEST_MPQ +#define TEST_TOMMATH +#define TEST_CPP_INT +#define TEST_CPP_INT_RATIONAL +#define TEST_CPP_BIN_FLOAT + +#ifdef _MSC_VER +#pragma message("CAUTION!!: No backend type specified so testing everything.... this will take some time!!") +#endif +#ifdef __GNUC__ +#pragma warning "CAUTION!!: No backend type specified so testing everything.... this will take some time!!" +#endif + +#endif + +#if defined(TEST_MPF) || defined(TEST_MPZ) || defined(TEST_MPQ) || defined(TEST_MPZ_BOOST_RATIONAL) +#include <boost/multiprecision/gmp.hpp> +#include <boost/multiprecision/rational_adaptor.hpp> +#endif +#ifdef TEST_CPP_DEC_FLOAT +#include <boost/multiprecision/cpp_dec_float.hpp> +#endif +#ifdef TEST_CPP_BIN_FLOAT +#include <boost/multiprecision/cpp_bin_float.hpp> +#endif +#if defined(TEST_MPFR) +#include <boost/multiprecision/mpfr.hpp> +#endif +#if defined(TEST_TOMMATH) || defined(TEST_TOMMATH_BOOST_RATIONAL) +#include <boost/multiprecision/tommath.hpp> +#include <boost/multiprecision/rational_adaptor.hpp> +#endif +#if defined(TEST_CPP_INT) || defined(TEST_CPP_INT_RATIONAL) +#include <boost/multiprecision/cpp_int.hpp> +#endif + +#include <boost/chrono.hpp> +#include <vector> +#include <map> +#include <string> +#include <cstring> +#include <cctype> +#include <iostream> +#include <iomanip> +#include <boost/random/mersenne_twister.hpp> +#include <boost/random/uniform_int.hpp> + +template <class Clock> +struct stopwatch +{ + typedef typename Clock::duration duration; + stopwatch() + { + m_start = Clock::now(); + } + duration elapsed() + { + return Clock::now() - m_start; + } + void reset() + { + m_start = Clock::now(); + } + + private: + typename Clock::time_point m_start; +}; + +unsigned bits_wanted; // for integer types + +template <class T, int Type> +struct tester +{ + tester() + { + a.assign(500, 0); + for (int i = 0; i < 500; ++i) + { + b.push_back(generate_random()); + c.push_back(generate_random()); + small.push_back(gen()); + } + } + double test_add() + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] + c[i]; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_subtract() + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] - c[i]; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_add_int() + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] + 1; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_subtract_int() + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] - 1; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_multiply() + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned k = 0; k < b.size(); ++k) + a[k] = b[k] * c[k]; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_multiply_int() + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] * 3; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_divide() + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] / c[i] + b[i] / small[i]; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_divide_int() + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] / 3; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_str(const boost::mpl::false_&) + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < b.size(); ++i) + a[i] = boost::lexical_cast<T>(boost::lexical_cast<std::string>(b[i])); + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_str(const boost::mpl::true_&) + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < b.size(); ++i) + a[i].assign(b[i].str()); + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_str() + { + return test_str(boost::is_class<T>()); + } + // + // The following tests only work for integer types: + // + double test_mod() + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] % c[i] + b[i] % small[i]; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_mod_int() + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] % 254; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_or() + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] | c[i]; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_or_int() + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] | 234; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_and() + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] & c[i]; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_and_int() + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] & 234; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_xor() + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] ^ c[i]; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_xor_int() + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] ^ 234; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_complement() + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = ~b[i]; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_left_shift() + { + int max_shift = std::numeric_limits<T>::is_bounded ? std::numeric_limits<T>::digits : bits_wanted; + int shift = 0; + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] << (shift++ % max_shift); + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_right_shift() + { + int max_shift = 2 + std::numeric_limits<T>::is_bounded ? std::numeric_limits<T>::digits : bits_wanted; + int shift = 0; + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] >> (shift++) % max_shift; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_gcd() + { + using boost::integer::gcd; + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = gcd(b[i], c[i]); + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_powm() + { + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 25; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = powm(b[i], b[i] / 2, c[i]); + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + double test_construct() + { + std::allocator<T> a; + T* pt = a.allocate(1000); + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < 1000; ++i) + new (pt + i) T(); + for (unsigned i = 0; i < 1000; ++i) + a.destroy(pt + i); + } + double result = boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + a.deallocate(pt, 1000); + return result; + } + double test_construct_unsigned() + { + std::allocator<T> a; + T* pt = a.allocate(1000); + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < 1000; ++i) + new (pt + i) T(i); + for (unsigned i = 0; i < 1000; ++i) + a.destroy(pt + i); + } + double result = boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + a.deallocate(pt, 1000); + return result; + } + double test_construct_unsigned_ll() + { + std::allocator<T> a; + T* pt = a.allocate(1000); + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned long long j = 0; j < 1000; ++j) + new (pt + j) T(j); + for (unsigned j = 0; j < 1000; ++j) + a.destroy(pt + j); + } + double result = boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + a.deallocate(pt, 1000); + return result; + } + + // + // Hetero operations: + // + template <class U> + static U get_hetero_test_value(boost::mpl::false_ const&) + { + return U(2) / 3; + } + template <class U> + static U get_hetero_test_value(boost::mpl::true_ const&) + { + return (std::numeric_limits<U>::max)() >> 4; + } + template <class U> + static U get_hetero_test_value() + { + return get_hetero_test_value<U>(boost::is_integral<U>()); + } + template <class U> + double test_multiply_hetero() + { + static const U val = get_hetero_test_value<U>(); + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] * val; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + template <class U> + double test_inplace_multiply_hetero() + { + static const U val = get_hetero_test_value<U>(); + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i]; + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] *= val; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + template <class U> + double test_add_hetero() + { + static const U val = get_hetero_test_value<U>(); + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] + val; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + template <class U> + double test_inplace_add_hetero() + { + static const U val = get_hetero_test_value<U>(); + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i]; + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] += val; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + template <class U> + double test_subtract_hetero() + { + static const U val = get_hetero_test_value<U>(); + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] - val; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + template <class U> + double test_inplace_subtract_hetero() + { + static const U val = get_hetero_test_value<U>(); + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i]; + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] -= val; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + template <class U> + double test_divide_hetero() + { + static const U val = get_hetero_test_value<U>(); + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i] / val; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + template <class U> + double test_inplace_divide_hetero() + { + static const U val = get_hetero_test_value<U>(); + for (unsigned i = 0; i < b.size(); ++i) + a[i] = b[i]; + stopwatch<boost::chrono::high_resolution_clock> w; + for (unsigned i = 0; i < 1000; ++i) + { + for (unsigned i = 0; i < b.size(); ++i) + a[i] /= val; + } + return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + } + + private: + T generate_random() + { + return generate_random(boost::mpl::int_<Type>()); + } + T generate_random(const boost::mpl::int_<boost::multiprecision::number_kind_floating_point>&) + { + T val = gen(); + T prev_val = -1; + while (val != prev_val) + { + val *= (gen.max)(); + prev_val = val; + val += gen(); + } + int e; + val = frexp(val, &e); + + typedef typename T::backend_type::exponent_type e_type; + static boost::random::uniform_int_distribution<e_type> ui(-30, 30); + return ldexp(val, static_cast<int>(ui(gen))); + } + T generate_random(const boost::mpl::int_<boost::multiprecision::number_kind_integer>&) + { + typedef boost::random::mt19937::result_type random_type; + + T max_val; + unsigned digits; + if (std::numeric_limits<T>::is_bounded) + { + max_val = (std::numeric_limits<T>::max)(); + digits = std::numeric_limits<T>::digits; + } + else + { + max_val = T(1) << bits_wanted; + digits = bits_wanted; + } + + unsigned bits_per_r_val = std::numeric_limits<random_type>::digits - 1; + while ((random_type(1) << bits_per_r_val) > (gen.max)()) + --bits_per_r_val; + + unsigned terms_needed = digits / bits_per_r_val + 1; + + T val = 0; + for (unsigned i = 0; i < terms_needed; ++i) + { + val *= (gen.max)(); + val += gen(); + } + val %= max_val; + return val; + } + T generate_random(const boost::mpl::int_<boost::multiprecision::number_kind_rational>&) + { + typedef boost::random::mt19937::result_type random_type; + typedef typename boost::multiprecision::component_type<T>::type IntType; + + IntType max_val; + unsigned digits; + if (std::numeric_limits<IntType>::is_bounded) + { + max_val = (std::numeric_limits<IntType>::max)(); + digits = std::numeric_limits<IntType>::digits; + } + else + { + max_val = IntType(1) << bits_wanted; + digits = bits_wanted; + } + + unsigned bits_per_r_val = std::numeric_limits<random_type>::digits - 1; + while ((random_type(1) << bits_per_r_val) > (gen.max)()) + --bits_per_r_val; + + unsigned terms_needed = digits / bits_per_r_val + 1; + + IntType val = 0; + IntType denom = 0; + for (unsigned i = 0; i < terms_needed; ++i) + { + val *= (gen.max)(); + val += gen(); + } + for (unsigned i = 0; i < terms_needed; ++i) + { + denom *= (gen.max)(); + denom += gen(); + } + if (denom == 0) + denom = 1; + val %= max_val; + denom %= max_val; + return T(val, denom); + } + std::vector<T> a, b, c, small; + static boost::random::mt19937 gen; +}; + +template <class N, int V> +boost::random::mt19937 tester<N, V>::gen; + +const char* category_name(const boost::mpl::int_<boost::multiprecision::number_kind_integer>&) +{ + return "integer"; +} +const char* category_name(const boost::mpl::int_<boost::multiprecision::number_kind_floating_point>&) +{ + return "float"; +} +const char* category_name(const boost::mpl::int_<boost::multiprecision::number_kind_rational>&) +{ + return "rational"; +} + +// +// Keys in order are: +// Category +// Operator +// Type +// Precision +// Time +// +std::map<std::string, std::map<std::string, std::map<std::string, std::map<int, double> > > > result_table; + +void report_result(const char* cat, const char* type, const char* op, unsigned precision, double time) +{ + std::cout << std::left << std::setw(15) << type << std::setw(10) << precision << std::setw(35) << op << time << std::endl; + result_table[cat][op][type][precision] = time; +} + +template <class Number, int N> +void test_int_ops(tester<Number, N>& t, const char* type, unsigned precision, const boost::mpl::int_<boost::multiprecision::number_kind_integer>&) +{ + const char* cat = "integer"; + report_result(cat, type, "%", precision, t.test_mod()); + report_result(cat, type, "|", precision, t.test_or()); + report_result(cat, type, "&", precision, t.test_and()); + report_result(cat, type, "^", precision, t.test_xor()); + //report_result(cat, type, "~", precision, t.test_complement()); + report_result(cat, type, "<<", precision, t.test_left_shift()); + report_result(cat, type, ">>", precision, t.test_right_shift()); + // integer ops: + report_result(cat, type, "%(int)", precision, t.test_mod_int()); + report_result(cat, type, "|(int)", precision, t.test_or_int()); + report_result(cat, type, "&(int)", precision, t.test_and_int()); + report_result(cat, type, "^(int)", precision, t.test_xor_int()); + report_result(cat, type, "gcd", precision, t.test_gcd()); + report_result(cat, type, "powm", precision, t.test_powm()); +} +template <class Number, int N, class U> +void test_int_ops(tester<Number, N>& t, const char* type, unsigned precision, const U&) +{ +} + +template <class Number> +void test(const char* type, unsigned precision) +{ + bits_wanted = precision; + tester<Number, boost::multiprecision::number_category<Number>::value> t; + const char* cat = category_name(typename boost::multiprecision::number_category<Number>::type()); + // + // call t.test_multiply() first so that the destination operands are + // forced to perform whatever memory allocation may be needed. That way + // we measure only algorithm performance, and not memory allocation effects. + // + t.test_multiply(); + // + // Now the actual tests: + // + report_result(cat, type, "+", precision, t.test_add()); + report_result(cat, type, "-", precision, t.test_subtract()); + report_result(cat, type, "*", precision, t.test_multiply()); + report_result(cat, type, "/", precision, t.test_divide()); + report_result(cat, type, "str", precision, t.test_str()); + // integer ops: + report_result(cat, type, "+(int)", precision, t.test_add_int()); + report_result(cat, type, "-(int)", precision, t.test_subtract_int()); + report_result(cat, type, "*(int)", precision, t.test_multiply_int()); + report_result(cat, type, "/(int)", precision, t.test_divide_int()); + // construction and destruction: + report_result(cat, type, "construct", precision, t.test_construct()); + report_result(cat, type, "construct(unsigned)", precision, t.test_construct_unsigned()); + report_result(cat, type, "construct(unsigned long long)", precision, t.test_construct_unsigned_ll()); + test_int_ops(t, type, precision, typename boost::multiprecision::number_category<Number>::type()); + // Hetero ops: + report_result(cat, type, "+(unsigned long long)", precision, t.template test_add_hetero<unsigned long long>()); + report_result(cat, type, "-(unsigned long long)", precision, t.template test_subtract_hetero<unsigned long long>()); + report_result(cat, type, "*(unsigned long long)", precision, t.template test_multiply_hetero<unsigned long long>()); + report_result(cat, type, "/(unsigned long long)", precision, t.template test_divide_hetero<unsigned long long>()); + report_result(cat, type, "+=(unsigned long long)", precision, t.template test_inplace_add_hetero<unsigned long long>()); + report_result(cat, type, "-=(unsigned long long)", precision, t.template test_inplace_subtract_hetero<unsigned long long>()); + report_result(cat, type, "*=(unsigned long long)", precision, t.template test_inplace_multiply_hetero<unsigned long long>()); + report_result(cat, type, "/=(unsigned long long)", precision, t.template test_inplace_divide_hetero<unsigned long long>()); +} + +void quickbook_results() +{ + // + // Keys in order are: + // Category + // Operator + // Type + // Precision + // Time + // + typedef std::map<std::string, std::map<std::string, std::map<std::string, std::map<int, double> > > >::const_iterator category_iterator; + typedef std::map<std::string, std::map<std::string, std::map<int, double> > >::const_iterator operator_iterator; + typedef std::map<std::string, std::map<int, double> >::const_iterator type_iterator; + typedef std::map<int, double>::const_iterator precision_iterator; + + for (category_iterator i = result_table.begin(); i != result_table.end(); ++i) + { + std::string cat = i->first; + cat[0] = std::toupper(cat[0]); + std::cout << "[section:" << i->first << "_performance " << cat << " Type Perfomance]" << std::endl; + + for (operator_iterator j = i->second.begin(); j != i->second.end(); ++j) + { + std::string op = j->first; + std::cout << "[table Operator " << op << std::endl; + std::cout << "[[Backend]"; + + for (precision_iterator k = j->second.begin()->second.begin(); k != j->second.begin()->second.end(); ++k) + { + std::cout << "[" << k->first << " Bits]"; + } + std::cout << "]\n"; + + std::vector<double> best_times(j->second.begin()->second.size(), (std::numeric_limits<double>::max)()); + for (unsigned m = 0; m < j->second.begin()->second.size(); ++m) + { + for (type_iterator k = j->second.begin(); k != j->second.end(); ++k) + { + precision_iterator l = k->second.begin(); + std::advance(l, m); + if (best_times[m] > l->second) + best_times[m] = l->second ? l->second : best_times[m]; + } + } + + for (type_iterator k = j->second.begin(); k != j->second.end(); ++k) + { + std::cout << "[[" << k->first << "]"; + + unsigned m = 0; + for (precision_iterator l = k->second.begin(); l != k->second.end(); ++l) + { + double rel_time = l->second / best_times[m]; + if (rel_time == 1) + std::cout << "[[*" << rel_time << "]"; + else + std::cout << "[" << rel_time; + std::cout << " (" << l->second << "s)]"; + ++m; + } + + std::cout << "]\n"; + } + + std::cout << "]\n"; + } + + std::cout << "[endsect]" << std::endl; + } +} + +int main() +{ +#ifdef TEST_INT64 + test<boost::uint64_t>("boost::uint64_t", 64); +#endif +#ifdef TEST_MPF + test<boost::multiprecision::mpf_float_50>("gmp_float", 50); + test<boost::multiprecision::mpf_float_100>("gmp_float", 100); + test<boost::multiprecision::mpf_float_500>("gmp_float", 500); +#endif +#ifdef TEST_MPZ + test<boost::multiprecision::mpz_int>("gmp_int", 128); + test<boost::multiprecision::mpz_int>("gmp_int", 256); + test<boost::multiprecision::mpz_int>("gmp_int", 512); + test<boost::multiprecision::mpz_int>("gmp_int", 1024); +#endif +#ifdef TEST_CPP_INT + //test<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<64, 64, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>, boost::multiprecision::et_off> >("cpp_int(unsigned, fixed)", 64); + //test<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<64, 64, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void>, boost::multiprecision::et_off> >("cpp_int(fixed)", 64); + test<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<128, 128, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void>, boost::multiprecision::et_off> >("cpp_int(fixed)", 128); + test<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<256, 256, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void>, boost::multiprecision::et_off> >("cpp_int(fixed)", 256); + test<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<512, 512, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void>, boost::multiprecision::et_off> >("cpp_int(fixed)", 512); + test<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<1024, 1024, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void>, boost::multiprecision::et_off> >("cpp_int(fixed)", 1024); + + test<boost::multiprecision::cpp_int>("cpp_int", 128); + test<boost::multiprecision::cpp_int>("cpp_int", 256); + test<boost::multiprecision::cpp_int>("cpp_int", 512); + test<boost::multiprecision::cpp_int>("cpp_int", 1024); +#endif +#ifdef TEST_CPP_INT_RATIONAL + test<boost::multiprecision::cpp_rational>("cpp_rational", 128); + test<boost::multiprecision::cpp_rational>("cpp_rational", 256); + test<boost::multiprecision::cpp_rational>("cpp_rational", 512); + test<boost::multiprecision::cpp_rational>("cpp_rational", 1024); +#endif +#ifdef TEST_MPQ + test<boost::multiprecision::mpq_rational>("mpq_rational", 128); + test<boost::multiprecision::mpq_rational>("mpq_rational", 256); + test<boost::multiprecision::mpq_rational>("mpq_rational", 512); + test<boost::multiprecision::mpq_rational>("mpq_rational", 1024); +#endif +#ifdef TEST_TOMMATH + test<boost::multiprecision::tom_int>("tommath_int", 128); + test<boost::multiprecision::tom_int>("tommath_int", 256); + test<boost::multiprecision::tom_int>("tommath_int", 512); + test<boost::multiprecision::tom_int>("tommath_int", 1024); + /* + // + // These are actually too slow to test!!! + // + test<boost::multiprecision::tom_rational>("tom_rational", 128); + test<boost::multiprecision::tom_rational>("tom_rational", 256); + test<boost::multiprecision::tom_rational>("tom_rational", 512); + test<boost::multiprecision::tom_rational>("tom_rational", 1024); + */ +#endif +#ifdef TEST_CPP_DEC_FLOAT + test<boost::multiprecision::cpp_dec_float_50>("cpp_dec_float", 50); + test<boost::multiprecision::cpp_dec_float_100>("cpp_dec_float", 100); + test<boost::multiprecision::number<boost::multiprecision::cpp_dec_float<500> > >("cpp_dec_float", 500); +#endif +#ifdef TEST_CPP_BIN_FLOAT + test<boost::multiprecision::cpp_bin_float_50>("cpp_bin_float", 50); + test<boost::multiprecision::cpp_bin_float_100>("cpp_bin_float", 100); + test<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<500> > >("cpp_bin_float", 500); +#endif +#ifdef TEST_MPFR + test<boost::multiprecision::mpfr_float_50>("mpfr_float", 50); + test<boost::multiprecision::mpfr_float_100>("mpfr_float", 100); + test<boost::multiprecision::mpfr_float_500>("mpfr_float", 500); +#endif + quickbook_results(); + return 0; +} diff --git a/src/boost/libs/multiprecision/performance/sf_performance-msvc-10.log b/src/boost/libs/multiprecision/performance/sf_performance-msvc-10.log new file mode 100644 index 00000000..9dc8de7b --- /dev/null +++ b/src/boost/libs/multiprecision/performance/sf_performance-msvc-10.log @@ -0,0 +1,69 @@ +0 +11 +24 +3 +13 +27 +Testing Bessel Functions..... +Time for mpfr_float_50 = 6.47208 seconds +Total allocations for mpfr_float_50 = 2684348 +Time for mpf_float_50 = 11.6627 seconds +Total allocations for mpf_float_50 = 2601366 +Time for cpp_float_50 = 20.2855 seconds +Total allocations for cpp_float_50 = 0 +Time for mpfr_class (50 digits) = 6.48063 seconds +Total allocations for mpfr_class (50 digits) = 3946031 +Time for mpreal (50 digits) = 9.98151 seconds +Total allocations for mpreal (50 digits) = 13223017 +Time for mpfr_float_100 = 10.154 seconds +Total allocations for mpfr_float_50 = 3671485 +Time for mpf_float_100 = 8.51179 seconds +Total allocations for mpf_float_100 = 3593669 +Time for cpp_float_100 = 21.0198 seconds +Total allocations for cpp_float_100 = 0 +Time for mpfr_class (100 digits) = 9.80571 seconds +Total allocations for mpfr_class (100 digits) = 5447348 +Time for mpreal (100 digits) = 13.7021 seconds +Total allocations for mpreal (100 digits) = 16671065 +Testing Polynomial Evaluation..... +Time for mpfr_float_50 = 0.00823841 seconds +Total allocations for mpfr_float_50 = 2996 +Time for mpf_float_50 = 0.00401608 seconds +Total allocations for mpf_float_50 = 2996 +Time for cpp_float_50 = 0.00492116 seconds +Total allocations for cpp_float_50 = 0 +Time for mpfr_class (50 digits) = 0.00935629 seconds +Total allocations for mpfr_class (50 digits) = 12976 +Time for mpreal (50 digits) = 0.0148374 seconds +Total allocations for mpreal (50 digits = 27947 +Time for mpfr_float_100 = 0.00948452 seconds +Total allocations for mpfr_float_100 = 2996 +Time for mpf_float_100 = 0.00390071 seconds +Total allocations for mpf_float_100 = 2996 +Time for cpp_float_100 = 0.00893563 seconds +Total allocations for cpp_float_100 = 0 +Time for mpfr_class (100 digits) = 0.0106166 seconds +Total allocations for mpfr_class (100 digits) = 12976 +Time for mpreal (100 digits) = 0.0162364 seconds +Total allocations for mpreal (100 digits) = 27947 +Testing Non-Central T..... +Time for mpfr_float_50 = 258.087 seconds +Total allocations for mpfr_float_50 = 139149049 +Time for mpf_float_50 = 197.303 seconds +Total allocations for mpf_float_50 = 134600354 +Time for cpp_float_50 = 334.503 seconds +Total allocations for cpp_float_50 = 0 +Time for mpfr_class (50 digits) = 266.389 seconds +Total allocations for mpfr_class (50 digits) = 252401115 +Time for mpreal (50 digits) = 346.641 seconds +Total allocations for mpreal (50 digits) = 447009420 +Time for mpfr_float_100 = 516.741 seconds +Total allocations for mpfr_float_100 = 220400854 +Time for mpf_float_100 = 397.302 seconds +Total allocations for mpf_float_100 = 212307349 +Time for cpp_float_100 = 1064.53 seconds +Total allocations for cpp_float_100 = 0 +Time for mpfr_class (100 digits) = 525.74 seconds +Total allocations for mpfr_class (100 digits) = 407154781 +Time for mpreal (100 digits) = 649.941 seconds +Total allocations for mpreal (100 digits) = 724581024 diff --git a/src/boost/libs/multiprecision/performance/sf_performance.cpp b/src/boost/libs/multiprecision/performance/sf_performance.cpp new file mode 100644 index 00000000..cfd2360c --- /dev/null +++ b/src/boost/libs/multiprecision/performance/sf_performance.cpp @@ -0,0 +1,44 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2011 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#include "sf_performance.hpp" + +unsigned allocation_count = 0; + +void* (*alloc_func_ptr)(size_t); +void* (*realloc_func_ptr)(void*, size_t, size_t); +void (*free_func_ptr)(void*, size_t); + +void* alloc_func(size_t n) +{ + ++allocation_count; + return (*alloc_func_ptr)(n); +} + +void free_func(void* p, size_t n) +{ + (*free_func_ptr)(p, n); +} + +void* realloc_func(void* p, size_t old, size_t n) +{ + ++allocation_count; + return (*realloc_func_ptr)(p, old, n); +} + +int main() +{ + using namespace boost::multiprecision; + +#if defined(TEST_MPFR) || defined(TEST_MPFR_CLASS) || defined(TEST_MPREAL) || defined(TEST_MPF) + mp_get_memory_functions(&alloc_func_ptr, &realloc_func_ptr, &free_func_ptr); + mp_set_memory_functions(&alloc_func, &realloc_func, &free_func); +#endif + + basic_tests(); + bessel_tests(); + poly_tests(); + nct_tests(); +} diff --git a/src/boost/libs/multiprecision/performance/sf_performance.hpp b/src/boost/libs/multiprecision/performance/sf_performance.hpp new file mode 100644 index 00000000..ce34f1b6 --- /dev/null +++ b/src/boost/libs/multiprecision/performance/sf_performance.hpp @@ -0,0 +1,216 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2011 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#define BOOST_MATH_MAX_ROOT_ITERATION_POLICY 750 +#define BOOST_MATH_PROMOTE_DOUBLE_POLICY false + +#if !defined(TEST_MPFR) && !defined(TEST_MPREAL) && !defined(TEST_MPF) && !defined(TEST_MPREAL) && !defined(TEST_CPP_DEC_FLOAT) && !defined(TEST_MPFR_CLASS) && !defined(TEST_FLOAT) && !defined(TEST_CPP_BIN_FLOAT) +#define TEST_MPFR +#define TEST_MPF +#define TEST_CPP_DEC_FLOAT +#define TEST_CPP_BIN_FLOAT +//# define TEST_MPFR_CLASS +//# define TEST_MPREAL +#define TEST_FLOAT +#endif + +#ifdef TEST_FLOAT +#include "arithmetic_backend.hpp" +#endif +#ifdef TEST_MPFR_CLASS +#include <boost/math/bindings/mpfr.hpp> +#endif +#ifdef TEST_MPFR +#include <boost/multiprecision/mpfr.hpp> +#endif +#ifdef TEST_MPREAL +#include <boost/math/bindings/mpreal.hpp> +#endif +#ifdef TEST_MPF +#include <boost/multiprecision/gmp.hpp> +#endif +#ifdef TEST_CPP_DEC_FLOAT +#include <boost/multiprecision/cpp_dec_float.hpp> +#endif +#ifdef TEST_CPP_BIN_FLOAT +#include <boost/multiprecision/cpp_bin_float.hpp> +#include <boost/multiprecision/mpfr.hpp> +#endif +#include <boost/math/special_functions/bessel.hpp> +#include <boost/math/tools/rational.hpp> +#include <boost/math/distributions/non_central_t.hpp> +#include <libs/math/test/table_type.hpp> +#include <boost/chrono.hpp> +#include <boost/array.hpp> +#include <boost/thread.hpp> + +template <class Real> +Real test_bessel(); + +template <class Clock> +struct stopwatch +{ + typedef typename Clock::duration duration; + stopwatch() + { + m_start = Clock::now(); + } + duration elapsed() + { + return Clock::now() - m_start; + } + void reset() + { + m_start = Clock::now(); + } + + private: + typename Clock::time_point m_start; +}; + +template <class Real> +Real test_bessel() +{ + try + { +#define T double +#define SC_(x) x +#include "libs/math/test/bessel_i_int_data.ipp" +#include "libs/math/test/bessel_i_data.ipp" + + Real r; + + for (unsigned i = 0; i < bessel_i_int_data.size(); ++i) + { + r += boost::math::cyl_bessel_i(Real(bessel_i_int_data[i][0]), Real(bessel_i_int_data[i][1])); + } + for (unsigned i = 0; i < bessel_i_data.size(); ++i) + { + r += boost::math::cyl_bessel_i(Real(bessel_i_data[i][0]), Real(bessel_i_data[i][1])); + } + +#include "libs/math/test/bessel_j_int_data.ipp" + for (unsigned i = 0; i < bessel_j_int_data.size(); ++i) + { + r += boost::math::cyl_bessel_j(Real(bessel_j_int_data[i][0]), Real(bessel_j_int_data[i][1])); + } + +#include "libs/math/test/bessel_j_data.ipp" + for (unsigned i = 0; i < bessel_j_data.size(); ++i) + { + r += boost::math::cyl_bessel_j(Real(bessel_j_data[i][0]), Real(bessel_j_data[i][1])); + } + +#include "libs/math/test/bessel_j_large_data.ipp" + for (unsigned i = 0; i < bessel_j_large_data.size(); ++i) + { + r += boost::math::cyl_bessel_j(Real(bessel_j_large_data[i][0]), Real(bessel_j_large_data[i][1])); + } + +#include "libs/math/test/sph_bessel_data.ipp" + for (unsigned i = 0; i < sph_bessel_data.size(); ++i) + { + r += boost::math::sph_bessel(static_cast<unsigned>(sph_bessel_data[i][0]), Real(sph_bessel_data[i][1])); + } + + return r; + } + catch (const std::exception& e) + { + std::cout << e.what() << std::endl; + } + return 0; +} + +template <class Real> +Real test_polynomial() +{ + static const unsigned t[] = { + 2, 3, 4, 5, 6, 7, 8}; + Real result = 0; + for (Real k = 2; k < 1000; ++k) + result += boost::math::tools::evaluate_polynomial(t, k); + + return result; +} + +template <class Real> +Real test_nct() +{ +#define T double +#include "libs/math/test/nct.ipp" + + Real result = 0; + for (unsigned i = 0; i < nct.size(); ++i) + { + try + { + result += quantile(boost::math::non_central_t_distribution<Real>(nct[i][0], nct[i][1]), nct[i][3]); + result += cdf(boost::math::non_central_t_distribution<Real>(nct[i][0], nct[i][1]), nct[i][2]); + } + catch (const std::exception&) + {} + } + return result; +} + +extern unsigned allocation_count; + +template <class Real> +void basic_allocation_test(const char* name, Real x) +{ + static const unsigned a[] = {2, 3, 4, 5, 6, 7, 8}; + allocation_count = 0; + Real result = (((((a[6] * x + a[5]) * x + a[4]) * x + a[3]) * x + a[2]) * x + a[1]) * x + a[0]; + std::cout << "Allocation count for type " << name << " = " << allocation_count << std::endl; +} + +template <class Real> +void poly_allocation_test(const char* name, Real x) +{ + static const unsigned a[] = {2, 3, 4, 5, 6, 7, 8}; + allocation_count = 0; + Real result = boost::math::tools::evaluate_polynomial(a, x); + std::cout << "Allocation count for type " << name << " = " << allocation_count << std::endl; +} + +template <class Real> +void time_proc(const char* name, Real (*proc)(), unsigned threads = 1) +{ + try + { + static Real total = 0; + allocation_count = 0; + boost::chrono::duration<double> time; + stopwatch<boost::chrono::high_resolution_clock> c; + total += proc(); + time = c.elapsed(); + std::cout << "Time for " << name << " = " << time << std::endl; + std::cout << "Total allocations for " << name << " = " << allocation_count << std::endl; + + for (unsigned thread_count = 1; thread_count < threads; ++thread_count) + { + c.reset(); + boost::thread_group g; + for (unsigned i = 0; i <= thread_count; ++i) + g.create_thread(proc); + g.join_all(); + time = c.elapsed(); + std::cout << "Time for " << name << " (" << (thread_count + 1) << " threads) = " << time << std::endl; + std::cout << "Total allocations for " << name << " = " << allocation_count << std::endl; + } + } + catch (const std::exception& e) + { + std::cout << e.what() << std::endl; + } +} + +using namespace boost::multiprecision; + +void basic_tests(); +void bessel_tests(); +void poly_tests(); +void nct_tests(); diff --git a/src/boost/libs/multiprecision/performance/sf_performance_basic.cpp b/src/boost/libs/multiprecision/performance/sf_performance_basic.cpp new file mode 100644 index 00000000..51436d98 --- /dev/null +++ b/src/boost/libs/multiprecision/performance/sf_performance_basic.cpp @@ -0,0 +1,49 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2011 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#include "sf_performance.hpp" + +void basic_tests() +{ + + std::cout << "Allocation Counts for Horner Evaluation:\n"; +#ifdef TEST_MPFR + basic_allocation_test("mpfr_float_50", mpfr_float_50(2)); + basic_allocation_test("mpfr_float_50 - no expression templates", number<mpfr_float_backend<50>, et_off>(2)); +#endif +#ifdef TEST_MPFR_CLASS + basic_allocation_test("mpfr_class", mpfr_class(2)); +#endif +#ifdef TEST_MPREAL + basic_allocation_test("mpfr::mpreal", mpfr::mpreal(2)); +#endif + + std::cout << "Allocation Counts for boost::math::tools::evaluate_polynomial:\n"; +#ifdef TEST_MPFR + poly_allocation_test("mpfr_float_50", mpfr_float_50(2)); + poly_allocation_test("mpfr_float_50 - no expression templates", number<mpfr_float_backend<50>, et_off>(2)); +#endif +#ifdef TEST_MPFR_CLASS + poly_allocation_test("mpfr_class", mpfr_class(2)); +#endif +#ifdef TEST_MPREAL + poly_allocation_test("mpfr::mpreal", mpfr::mpreal(2)); +#endif + + // + // Comparison for builtin floats: + // +#ifdef TEST_FLOAT + time_proc("Bessel Functions - double", test_bessel<double>); + time_proc("Bessel Functions - real_concept", test_bessel<boost::math::concepts::real_concept>); + time_proc("Bessel Functions - arithmetic_backend<double>", test_bessel<number<arithmetic_backend<double>, et_on> >); + time_proc("Bessel Functions - arithmetic_backend<double> - no expression templates", test_bessel<number<arithmetic_backend<double>, et_off> >); + + time_proc("Non-central T - double", test_nct<double>); + time_proc("Non-central T - real_concept", test_nct<boost::math::concepts::real_concept>); + time_proc("Non-central T - arithmetic_backend<double>", test_nct<number<arithmetic_backend<double>, et_on> >); + time_proc("Non-central T - arithmetic_backend<double> - no expression templates", test_nct<number<arithmetic_backend<double>, et_off> >); +#endif +} diff --git a/src/boost/libs/multiprecision/performance/sf_performance_bessel.cpp b/src/boost/libs/multiprecision/performance/sf_performance_bessel.cpp new file mode 100644 index 00000000..97a9b476 --- /dev/null +++ b/src/boost/libs/multiprecision/performance/sf_performance_bessel.cpp @@ -0,0 +1,42 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2011 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#include "sf_performance.hpp" + +void bessel_tests_1(); +void bessel_tests_2(); +void bessel_tests_3(); +void bessel_tests_4(); +void bessel_tests_5(); +void bessel_tests_6(); + +void bessel_tests() +{ + // + // 50 digits first: + // + std::cout << "Testing Bessel Functions at 50 digits....." << std::endl; +#if defined(TEST_MPFR) || defined(TEST_MPFR_CLASS) + mpfr_set_default_prec(50 * 1000L / 301L); +#endif +#ifdef TEST_MPREAL + mpfr::mpreal::set_default_prec(50 * 1000L / 301L); +#endif + + bessel_tests_1(); + bessel_tests_2(); + bessel_tests_3(); + + // + // Then 100 digits: + // + std::cout << "Testing Bessel Functions at 100 digits....." << std::endl; +#if defined(TEST_MPFR) || defined(TEST_MPFR_CLASS) + mpfr_set_default_prec(100 * 1000L / 301L); +#endif + bessel_tests_4(); + bessel_tests_5(); + bessel_tests_6(); +} diff --git a/src/boost/libs/multiprecision/performance/sf_performance_bessel1.cpp b/src/boost/libs/multiprecision/performance/sf_performance_bessel1.cpp new file mode 100644 index 00000000..476d8f38 --- /dev/null +++ b/src/boost/libs/multiprecision/performance/sf_performance_bessel1.cpp @@ -0,0 +1,23 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2011 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#include "sf_performance.hpp" + +void bessel_tests_1() +{ +#ifdef TEST_MPFR +#if MPFR_VERSION < MPFR_VERSION_NUM(3, 0, 0) + time_proc("mpfr_float_50", test_bessel<boost::multiprecision::mpfr_float_50>, 1); + time_proc("mpfr_float_50 (no expression templates)", test_bessel<number<mpfr_float_backend<50>, et_off> >, 1); + time_proc("static_mpfr_float_50", test_bessel<number<mpfr_float_backend<50, allocate_stack>, et_on> >, 1); + time_proc("static_mpfr_float_50 (no expression templates)", test_bessel<number<mpfr_float_backend<50, allocate_stack>, et_off> >, 1); +#else + time_proc("mpfr_float_50", test_bessel<boost::multiprecision::mpfr_float_50>, mpfr_buildopt_tls_p() ? 3 : 1); + time_proc("mpfr_float_50 (no expression templates", test_bessel<number<mpfr_float_backend<50>, et_off> >, mpfr_buildopt_tls_p() ? 3 : 1); + time_proc("static_mpfr_float_50", test_bessel<number<mpfr_float_backend<50, allocate_stack>, et_on> >, mpfr_buildopt_tls_p() ? 3 : 1); + time_proc("static_mpfr_float_50 (no expression templates)", test_bessel<number<mpfr_float_backend<50, allocate_stack>, et_off> >, mpfr_buildopt_tls_p() ? 3 : 1); +#endif +#endif +} diff --git a/src/boost/libs/multiprecision/performance/sf_performance_bessel2.cpp b/src/boost/libs/multiprecision/performance/sf_performance_bessel2.cpp new file mode 100644 index 00000000..19f76b5f --- /dev/null +++ b/src/boost/libs/multiprecision/performance/sf_performance_bessel2.cpp @@ -0,0 +1,20 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2011 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#include "sf_performance.hpp" + +void bessel_tests_2() +{ +#ifdef TEST_MPF + time_proc("mpf_float_50", test_bessel<mpf_float_50>, 3); + time_proc("mpf_float_50 (no expression templates", test_bessel<number<gmp_float<50>, et_off> >, 3); +#endif +#ifdef TEST_CPP_DEC_FLOAT + time_proc("cpp_dec_float_50", test_bessel<cpp_dec_float_50>, 3); +#endif +#ifdef TEST_CPP_BIN_FLOAT + time_proc("cpp_bin_float_50", test_bessel<cpp_bin_float_50>, 3); +#endif +} diff --git a/src/boost/libs/multiprecision/performance/sf_performance_bessel3.cpp b/src/boost/libs/multiprecision/performance/sf_performance_bessel3.cpp new file mode 100644 index 00000000..04d918d0 --- /dev/null +++ b/src/boost/libs/multiprecision/performance/sf_performance_bessel3.cpp @@ -0,0 +1,16 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2011 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#include "sf_performance.hpp" + +void bessel_tests_3() +{ +#ifdef TEST_MPFR_CLASS + time_proc("mpfr_class", test_bessel<mpfr_class>, mpfr_buildopt_tls_p() ? 3 : 1); +#endif +#ifdef TEST_MPREAL + time_proc("mpfr::mpreal", test_bessel<mpfr::mpreal>, mpfr_buildopt_tls_p() ? 3 : 1); +#endif +} diff --git a/src/boost/libs/multiprecision/performance/sf_performance_bessel4.cpp b/src/boost/libs/multiprecision/performance/sf_performance_bessel4.cpp new file mode 100644 index 00000000..cbb9ec95 --- /dev/null +++ b/src/boost/libs/multiprecision/performance/sf_performance_bessel4.cpp @@ -0,0 +1,15 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2011 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#include "sf_performance.hpp" + +void bessel_tests_4() +{ +#ifdef TEST_MPFR + time_proc("mpfr_float_100", test_bessel<mpfr_float_100>); + time_proc("mpfr_float_100 (no expression templates", test_bessel<number<mpfr_float_backend<100>, et_off> >); + time_proc("static_mpfr_float_100", test_bessel<static_mpfr_float_100>); +#endif +} diff --git a/src/boost/libs/multiprecision/performance/sf_performance_bessel5.cpp b/src/boost/libs/multiprecision/performance/sf_performance_bessel5.cpp new file mode 100644 index 00000000..b22c2408 --- /dev/null +++ b/src/boost/libs/multiprecision/performance/sf_performance_bessel5.cpp @@ -0,0 +1,17 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2011 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#include "sf_performance.hpp" + +void bessel_tests_5() +{ +#ifdef TEST_MPREAL + mpfr::mpreal::set_default_prec(100 * 1000L / 301L); +#endif +#ifdef TEST_MPF + time_proc("mpf_float_100", test_bessel<mpf_float_100>); + time_proc("mpf_float_100 (no expression templates", test_bessel<number<gmp_float<100>, et_off> >); +#endif +} diff --git a/src/boost/libs/multiprecision/performance/sf_performance_bessel6.cpp b/src/boost/libs/multiprecision/performance/sf_performance_bessel6.cpp new file mode 100644 index 00000000..f3605c7c --- /dev/null +++ b/src/boost/libs/multiprecision/performance/sf_performance_bessel6.cpp @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2011 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#include "sf_performance.hpp" + +void bessel_tests_6() +{ +#ifdef TEST_CPP_DEC_FLOAT + time_proc("cpp_dec_float_100", test_bessel<cpp_dec_float_100>); +#endif +#ifdef TEST_CPP_BIN_FLOAT + time_proc("cpp_bin_float_100", test_bessel<cpp_bin_float_100>); +#endif +#ifdef TEST_MPFR_CLASS + time_proc("mpfr_class", test_bessel<mpfr_class>); +#endif +#ifdef TEST_MPREAL + time_proc("mpfr::mpreal", test_bessel<mpfr::mpreal>); +#endif +} diff --git a/src/boost/libs/multiprecision/performance/sf_performance_nct.cpp b/src/boost/libs/multiprecision/performance/sf_performance_nct.cpp new file mode 100644 index 00000000..4c5a00db --- /dev/null +++ b/src/boost/libs/multiprecision/performance/sf_performance_nct.cpp @@ -0,0 +1,39 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2011 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#include "sf_performance.hpp" + +void nct_tests_1(); +void nct_tests_2(); +void nct_tests_3(); +void nct_tests_4(); +void nct_tests_5(); +void nct_tests_6(); + +void nct_tests() +{ + // + // 50 digits first: + // + std::cout << "Testing Non-Central T at 50 digits....." << std::endl; +#ifdef TEST_MPFR_CLASS + mpfr_set_default_prec(50 * 1000L / 301L); +#endif + + nct_tests_1(); + nct_tests_2(); + nct_tests_3(); + + // + // Then 100 digits: + // + std::cout << "Testing Non-Central T at 100 digits....." << std::endl; +#ifdef TEST_MPFR_CLASS + mpfr_set_default_prec(100 * 1000L / 301L); +#endif + nct_tests_4(); + nct_tests_5(); + nct_tests_6(); +} diff --git a/src/boost/libs/multiprecision/performance/sf_performance_nct1.cpp b/src/boost/libs/multiprecision/performance/sf_performance_nct1.cpp new file mode 100644 index 00000000..4d12c8b2 --- /dev/null +++ b/src/boost/libs/multiprecision/performance/sf_performance_nct1.cpp @@ -0,0 +1,15 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2011 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#include "sf_performance.hpp" + +void nct_tests_1() +{ +#ifdef TEST_MPFR + time_proc("mpfr_float_50", test_nct<mpfr_float_50>); + time_proc("mpfr_float_50 (no expression templates", test_nct<number<mpfr_float_backend<50>, et_off> >); + time_proc("static_mpfr_float_50", test_nct<static_mpfr_float_50>); +#endif +} diff --git a/src/boost/libs/multiprecision/performance/sf_performance_nct2.cpp b/src/boost/libs/multiprecision/performance/sf_performance_nct2.cpp new file mode 100644 index 00000000..a52a029c --- /dev/null +++ b/src/boost/libs/multiprecision/performance/sf_performance_nct2.cpp @@ -0,0 +1,14 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2011 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#include "sf_performance.hpp" + +void nct_tests_2() +{ +#ifdef TEST_MPF + time_proc("mpf_float_50", test_nct<mpf_float_50>); + time_proc("mpf_float_50 (no expression templates", test_nct<number<gmp_float<50>, et_off> >); +#endif +} diff --git a/src/boost/libs/multiprecision/performance/sf_performance_nct3.cpp b/src/boost/libs/multiprecision/performance/sf_performance_nct3.cpp new file mode 100644 index 00000000..cc84ab1b --- /dev/null +++ b/src/boost/libs/multiprecision/performance/sf_performance_nct3.cpp @@ -0,0 +1,25 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2011 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#include "sf_performance.hpp" + +void nct_tests_3() +{ +#ifdef TEST_MPREAL + mpfr::mpreal::set_default_prec(50 * 1000L / 301L); +#endif +#ifdef TEST_CPP_DEC_FLOAT + time_proc("cpp_dec_float_50", test_nct<cpp_dec_float_50>); +#endif +#ifdef TEST_CPP_BIN_FLOAT + time_proc("cpp_bin_float_50", test_nct<cpp_bin_float_50>, 3); +#endif +#ifdef TEST_MPFR_CLASS + time_proc("mpfr_class", test_nct<mpfr_class>); +#endif +#ifdef TEST_MPREAL + time_proc("mpfr::mpreal", test_nct<mpfr::mpreal>); +#endif +} diff --git a/src/boost/libs/multiprecision/performance/sf_performance_nct4.cpp b/src/boost/libs/multiprecision/performance/sf_performance_nct4.cpp new file mode 100644 index 00000000..c23b0fd5 --- /dev/null +++ b/src/boost/libs/multiprecision/performance/sf_performance_nct4.cpp @@ -0,0 +1,15 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2011 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#include "sf_performance.hpp" + +void nct_tests_4() +{ +#ifdef TEST_MPFR + time_proc("mpfr_float_100", test_nct<mpfr_float_100>); + time_proc("mpfr_float_100 (no expression templates", test_nct<number<mpfr_float_backend<100>, et_off> >); + time_proc("static_mpfr_float_100", test_nct<static_mpfr_float_100>); +#endif +} diff --git a/src/boost/libs/multiprecision/performance/sf_performance_nct5.cpp b/src/boost/libs/multiprecision/performance/sf_performance_nct5.cpp new file mode 100644 index 00000000..676005a1 --- /dev/null +++ b/src/boost/libs/multiprecision/performance/sf_performance_nct5.cpp @@ -0,0 +1,14 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2011 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#include "sf_performance.hpp" + +void nct_tests_5() +{ +#ifdef TEST_MPF + time_proc("mpf_float_100", test_nct<mpf_float_100>); + time_proc("mpf_float_100 (no expression templates", test_nct<number<gmp_float<100>, et_off> >); +#endif +} diff --git a/src/boost/libs/multiprecision/performance/sf_performance_nct6.cpp b/src/boost/libs/multiprecision/performance/sf_performance_nct6.cpp new file mode 100644 index 00000000..cf3af1cf --- /dev/null +++ b/src/boost/libs/multiprecision/performance/sf_performance_nct6.cpp @@ -0,0 +1,25 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2011 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#include "sf_performance.hpp" + +void nct_tests_6() +{ +#ifdef TEST_MPREAL + mpfr::mpreal::set_default_prec(100 * 1000L / 301L); +#endif +#ifdef TEST_CPP_DEC_FLOAT + time_proc("cpp_dec_float_100", test_nct<cpp_dec_float_100>); +#endif +#ifdef TEST_CPP_BIN_FLOAT + time_proc("cpp_bin_float_100", test_nct<cpp_bin_float_100>); +#endif +#ifdef TEST_MPFR_CLASS + time_proc("mpfr_class", test_nct<mpfr_class>); +#endif +#ifdef TEST_MPREAL + time_proc("mpfr::mpreal", test_nct<mpfr::mpreal>); +#endif +} diff --git a/src/boost/libs/multiprecision/performance/sf_performance_poly.cpp b/src/boost/libs/multiprecision/performance/sf_performance_poly.cpp new file mode 100644 index 00000000..4c84c835 --- /dev/null +++ b/src/boost/libs/multiprecision/performance/sf_performance_poly.cpp @@ -0,0 +1,72 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2011 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#include "sf_performance.hpp" + +void poly_tests() +{ + // + // 50 digits first: + // + std::cout << "Testing Polynomial Evaluation at 50 digits....." << std::endl; +#if defined(TEST_MPFR) || defined(TEST_MPFR_CLASS) + mpfr_set_default_prec(50 * 1000L / 301L); +#endif +#ifdef TEST_MPREAL + mpfr::mpreal::set_default_prec(50 * 1000L / 301L); +#endif +#ifdef TEST_MPFR + time_proc("mpfr_float_50", test_polynomial<mpfr_float_50>); + time_proc("mpfr_float_50 (no expression templates", test_polynomial<number<mpfr_float_backend<50>, et_off> >); + time_proc("static_mpfr_float_50", test_polynomial<static_mpfr_float_50>); +#endif +#ifdef TEST_MPF + time_proc("mpf_float_50", test_polynomial<mpf_float_50>); + time_proc("mpf_float_50 (no expression templates", test_polynomial<number<gmp_float<50>, et_off> >); +#endif +#ifdef TEST_CPP_DEC_FLOAT + time_proc("cpp_dec_float_50", test_polynomial<cpp_dec_float_50>); +#endif +#ifdef TEST_CPP_BIN_FLOAT + time_proc("cpp_bin_float_50", test_polynomial<cpp_bin_float_50>); +#endif +#ifdef TEST_MPFR_CLASS + time_proc("mpfr_class", test_polynomial<mpfr_class>); +#endif +#ifdef TEST_MPREAL + time_proc("mpfr::mpreal", test_polynomial<mpfr::mpreal>); +#endif + // + // Then 100 digits: + // + std::cout << "Testing Polynomial Evaluation at 100 digits....." << std::endl; +#ifdef TEST_MPFR_CLASS + mpfr_set_default_prec(100 * 1000L / 301L); +#endif +#ifdef TEST_MPREAL + mpfr::mpreal::set_default_prec(100 * 1000L / 301L); +#endif +#ifdef TEST_MPFR + time_proc("mpfr_float_100", test_polynomial<mpfr_float_100>); + time_proc("mpfr_float_100 (no expression templates", test_polynomial<number<mpfr_float_backend<100>, et_off> >); + time_proc("static_mpfr_float_100", test_polynomial<static_mpfr_float_100>); +#endif +#ifdef TEST_MPF + time_proc("mpf_float_100", test_polynomial<mpf_float_100>); + time_proc("mpf_float_100 (no expression templates", test_polynomial<number<gmp_float<100>, et_off> >); +#endif +#ifdef TEST_CPP_DEC_FLOAT + time_proc("cpp_dec_float_100", test_polynomial<cpp_dec_float_100>); +#endif +#ifdef TEST_CPP_BIN_FLOAT + time_proc("cpp_bin_float_100", test_polynomial<cpp_bin_float_100>); +#endif +#ifdef TEST_MPFR_CLASS + time_proc("mpfr_class", test_polynomial<mpfr_class>); +#endif +#ifdef TEST_MPREAL + time_proc("mpfr::mpreal", test_polynomial<mpfr::mpreal>); +#endif +} diff --git a/src/boost/libs/multiprecision/performance/voronoi_performance.cpp b/src/boost/libs/multiprecision/performance/voronoi_performance.cpp new file mode 100644 index 00000000..898ca37d --- /dev/null +++ b/src/boost/libs/multiprecision/performance/voronoi_performance.cpp @@ -0,0 +1,227 @@ +/////////////////////////////////////////////////////////////////////////////// +// 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_0.txt) + +#ifdef _MSC_VER +#pragma warning(disable : 4244) +#endif + +#include <boost/polygon/detail/voronoi_predicates.hpp> +#include <boost/polygon/detail/voronoi_structures.hpp> +#include <boost/polygon/detail/skeleton_predicates.hpp> +#include <boost/random/mersenne_twister.hpp> +#include <boost/random/uniform_int_distribution.hpp> +#include <vector> +#include <map> +#include <boost/chrono.hpp> +#include <boost/multiprecision/cpp_int.hpp> + +#ifdef TEST_GMP +#include <boost/multiprecision/gmp.hpp> +#endif +#ifdef TEST_TOMMATH +#include <boost/multiprecision/tommath.hpp> +#endif + +#include "arithmetic_backend.hpp" + +typedef boost::polygon::detail::point_2d<boost::int32_t> i_point; + +template <class Clock> +struct stopwatch +{ + typedef typename Clock::duration duration; + stopwatch() + { + m_start = Clock::now(); + } + duration elapsed() + { + return Clock::now() - m_start; + } + void reset() + { + m_start = Clock::now(); + } + + private: + typename Clock::time_point m_start; +}; + +std::vector<i_point> points; +boost::random::mt19937 gen; + +template <class Big> +struct cpp_int_voronoi_traits +{ + typedef boost::int32_t int_type; + typedef boost::int64_t int_x2_type; + typedef boost::uint64_t uint_x2_type; + typedef Big big_int_type; + typedef double fpt_type; + typedef boost::polygon::detail::extended_exponent_fpt<fpt_type> efpt_type; + typedef boost::polygon::detail::ulp_comparison<fpt_type> ulp_cmp_type; + struct to_fpt_converter_type + { + template <class B, boost::multiprecision::expression_template_option ET> + double operator()(const boost::multiprecision::number<B, ET>& val) + { + return val.template convert_to<double>(); + } + double operator()(double val) + { + return val; + } + double operator()(const efpt_type& that) const + { + return that.d(); + } + template <class tag, class Arg1, class Arg2, class Arg3, class Arg4> + double operator()(const boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>& e) + { + typedef typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type r_t; + r_t r(e); + return r.template convert_to<double>(); + } + }; + struct to_efpt_converter_type + { + template <class B, boost::multiprecision::expression_template_option ET> + efpt_type operator()(const boost::multiprecision::number<B, ET>& val) + { + return efpt_type(val.template convert_to<double>(), 0); + } + efpt_type operator()(double val) + { + return efpt_type(val, 0); + } + template <class tag, class Arg1, class Arg2, class Arg3, class Arg4> + double operator()(const boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>& e) + { + typedef typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type r_t; + r_t r(e); + return efpt_type(r.template convert_to<double>(), 0); + } + }; +}; + +template <class Big> +struct native_int_voronoi_traits +{ + typedef boost::int32_t int_type; + typedef boost::int64_t int_x2_type; + typedef boost::uint64_t uint_x2_type; + typedef Big big_int_type; + typedef double fpt_type; + typedef boost::polygon::detail::extended_exponent_fpt<fpt_type> efpt_type; + typedef boost::polygon::detail::ulp_comparison<fpt_type> ulp_cmp_type; + struct to_fpt_converter_type + { + template <class T> + double operator()(const T& val) const + { + return val; + } + double operator()(const efpt_type& that) const + { + return that.d(); + } + }; + struct to_efpt_converter_type + { + template <class T> + efpt_type operator()(const T& val) const + { + return efpt_type(val, 0); + } + }; +}; + +std::map<std::string, double> results; +double min_time = (std::numeric_limits<double>::max)(); + +template <class Traits> +double test(const char* name) +{ + typedef boost::polygon::detail::voronoi_predicates<Traits> preds; + typedef boost::polygon::detail::circle_event<boost::int32_t> circle_event; + typedef boost::polygon::detail::site_event<boost::int32_t> site_event; + typedef typename preds::template mp_circle_formation_functor<site_event, circle_event> circle_pred; + + boost::random::uniform_int_distribution<> dist(0, points.size() - 1); + circle_pred pc; + circle_event event; + + stopwatch<boost::chrono::high_resolution_clock> w; + + for (unsigned i = 0; i < 10000; ++i) + { + site_event s1(points[dist(gen)]); + site_event s2(points[dist(gen)]); + site_event s3(points[dist(gen)]); + pc.ppp(s1, s2, s3, event); + pc.pps(s1, s2, s3, 0, event); + pc.pss(s1, s2, s3, 0, event); + pc.sss(s1, s2, s3, event); + } + double d = boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count(); + if (d < min_time) + min_time = d; + results[name] = d; + std::cout << "Time for " << std::setw(30) << std::left << name << " = " << d << std::endl; + return d; +} + +void generate_quickbook() +{ + std::cout << "[table\n[[Integer Type][Relative Performance (Actual time in parenthesis)]]\n"; + + std::map<std::string, double>::const_iterator i(results.begin()), j(results.end()); + + while (i != j) + { + double rel = i->second / min_time; + std::cout << "[[" << i->first << "][" << rel << "(" << i->second << "s)]]\n"; + ++i; + } + + std::cout << "]\n"; +} + +int main() +{ + boost::random::uniform_int_distribution<> dist((std::numeric_limits<boost::int32_t>::min)() / 2, (std::numeric_limits<boost::int32_t>::max)() / 2); + + for (unsigned i = 0; i < 100; ++i) + { + points.push_back(i_point(dist(gen), dist(gen))); + } + + test<boost::polygon::detail::voronoi_ctype_traits<boost::int32_t> >("extended_int"); + + test<cpp_int_voronoi_traits<boost::multiprecision::int256_t> >("int256_t"); + test<cpp_int_voronoi_traits<boost::multiprecision::int512_t> >("int512_t"); + test<cpp_int_voronoi_traits<boost::multiprecision::int1024_t> >("int1024_t"); + + test<cpp_int_voronoi_traits<boost::multiprecision::checked_int256_t> >("checked_int256_t"); + test<cpp_int_voronoi_traits<boost::multiprecision::checked_int512_t> >("checked_int512_t"); + test<cpp_int_voronoi_traits<boost::multiprecision::checked_int1024_t> >("checked_int1024_t"); + + test<cpp_int_voronoi_traits<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<>, boost::multiprecision::et_off> > >("cpp_int"); + +#ifdef TEST_GMP + test<cpp_int_voronoi_traits<boost::multiprecision::number<boost::multiprecision::gmp_int, boost::multiprecision::et_off> > >("mpz_int"); +#endif +#ifdef TEST_TOMMATH + test<cpp_int_voronoi_traits<boost::multiprecision::number<boost::multiprecision::tommath_int, boost::multiprecision::et_off> > >("tom_int"); +#endif + + generate_quickbook(); + + test<native_int_voronoi_traits<boost::int64_t> >("int64_t"); + test<cpp_int_voronoi_traits<boost::multiprecision::number<boost::multiprecision::arithmetic_backend<boost::int64_t>, boost::multiprecision::et_off> > >("number<arithmetic_backend<boost::int64_t>, et_off>"); + //test<cpp_int_voronoi_traits<boost::multiprecision::number<boost::multiprecision::arithmetic_backend<boost::int64_t>, boost::multiprecision::et_on> > >("number<arithmetic_backend<boost::int64_t>, et_on>"); + + return 0; +} |