mirror of
https://github.com/boostorg/multiprecision.git
synced 2026-02-19 14:32:35 +00:00
Merge branch 'develop'
This commit is contained in:
95
example/Jamfile.v2
Normal file
95
example/Jamfile.v2
Normal file
@@ -0,0 +1,95 @@
|
||||
# \libs\math\example\jamfile.v2
|
||||
# Runs multiprecision examples.
|
||||
# Copyright 2014 John Maddock
|
||||
# Copyright Paul A. Bristow 2014.
|
||||
# Copyright Christpher Kormanyos 2014
|
||||
|
||||
# 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)
|
||||
|
||||
# bring in the rules for testing
|
||||
import testing ;
|
||||
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 mpfi_path = [ modules.peek : MPFI_PATH ] ;
|
||||
local tommath_path = [ modules.peek : TOMMATH_PATH ] ;
|
||||
|
||||
project
|
||||
: requirements
|
||||
<include>$(gmp_path)
|
||||
<include>$(gmp_path)/mpfr
|
||||
<include>$(gmp_path)/gmpfrxx
|
||||
<include>$(mpfr_path)
|
||||
<include>$(mpfi_path)
|
||||
<include>$(mpfi_path)/src
|
||||
<include>$(tommath_path)
|
||||
<include>../include
|
||||
<include>../../..
|
||||
<toolset>gcc:<cxxflags>-Wno-missing-braces
|
||||
<toolset>darwin:<cxxflags>-Wno-missing-braces
|
||||
<toolset>acc:<cxxflags>+W2068,2461,2236,4070
|
||||
<toolset>intel:<cxxflags>-Qwd264,239
|
||||
<toolset>msvc:<runtime-link>static
|
||||
<toolset>msvc:<link>static
|
||||
<toolset>msvc:<warnings>all
|
||||
<toolset>msvc:<asynch-exceptions>on
|
||||
<toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
|
||||
<toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE
|
||||
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
|
||||
<toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
|
||||
<toolset>msvc:<cxxflags>/wd4996
|
||||
<toolset>msvc:<cxxflags>/wd4512
|
||||
<toolset>msvc:<cxxflags>/wd4610
|
||||
<toolset>msvc:<cxxflags>/wd4510
|
||||
<toolset>msvc:<cxxflags>/wd4127
|
||||
<toolset>msvc:<cxxflags>/wd4701
|
||||
<toolset>msvc:<cxxflags>/wd4127
|
||||
<toolset>msvc:<cxxflags>/wd4305
|
||||
;
|
||||
|
||||
lib gmp : : <search>$(gmp_path) ;
|
||||
lib mpfr : : <search>$(gmp_path) <search>$(mpfr_path) <search>$(mpfr_path)/build.vc10/lib/Win32/Debug ;
|
||||
lib mpfi : : <search>$(gmp_path) <search>$(mpfr_path) <search>$(mpfr_path)/build.vc10/lib/Win32/Debug <search>$(mpfi_path) <search>$(mpfi_path)/src ;
|
||||
lib quadmath ;
|
||||
|
||||
if $(tommath_path)
|
||||
{
|
||||
lib tommath : [ GLOB $(tommath_path) : *.c ] ;
|
||||
TOMMATH = tommath ;
|
||||
}
|
||||
else
|
||||
{
|
||||
lib tommath : : <search>$(tommath_path) ;
|
||||
TOMMATH = tommath ;
|
||||
}
|
||||
|
||||
run cpp_int_snips.cpp ;
|
||||
|
||||
run cpp_dec_float_snips.cpp ;
|
||||
|
||||
run cpp_bin_float_snips.cpp ;
|
||||
|
||||
run debug_adaptor_snips.cpp ;
|
||||
run float128_snips.cpp quadmath : : : [ check-target-builds ../config//has_float128 : : <build>no ] ;
|
||||
run floating_point_examples.cpp ;
|
||||
run gauss_laguerre_quadrature.cpp ;
|
||||
run hypergeometric_luke_algorithms.cpp ;
|
||||
run integer_examples.cpp ;
|
||||
run logged_adaptor.cpp mpfi mpfr gmp : : : [ check-target-builds ../config//has_mpfi : : <build>no ] ;
|
||||
run mixed_integer_arithmetic.cpp ;
|
||||
run numeric_limits_snips.cpp /boost//test_exec_monitor ;
|
||||
run random_snips.cpp gmp : : : [ check-target-builds ../config//has_gmp : : <build>no ] ;
|
||||
run safe_prime.cpp ;
|
||||
|
||||
run gmp_snips.cpp gmp : : : [ check-target-builds ../config//has_gmp : : <build>no ] ;
|
||||
run mpfi_snips.cpp mpfi mpfr gmp : : : [ check-target-builds ../config//has_mpfi : : <build>no ] ;
|
||||
run mpfr_snips.cpp mpfr gmp : : : [ check-target-builds ../config//has_mpfr : : <build>no ] ;
|
||||
run tommath_snips.cpp $(TOMMATH) : : : [ check-target-builds ../config//has_tommath : : <build>no ] ;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_
|
||||
|
||||
#include <boost/multiprecision/mpfr.hpp>
|
||||
#include <boost/multiprecision/cpp_dec_float.hpp>
|
||||
#include <boost/multiprecision/debug_adaptor.hpp>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ bool nearly_equal(RealType a, RealType b)
|
||||
&& (a + tolerance * std::abs(a) >= b - tolerance * std::abs(b));
|
||||
}
|
||||
|
||||
int main()
|
||||
int test_main(int argc, char**const argv)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -308,15 +308,7 @@ with Boost.Test's macro `BOOST_CHECK_CLOSE_FRACTION`
|
||||
T expected = 1.0;
|
||||
T calculated = 1.0 + std::numeric_limits<T>::epsilon();
|
||||
|
||||
using boost::test_tools::check_is_close;
|
||||
|
||||
bool r = check_is_close(expected, calculated, tolerance);
|
||||
std::cout << std::boolalpha << r << std::endl; // true
|
||||
|
||||
/*`If using Boost.Test, then call the macro version:
|
||||
``BOOST_CHECK_CLOSE_FRACTION(expected, calculated, tolerance);``
|
||||
*/
|
||||
|
||||
BOOST_CHECK_CLOSE_FRACTION(expected, calculated, tolerance);
|
||||
|
||||
//] [/tolerance_1]
|
||||
}
|
||||
@@ -336,10 +328,8 @@ so the default expression template parameter has been replaced by `et_off`.]
|
||||
cpp_dec_float_50 tolerance = 3 * std::numeric_limits<cpp_dec_float_50>::epsilon();
|
||||
cpp_dec_float_50 expected = boost::math::constants::two_pi<cpp_dec_float_50>();
|
||||
cpp_dec_float_50 calculated = 2 * boost::math::constants::pi<cpp_dec_float_50>();
|
||||
using boost::test_tools::check_is_close;
|
||||
|
||||
bool r = check_is_close(expected, calculated, tolerance);
|
||||
std::cout << std::boolalpha << r << std::endl; // true
|
||||
BOOST_CHECK_CLOSE_FRACTION(expected, calculated, tolerance);
|
||||
|
||||
//] [/tolerance_2]
|
||||
}
|
||||
@@ -352,10 +342,8 @@ so the default expression template parameter has been replaced by `et_off`.]
|
||||
cpp_bin_float_quad tolerance = 3 * std::numeric_limits<cpp_bin_float_quad>::epsilon();
|
||||
cpp_bin_float_quad expected = boost::math::constants::two_pi<cpp_bin_float_quad>();
|
||||
cpp_bin_float_quad calculated = 2 * boost::math::constants::pi<cpp_bin_float_quad>();
|
||||
using boost::test_tools::check_is_close;
|
||||
|
||||
bool r = check_is_close(expected, calculated, tolerance);
|
||||
std::cout << std::boolalpha << r << std::endl; // true
|
||||
BOOST_CHECK_CLOSE_FRACTION(expected, calculated, tolerance);
|
||||
|
||||
//] [/tolerance_3]
|
||||
}
|
||||
@@ -376,13 +364,11 @@ so the default expression template parameter has been replaced by `et_off`.]
|
||||
|
||||
cpp_bin_float_quad expected = NaN;
|
||||
cpp_bin_float_quad calculated = 2 * NaN;
|
||||
using boost::test_tools::check_is_close;
|
||||
|
||||
bool r = check_is_close(expected, expected, tolerance);
|
||||
std::cout << std::boolalpha << r << std::endl; // false, as expected because all comparisons with NaNs are false.
|
||||
|
||||
r = check_is_close(expected, calculated, tolerance);
|
||||
std::cout << std::boolalpha << r << std::endl; // false, as expected because all comparisons with NaNs are false.
|
||||
// Comparisons of NaN's always fail:
|
||||
bool b = expected == calculated;
|
||||
std::cout << b << std::endl;
|
||||
BOOST_CHECK_NE(expected, expected);
|
||||
BOOST_CHECK_NE(expected, calculated);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -444,7 +430,6 @@ Similarly we can do the same with NaN (except that we cannot use `assert`)
|
||||
assert(ss.str() == "nan");
|
||||
std::cout << "NaN output was " << ss.str() << std::endl;
|
||||
ss >> n; // Read back in.
|
||||
assert(NaN == n); // Confirms that the floating-point values really are identical.
|
||||
std::cout << "NaN input was " << n << std::endl;
|
||||
}
|
||||
/*`
|
||||
@@ -455,4 +440,6 @@ Similarly we can do the same with NaN (except that we cannot use `assert`)
|
||||
//] [/facet_1]
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
} // int main()
|
||||
|
||||
@@ -315,7 +315,9 @@ public:
|
||||
if(m_sign != o.m_sign)
|
||||
return m_sign ? -1 : 1;
|
||||
int result;
|
||||
if(m_exponent != o.m_exponent)
|
||||
if(m_exponent == exponent_nan)
|
||||
return -1;
|
||||
else if(m_exponent != o.m_exponent)
|
||||
{
|
||||
if(m_exponent == exponent_zero)
|
||||
result = -1;
|
||||
|
||||
@@ -1258,7 +1258,7 @@ private:
|
||||
void do_assign_string(const char* s, const mpl::true_&)
|
||||
{
|
||||
std::size_t n = s ? std::strlen(s) : 0;
|
||||
*this->limbs() = 0;
|
||||
*this = 0;
|
||||
unsigned radix = 10;
|
||||
bool isneg = false;
|
||||
if(n && (*s == '-'))
|
||||
|
||||
Reference in New Issue
Block a user