diff --git a/libs/algebra/test/curves.cpp b/libs/algebra/test/curves.cpp index 23ad25943..34c541ab0 100644 --- a/libs/algebra/test/curves.cpp +++ b/libs/algebra/test/curves.cpp @@ -54,8 +54,6 @@ #include #include -#include - #include using namespace nil::crypto3::algebra; diff --git a/libs/algebra/test/fields.cpp b/libs/algebra/test/fields.cpp index 0b14cd87f..9218d0731 100644 --- a/libs/algebra/test/fields.cpp +++ b/libs/algebra/test/fields.cpp @@ -54,7 +54,6 @@ #include #include #include -#include #include #include diff --git a/libs/multiprecision/include/nil/crypto3/multiprecision/cpp_int_modular/comparison.hpp b/libs/multiprecision/include/nil/crypto3/multiprecision/cpp_int_modular/comparison.hpp index 94c79ef50..6aa6af1d3 100644 --- a/libs/multiprecision/include/nil/crypto3/multiprecision/cpp_int_modular/comparison.hpp +++ b/libs/multiprecision/include/nil/crypto3/multiprecision/cpp_int_modular/comparison.hpp @@ -52,11 +52,11 @@ namespace boost { const cpp_int_modular_backend& b) noexcept { for (int i = b.size() - 1; i > a.size() - 1 ; --i) { if (b.limbs()[i] != 0) - return false; + return true; } for (int i = a.size() - 1; i > b.size() - 1 ; --i) { if (a.limbs()[i] != 0) - return true; + return false; } for (int i = std::min(a.size() - 1, b.size() - 1); i >= 0; --i) { if (a.limbs()[i] != b.limbs()[i]) diff --git a/libs/multiprecision/include/nil/crypto3/multiprecision/traits/is_backend.hpp b/libs/multiprecision/include/nil/crypto3/multiprecision/traits/is_backend.hpp index ab38270f2..2137fc063 100644 --- a/libs/multiprecision/include/nil/crypto3/multiprecision/traits/is_backend.hpp +++ b/libs/multiprecision/include/nil/crypto3/multiprecision/traits/is_backend.hpp @@ -28,6 +28,14 @@ namespace boost { struct is_backend> { static BOOST_MP_CXX14_CONSTEXPR bool value = true; }; + + // If boost wants to convert one cpp_int_modular_backend to another for comparison, make it convert the + // shorter one to the longer by adding zeros, not cut the longer one. + template + struct is_first_backend_imp, + boost::multiprecision::backends::cpp_int_modular_backend> + : public std::integral_constant < bool, Bits1 >= Bits2> {}; + } // namespace detail } // multiprecision } // namespace boost diff --git a/libs/multiprecision/test/CMakeLists.txt b/libs/multiprecision/test/CMakeLists.txt index 8f265d72b..c283430d6 100644 --- a/libs/multiprecision/test/CMakeLists.txt +++ b/libs/multiprecision/test/CMakeLists.txt @@ -7,42 +7,13 @@ # http://www.boost.org/LICENSE_1_0.txt #---------------------------------------------------------------------------# -#add_custom_target(${CURRENT_PROJECT_NAME}_test_suite_arithmetic_tests) -#add_custom_target(${CURRENT_PROJECT_NAME}_test_suite_functions_and_limits) -#add_custom_target(${CURRENT_PROJECT_NAME}_test_suite_conversions) -#add_custom_target(${CURRENT_PROJECT_NAME}_test_suite_cpp_int_tests) add_custom_target(${CURRENT_PROJECT_NAME}_test_suite_modular_cpp_int_tests) -#add_custom_target(${CURRENT_PROJECT_NAME}_test_suite_misc) -#add_custom_target(${CURRENT_PROJECT_NAME}_test_suite_specfun) -#add_custom_target(${CURRENT_PROJECT_NAME}_test_suite_concepts) -#add_custom_target(${CURRENT_PROJECT_NAME}_test_suite_examples) -#add_custom_target(${CURRENT_PROJECT_NAME}_test_suite_compile_fail) cm_test_link_libraries( ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} Boost::unit_test_framework ) -# HACK: Workaround broken includes -file(GLOB TEST_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp ${CMAKE_CURRENT_SOURCE_DIR}/*.ipp) -set(CMAKE_INCLUDE_CURRENT_DIR TRUE) -foreach(HEADER ${TEST_HEADERS}) - configure_file(${HEADER} ${CMAKE_CURRENT_BINARY_DIR}/libs/${CURRENT_PROJECT_NAME}/test/${HEADER} - @ONLY) -endforeach() - -add_library(${CURRENT_PROJECT_NAME}_test_settings INTERFACE) -target_include_directories(${CURRENT_PROJECT_NAME}_test_settings INTERFACE ${CURRENT_TEST_SOURCES_DIR}/include) -cm_test_link_libraries(${CURRENT_PROJECT_NAME}_test_settings) - -if(EIGEN_FOUND) - try_compile(EIGEN_COMPILED ${CMAKE_BINARY_DIR} ${CURRENT_TEST_SOURCES_DIR}/../config/has_eigen.cpp - CMAKE_FLAGS "-DCMAKE_CXX_LINK_EXECUTABLE='echo not linking now...'" "-DINCLUDE_DIRECTORIES=${EIGEN3_INCLUDE_DIRS}") -endif() - -# TODO: figure out if it is needed -# add_library(no_eh_support SHARED ${CURRENT_TEST_SOURCES_DIR}/no_eh_test_support.cpp) - macro(define_runtime_multiprecision_test name) set(test_name "${CURRENT_PROJECT_NAME}_${name}_test") @@ -81,6 +52,7 @@ set(RUNTIME_TESTS_NAMES "inverse" "jacobi" "ressol" + "arithmetic_non_matching_bitlength_numbers" ) set(MODULAR_TESTS_NAMES diff --git a/libs/multiprecision/test/arithmetic_non_matching_bitlength_numbers.cpp b/libs/multiprecision/test/arithmetic_non_matching_bitlength_numbers.cpp new file mode 100644 index 000000000..42fbe5f4f --- /dev/null +++ b/libs/multiprecision/test/arithmetic_non_matching_bitlength_numbers.cpp @@ -0,0 +1,102 @@ +//---------------------------------------------------------------------------// +// Copyright (c) 2024 Martun Karapetyan +// +// 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 +//---------------------------------------------------------------------------// + +#define BOOST_TEST_MODULE NON_MATCHING_BITLENGTH_NUMBERS_TESTS + +// Suddenly, BOOST_MP_ASSERT is NOT constexpr, and it is used in constexpr functions throughout the boost, resulting to compilation errors on all compilers in debug mode. We need to switch assertions off inside cpp_int to make this code compile in debug mode. So we use this workaround to turn off file 'boost/multiprecision/detail/assert.hpp' which contains definition of BOOST_MP_ASSERT and BOOST_MP_ASSERT_MSG. +#ifndef BOOST_MP_DETAIL_ASSERT_HPP + #define BOOST_MP_DETAIL_ASSERT_HPP + #define BOOST_MP_ASSERT(expr) ((void)0) + #define BOOST_MP_ASSERT_MSG(expr, msg) ((void)0) +#endif + +#include + +#include +#include +#include + +#include +#include +#include + +// We need cpp_int to compare to it. +#include + +#include +#include +#include +#include + +using namespace boost::multiprecision; + +using boost::multiprecision::backends::cpp_int_modular_backend; + +// This test case uses normal boost::cpp_int for comparison to our cpp_int_modular_backend. +template +void value_comparisons_tests(const number>& a, + const number>& b) { + + typedef cpp_int_modular_backend Backend1; + typedef cpp_int_modular_backend Backend2; + typedef cpp_int_modular_backend Backend_large; + typedef typename Backend1::cpp_int_type CppIntBackend1; + typedef typename Backend2::cpp_int_type CppIntBackend2; + typedef typename Backend_large::cpp_int_type CppIntBackend_large; + + typedef boost::multiprecision::number cpp_int_number1; + typedef boost::multiprecision::number cpp_int_number2; + typedef boost::multiprecision::number cpp_int_number_large; + + // Convert from cpp_int_modular_backend to cpp_int_backend numbers. + cpp_int_number1 a_cppint = a.backend().to_cpp_int(); + cpp_int_number2 b_cppint = b.backend().to_cpp_int(); + + BOOST_ASSERT_MSG((a > b) == (a_cppint > b_cppint), "g error"); + BOOST_ASSERT_MSG((a >= b) == (a_cppint >= b_cppint), "ge error"); + BOOST_ASSERT_MSG((a == b) == (a_cppint == b_cppint), "e error"); + BOOST_ASSERT_MSG((a < b) == (a_cppint < b_cppint), "l error"); + BOOST_ASSERT_MSG((a <= b) == (a_cppint <= b_cppint), "le error"); + BOOST_ASSERT_MSG((a != b) == (a_cppint != b_cppint), "ne error"); +} + +template +void value_comparisons_tests(const std::size_t N) { + using Backend1 = cpp_int_modular_backend<130>; + using Backend2 = cpp_int_modular_backend<260>; + using standard_number1 = boost::multiprecision::number; + using standard_number2 = boost::multiprecision::number; + + int seed = 0; + boost::random::mt19937 gen(seed); + boost::random::uniform_int_distribution d1(0, ~standard_number1(0u)); + boost::random::uniform_int_distribution d2(0, ~standard_number2(0u)); + + for (std::size_t i = 0; i < N; ++i) { + standard_number1 a = d1(gen); + standard_number2 b = d2(gen); + value_comparisons_tests(a, b); + } +} + + +BOOST_AUTO_TEST_SUITE(static_tests) + +BOOST_AUTO_TEST_CASE(base_test_backend_12_17) { + value_comparisons_tests<12, 17>(1000); +} + +BOOST_AUTO_TEST_CASE(base_test_backend_130_260) { + value_comparisons_tests<260, 130>(1000); +} + +BOOST_AUTO_TEST_CASE(base_test_backend_128_256) { + value_comparisons_tests<128, 256>(1000); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/libs/multiprecision/test/modular_adaptor_fixed.cpp b/libs/multiprecision/test/modular_adaptor_fixed.cpp index 78b3de5d4..a86248cd3 100644 --- a/libs/multiprecision/test/modular_adaptor_fixed.cpp +++ b/libs/multiprecision/test/modular_adaptor_fixed.cpp @@ -18,8 +18,6 @@ #endif #include -#include -#include #include #include diff --git a/libs/multiprecision/test/test_atan.cpp b/libs/multiprecision/test/test_atan.cpp deleted file mode 100644 index ea8104fb8..000000000 --- a/libs/multiprecision/test/test_atan.cpp +++ /dev/null @@ -1,492 +0,0 @@ -/////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2002 - 2011. -// 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 -// -// This work is based on an earlier work: -// "Algorithm 910: A Portable C++ Multiple-Precision System for Special-Function Calculations", -// in ACM TOMS, {VOL 37, ISSUE 4, (February 2011)} (C) ACM, 2011. http://doi.acm.org/10.1145/1916461.1916469 - -#ifdef _MSC_VER -#define _SCL_SECURE_NO_WARNINGS -#endif - -#include -#include -#include "test.hpp" - -#if !defined(TEST_MPF_50) && !defined(TEST_MPF) && !defined(TEST_BACKEND) && !defined(TEST_CPP_DEC_FLOAT) && \ - !defined(TEST_MPFR) && !defined(TEST_MPFR_50) && !defined(TEST_MPFI_50) && !defined(TEST_FLOAT128) && \ - !defined(TEST_CPP_BIN_FLOAT) -#define TEST_MPF_50 -//# define TEST_MPF -#define TEST_BACKEND -#define TEST_CPP_DEC_FLOAT -#define TEST_MPFI_50 -#define TEST_FLOAT128 -#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_50) -#include -#endif -#if defined(TEST_MPFR_50) -#include -#endif -#if defined(TEST_MPFI_50) -#include -#endif -#ifdef TEST_BACKEND -#include -#endif -#ifdef TEST_CPP_DEC_FLOAT -#include -#endif -#ifdef TEST_FLOAT128 -#include -#endif -#ifdef TEST_CPP_BIN_FLOAT -#include -#endif - -#ifdef BOOST_MSVC -#pragma warning(disable : 4127) -#endif - -template -T atan2_def(T y, T x) { - T t; - t.backend() = boost::multiprecision::default_ops::get_constant_pi(); - T t2; - if (x) - t2 = atan(y / x); - else - t2 = y.sign() * t / 2; - return t2 + (t / 2) * (1 - x.sign()) * T(y.sign() + 0.5).sign(); -} - -template -struct is_mpfr_type : public std::integral_constant { }; - -#ifdef TEST_MPFR_50 -template -struct is_mpfr_type>> - : public std::integral_constant { }; -#endif - -template -void test() { - std::cout << "Testing type: " << typeid(T).name() << std::endl; - static const boost::array data = {{ - "9." - "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999" - "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999666666666666666666666" - "66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666" - "666666666666666666666666666666666666666666666666666666666666666666667e-101", - "9." - "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999" - "99999999999999999999999999999999999999999999999999999999999999999999999999999999966666666666666666666666666666" - "66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666" - "666666666666666666666666666666666666666666666666666668666666666666667e-97", - "9." - "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999" - "99999999999999999999999999999999999999999999999999999999999999999999999996666666666666666666666666666666666666" - "66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666" - "666666666666666666666666666666666666686666666666666666666666666666667e-93", - "9." - "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999" - "99999999999999999999999999999999999999999999999999999999999999999666666666666666666666666666666666666666666666" - "66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666" - "666666666666666666666866666666666666666666666666666666666666666666667e-89", - "9." - "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999" - "99999999999999999999999999999999999999999999999999999999966666666666666666666666666666666666666666666666666666" - "66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666" - "666668666666666666666666666666666666666666666666666666666666666666667e-85", - "9." - "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999" - "99999999999999999999999999999999999999999999999996666666666666666666666666666666666666666666666666666666666666" - "66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666686666666666" - "666666666666666666666666666666666666666666666666666666666666666666667e-81", - "9." - "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999" - "99999999999999999999999999999999999999999666666666666666666666666666666666666666666666666666666666666666666666" - "66666666666666666666666666666666666666666666666666666666666666666666666666666666666866666666666666666666666666" - "666666666666666666666666666666666666666666666666666666666666666666667e-77", - "9." - "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999" - "99999999999999999999999999999999966666666666666666666666666666666666666666666666666666666666666666666666666666" - "66666666666666666666666666666666666666666666666666666666666666666668666666666666666666666666666666666666666666" - "666666666666666666666666666666666666666666666666666666666666666666667e-73", - "9." - "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999" - "99999999999999999999999996666666666666666666666666666666666666666666666666666666666666666666666666666666666666" - "66666666666666666666666666666666666666666666666666686666666666666666666666666666666666666666666666666666666666" - "666666666666666666666666666666666666666666666666666666666666666666667e-69", - "9." - "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999" - "99999999999999999666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666" - "66666666666666666666666666666666666866666666666666666666666666666666666666666666666666666666666666666666666666" - "666666666666666666666666666666666666666666666666666665238095238095238e-65", - "9." - "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999" - "99999999966666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666" - "66666666666666666668666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666" - "666666666666666666666666666665238095238095238095238095238095238095238e-61", - "9." - "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999" - "96666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666" - "66686666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666" - "666665238095238095238095238095238095238095238095238095238095238095238e-57", - "9." - "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999996666666" - "66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666668666666666666" - "66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666665238095238095238095" - "238095238095238095238095238095238095238095238095238095238095238095238e-53", - "9." - "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999666666666666666" - "66666666666666666666666666666666666666666666666666666666666666666666666666666666686666666666666666666666666666" - "66666666666666666666666666666666666666666666666666666666666666666665238095238095238095238095238095238095238095" - "238095238095238095238095238095238095238095238095238096349206349206349e-49", - "9." - "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999966666666666666666666666" - "66666666666666666666666666666666666666666666666666666666666666666866666666666666666666666666666666666666666666" - "66666666666666666666666666666666666666666665238095238095238095238095238095238095238095238095238095238095238095" - "238095238095238095238206349206349206349206349206349206349206349206349e-45", - "9." - "99999999999999999999999999999999999999999999999999999999999999999999999999999996666666666666666666666666666666" - "66666666666666666666666666666666666666666666666668666666666666666666666666666666666666666666666666666666666666" - "66666666666666666665238095238095238095238095238095238095238095238095238095238095238095238095238095249206349206" - "349206349206349206349206349206349206349206349206349206349206349206349e-41", - "9." - "99999999999999999999999999999999999999999999999999999999999999999999999666666666666666666666666666666666666666" - "66666666666666666666666666666666686666666666666666666666666666666666666666666666666666666666666666666666652380" - "95238095238095238095238095238095238095238095238095238095238095238096349206349206349206349206349206349206349206" - "34920634920634920634920634920544011544011544011544011544011544011544e-37", - "9." - "99999999999999999999999999999999999999999999999999999999999999966666666666666666666666666666666666666666666666" - "66666666666666666866666666666666666666666666666666666666666666666666666666666666652380952380952380952380952380" - "95238095238095238095238095238095238206349206349206349206349206349206349206349206349206349206349206340115440115" - "440115440115440115440115440115440115440115440115440116209346209346209e-33", - "9." - "99999999999999999999999999999999999999999999999999999996666666666666666666666666666666666666666666666666666666" - "68666666666666666666666666666666666666666666666666666666652380952380952380952380952380952380952380952380952380" - "95249206349206349206349206349206349206349206349206349206349115440115440115440115440115440115440115440115440115" - "440116209346209346209346209346209346209346209346209346209346202679543e-29", - "9." - "99999999999999999999999999999999999999999999999666666666666666666666666666666666666666666666666866666666666666" - "66666666666666666666666666666666652380952380952380952380952380952380952380952380963492063492063492063492063492" - "06349206349206349205440115440115440115440115440115440115440115440116209346209346209346209346209346209346209346" - "20934554267954267954267954267954267954267954267954268013091483679719e-25", - "9." - "99999999999999999999999999999999999999966666666666666666666666666666666666666668666666666666666666666666666666" - "66666666652380952380952380952380952380952380952382063492063492063492063492063492063492063401154401154401154401" - "15440115440115440116209346209346209346209346209346209346209279542679542679542679542679542679542679548561895620" - "719150130914836797189738366208428128459088211410192834341441152586663e-21", - "9." - "99999999999999999999999999999996666666666666666666666666666666686666666666666666666666666666666523809523809523" - "80952380952380952492063492063492063492063492063491154401154401154401154401154401162093462093462093462093462093" - "46202679542679542679542679542679542738366208954444248561895620719149604599047323505527839893164970569113274066" - "834438351466215243304983108499463325146458811824271509689681318218133e-17", - "9." - "99999999999999999999999666666666666666666666666866666666666666666666666523809523809523809523809634920634920634" - "92063492054401154401154401154401162093462093462093462093455426795426795426795426801309148367971897383662084281" - "28459088211410192834817631628777139613052925311641589740930163598087002528653948764327011735444703713649735994" - "600714288656350334489593033695272837185114343249547095046272603174268e-13", - "9." - "99999999999999966666666666666668666666666666666523809523809523820634920634920634011544011544011620934620934620" - "92795426795426795485618956207191496045990473235055754589407840181790511622655922027266214947464105796118350970" - "95566286199717626418813764642659343446728207455753397291482030056516178836684094391777365260695851470017381944" - "166954115569576329193296454393446430574957840819236721213626802085619e-9", - "0." - "00009999999966666666866666665238095249206349115440116209346202679542738366208428128463850116128619335776637836" - "25356016743446481287919721529889488170726992708103099973754992548200867236379993760691596237924758432415909453" - "64213757559975131795786106774549205128978509536127629907329130469210884560799844298882202621374002139299626915" - "32176198436788640624698990926490105259050461938357510947570244880435664081", - "0." - "78539816339744830961566084581987572104929234984377645524373614807695410157155224965700870633552926699553702162" - "83205766617734611523876455579313398520321202793625710256754846302763899111557372387325954911072027439164833615" - "32118912058446695791317800477286412141730865087152613581662053348401815062285318431146751651578897043720380230" - "24070731352292884109197314759000283263263720511663034603673798537790236", - "1." - "57069632679522995256265502498737048960652120853315174839401026935848081948102021802937891150977234063330766489" - "41055516492022741759833189628737308869915412879148320539754700057326930986734751013960313584219296445913757777" - "00024066556918259786849494180023619154483220638177597255994976227592745563770792563411300681783791948141133545" - "1596526426779712759369563859151046126747697908496855825977735219514481", - "1." - "57079631679489661923132202497308477543189803302088624382223420091581296493675529296481107255561841855095783391" - "04318071142673796252326115673007840833450909541260947278453938016119958041324233151995987794877839930865561434" - "52402727021327105382917974535759059640802386727577019707570709405321600068054458025609408911380428826744908990" - "4640326828789035666143699659867092108718279796583028512542392495421779", - "1." - "57079632679389661923132169163975144243191803302088624382080542948724153647643783264749360314724901018155023362" - "17205184029120016698547471043186681600526965471042074304163483259318452680435202095109230279463923963492870040" - "90401203274080545673814459935289342520298852460343921870792942537829537108210828162040637908281361386267215990" - "1100496534463976107550806601465567059619048829495421806391510160463001", - "1." - "57079632679489651923132169163975144209858469968788624382080562948724153647643783064735074600439186732440737658" - "99887723711659699238229101634817272120007484952330785592874771970616254211570733230640365810600043257395046296" - "02144362023431298120608805527777397488034934747509799779662017152361144505614429670797457312684559032162361528" - "8317089359131170138395627805178532322154433252386274406088878525130896", - "1." - "57079632679489661922132169163975144209858469968755291048747262948724153647643783264735074600439186730440737658" - "99744866568802556381086244491974416088261453206299039561128740224575416159622681282588417758651991386266175167" - "24122384001453276142520160839132708843345520828095880953977897350594283915224427582750823760478251407898080917" - "8018719474972957865632271450490908284680846718670522639450168825443945", - "1." - "57079632679489661923132069163975144209858469968755291048747229615390820347643783264735074600439186732440737658" - "99744866566802556381086244491960130373975738920584753846844454510289702985019506679413814584048816783091570881" - "43602903481972756662000680319652189362826809630293683151780095152792086113026625318281959291536859466506139525" - "8604800061112367475630116742454513973110064559653064241192080164878504", - "1." - "57079632679489661923132169153975144209858469968755291048747229615390820314310449931435074600439186732440737658" - "99744866568802556381086244491940130373975738920584753846843025938861131556448078107985386012620245354520143421" - "11856871735941010630254648573620332219969666682241735099832043204740138061078573370230012148756639686286359306" - "0802602258914565277827918940256045031718123167711672299800138772937113", - "1." - "57079632679489661923132169163974144209858469968755291048747229615390820314310449931401741267105886732440737658" - "99744866568802556381086244491960130373975738920584553846843025938861131556448078107985243155477388211663000563" - "97572586021655296344540362859334729045366492079067131925228868601565423775364287655944296953951444881091554111" - "2750654206966513329776061797398902251498342947931452519580358553156893", - "1." - "57079632679489661923132169163975144109858469968755291048747229615390820314310449931401741267105853399107404358" - "99744866568802556381086244491960130373975738920584753846843025938861129556448078107985243155477388211663000563" - "97571157450226724915968934287906300473937920650495703353800297172994106315046827338483979493633984563631125539" - "8464939921252227615490256602593707446303537753126257714385553358352607", - "1." - "57079632679489661923132169163975144209848469968755291048747229615390820314310449931401741267105853399107404325" - "66411533238802556381086244491960130373975738920584753846843025938861131556448078107985243135477388211663000563" - "97571157450226724915968934287906157616795063507638560496657454315851249172189684481341122350776841706488379508" - "1004622460934767298029939142275136017732109181697686285814124786923127", - "1." - "57079632679489661923132169163975144209858468968755291048747229615390820314310449931401741267105853399107404325" - "66411533235469223047756244491960130373975738920584753846843025938861131556448078107985243155477388211663000563" - "77571157450226724915968934287906157616795063507638560496657440030136963457903970195626838065062555992202665222" - "3861765318077624440887081999419104271700363149951654539782378755175984", - "1." - "57079632679489661923132169163975144209858469968655291048747229615390820314310449931401741267105853399107404325" - "66411533235469223047752911158626800373975738920584753846843025938861131556448078107985243155477388211663000563" - "97571157450226724915768934287906157616795063507638560496657440030136963457903970195626836636491127420774093793" - "8147481032363338726601367713704818557414648864237368825496664469462809", - "1." - "57079632679489661923132169163975144209858469968755281048747229615390820314310449931401741267105853399107404325" - "66411533235469223047752911158626797040642405590584753846843025938861131556448078107985243155477388211663000563" - "97571157450226724915968934287906157616793063507638560496657440030136963457903970195626836636491127420774093793" - "8147479603791910155172796285133390128843220292808797396925235898034238", - "1." - "57079632679489661923132169163975144209858469968755291047747229615390820314310449931401741267105853399107404325" - "66411533235469223047752911158626797040642405587251420513513025938861131556448078107985243155477388211663000563" - "97571157450226724915968934287906157616795063507638560496657420030136963457903970195626836636491127420774093793" - "8147479603791910155172796285133389985986077435665940254068093055177095", - "1." - "57079632679489661923132169163975144209858469968755291048747129615390820314310449931401741267105853399107404325" - "66411533235469223047752911158626797040642405587251420513509692605527801556448078107985243155477388211663000563" - "97571157450226724915968934287906157616795063507638560496657440030136963457903969995626836636491127420774093793" - "814747960379191015517279628513338998598607743566594025406809304089138", - "1." - "57079632679489661923132169163975144209858469968755291048747229605390820314310449931401741267105853399107404325" - "66411533235469223047752911158626797040642405587251420513509692605527798223114744777985243155477388211663000563" - "97571157450226724915968934287906157616795063507638560496657440030136963457903970195626836636491127418774093793" - "814747960379191015517279628513338998598607743566594025406809304089138", - "1." - "57079632679489661923132169163975144209858469968755291048747229615389820314310449931401741267105853399107404325" - "66411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822147388211663000563" - "97571157450226724915968934287906157616795063507638560496657440030136963457903970195626836636491127420774093793" - "814747960359191015517279628513338998598607743566594025406809304089138", - "1." - "57079632679489661923132169163975144209858469968755291048747229615390820214310449931401741267105853399107404325" - "66411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329670563" - "97571157450226724915968934287906157616795063507638560496657440030136963457903970195626836636491127420774093793" - "814747960379191015517279628513138998598607743566594025406809304089138", - "1." - "57079632679489661923132169163975144209858469968755291048747229615390820314300449931401741267105853399107404325" - "66411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230" - "64237824450226724915968934287906157616795063507638560496657440030136963457903970195626836636491127420774093793" - "814747960379191015517279628513338998598607743566592025406809304089138", - "1." - "57079632679489661923132169163975144209858469968755291048747229615390820314310448931401741267105853399107404325" - "66411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230" - "64237824116893391582968934287906157616795063507638560496657440030136963457903970195626836636491127420774093793" - "814747960379191015517279628513338998598607743566594025406809304089138", - "1." - "57079632679489661923132169163975144209858469968755291048747229615390820314310449931301741267105853399107404325" - "66411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230" - "64237824116893391582635600954573157616795063507638560496657440030136963457903970195626836636491127420774093793" - "814747960379191015517279628513338998598607743566594025406809304089138", - "1." - "57079632679489661923132169163975144209858469968755291048747229615390820314310449931401731267105853399107404325" - "66411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230" - "64237824116893391582635600954572824283461730507638560496657440030136963457903970195626836636491127420774093793" - "814747960379191015517279628513338998598607743566594025406809304089138", - "1." - "57079632679489661923132169163975144209858469968755291048747229615390820314310449931401741266105853399107404325" - "66411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230" - "64237824116893391582635600954572824283461730174305227163657440030136963457903970195626836636491127420774093793" - "814747960379191015517279628513338998598607743566594025406809304089138", - "1." - "57079632679489661923132169163975144209858469968755291048747229615390820314310449931401741267105753399107404325" - "66411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230" - "64237824116893391582635600954572824283461730174305227163324106696803963457903970195626836636491127420774093793" - "814747960379191015517279628513338998598607743566594025406809304089138", - "1." - "57079632679489661923132169163975144209858469968755291048747229615390820314310449931401741267105853389107404325" - "66411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230" - "64237824116893391582635600954572824283461730174305227163324106696803630124570637195626836636491127420774093793" - "814747960379191015517279628513338998598607743566594025406809304089138", - }}; - - T arg = static_cast("1e-100"); - - unsigned max_err = 0; - for (unsigned k = 0; k < data.size(); k++) { - T val = atan(arg); - T e = relative_error(val, T(data[k])); - unsigned err = e.template convert_to(); - if (err > max_err) - max_err = err; - val = atan(-arg); - e = relative_error(val, T(-T(data[k]))); - err = e.template convert_to(); - if (err > max_err) { - max_err = err; - } - arg *= 10000; - } - std::cout << "Max error was: " << max_err << std::endl; - BOOST_TEST(max_err < 10); - BOOST_TEST(atan(T(0)) == 0); - - // - // And again, but test all the phases of atan2: - // - arg = static_cast("1e-100"); - unsigned err; - for (unsigned k = 0; k < data.size(); k++) { - T val = atan2(arg, 1); - T e = relative_error(val, atan2_def(arg, T(1))); - err = e.template convert_to(); - if (err > max_err) { - max_err = err; - } - val = atan2(-arg, 1); - e = relative_error(val, atan2_def(T(-arg), T(1))); - err = e.template convert_to(); - if (err > max_err) { - max_err = err; - } - val = atan2(arg, -1); - e = relative_error(val, atan2_def(arg, T(-1))); - err = e.template convert_to(); - if (err > max_err) { - max_err = err; - } - val = atan2(-arg, -1); - e = relative_error(val, atan2_def(T(-arg), T(-1))); - err = e.template convert_to(); - if (err > max_err) { - max_err = err; - } - arg *= 10000; - } - // - // special cases: - // - err = relative_error(T(atan2(T(0), T(1))), atan2_def(T(0), T(1))).template convert_to(); - if (err > max_err) - max_err = err; - if (!boost::multiprecision::is_interval_number::value) { - // We don't test this with intervals as [-0,0] leads to strange behaviour in atan2... - err = relative_error(T(atan2(T(0), T(-1))), atan2_def(T(0), T(-1))).template convert_to(); - if (err > max_err) - max_err = err; - } - - T pi; - pi.backend() = boost::multiprecision::default_ops::get_constant_pi(); - - err = relative_error(T(atan2(T(1), T(0))), T(pi / 2)).template convert_to(); - if (err > max_err) - max_err = err; - - err = relative_error(T(atan2(T(-1), T(0))), T(pi / -2)).template convert_to(); - if (err > max_err) - max_err = err; - - T mv = (std::numeric_limits::max)(); - err = relative_error(T(atan2(mv, T(1))), T(pi / 2)).template convert_to(); - if (err > max_err) - max_err = err; - err = relative_error(T(atan2(-mv, T(1))), T(pi / -2)).template convert_to(); - if (err > max_err) - max_err = err; - - if (std::numeric_limits::has_infinity) { - mv = (std::numeric_limits::infinity)(); - err = relative_error(T(atan2(mv, T(1))), T(pi / 2)).template convert_to(); - if (err > max_err) - max_err = err; - err = relative_error(T(atan2(-mv, T(1))), T(pi / -2)).template convert_to(); - if (err > max_err) - max_err = err; - } - - std::cout << "Max error was: " << max_err << std::endl; - BOOST_TEST(max_err < 2000); -} - -int main() { -#ifdef TEST_BACKEND - test< - boost::multiprecision::number>(); -#endif -#ifdef TEST_MPF_50 - test(); - test(); -#endif -#ifdef TEST_MPFR_50 - test(); - test(); -#endif -#ifdef TEST_MPFI_50 - test(); - test(); -#endif -#ifdef TEST_CPP_DEC_FLOAT - test(); - test(); -#ifndef SLOW_COMPLER - // Some "peculiar" digit counts which stress our code: - test>>(); - test>>(); - test>>(); - test>>(); - test>>(); - test>>(); - test>>>(); - test>>>(); - // Check low multiprecision digit counts. - test>>(); - test>>(); -#endif -#endif -#ifdef TEST_FLOAT128 - test(); -#endif -#ifdef TEST_CPP_BIN_FLOAT - test(); - test, boost::long_long_type>>>(); -#endif - return boost::report_errors(); -} diff --git a/libs/multiprecision/test/test_cos.cpp b/libs/multiprecision/test/test_cos.cpp deleted file mode 100644 index 18a182616..000000000 --- a/libs/multiprecision/test/test_cos.cpp +++ /dev/null @@ -1,818 +0,0 @@ -/////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2002 - 2011. -// 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 -// -// This work is based on an earlier work: -// "Algorithm 910: A Portable C++ Multiple-Precision System for Special-Function Calculations", -// in ACM TOMS, {VOL 37, ISSUE 4, (February 2011)} (C) ACM, 2011. http://doi.acm.org/10.1145/1916461.1916469 - -#ifdef _MSC_VER -#define _SCL_SECURE_NO_WARNINGS -#endif - -#include -#include -#include "test.hpp" - -#if !defined(TEST_MPF_50) && !defined(TEST_MPF) && !defined(TEST_BACKEND) && !defined(TEST_CPP_DEC_FLOAT) && \ - !defined(TEST_MPFR) && !defined(TEST_MPFR_50) && !defined(TEST_MPFI_50) && !defined(TEST_FLOAT128) && \ - !defined(TEST_CPP_BIN_FLOAT) -#define TEST_MPF_50 -//# define TEST_MPF -#define TEST_BACKEND -#define TEST_CPP_DEC_FLOAT -#define TEST_MPFI_50 -#define TEST_FLOAT128 -#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_50) -#include -#endif -#if defined(TEST_MPFR_50) -#include -#endif -#if defined(TEST_MPFI_50) -#include -#endif -#ifdef TEST_BACKEND -#include -#endif -#ifdef TEST_CPP_DEC_FLOAT -#include -#endif -#ifdef TEST_FLOAT128 -#include -#endif -#ifdef TEST_CPP_BIN_FLOAT -#include -#endif - -template -struct has_poor_large_value_support { - static const bool value = false; -}; -#ifdef TEST_CPP_DEC_FLOAT -template -struct has_poor_large_value_support, ExpressionTemplates>> { - static const bool value = true; -}; -#endif -#ifdef TEST_CPP_BIN_FLOAT -template -struct has_poor_large_value_support, - ExpressionTemplates>> { - static const bool value = true; -}; -#endif - -template -void test() { - std::cout << "Testing type " << typeid(T).name() << std::endl; - static const boost::array data = {{ - "-2." - "37609908807915949996042688873953402912174184373388399043229539427530802169622688886435380890546981798452174137" - "747437590e-1", - "8." - "03406366226813589517543567844755380935198206635917017883860879215939165740799963435747185200486086864198723786" - "516760875e-1", - "8." - "60219386510802105228997694366289682807721120146423711696179175800635220710279361583231346318224971127450760223" - "168489952e-1", - "-1." - "36768951513839774357595871594675554406872039078811749027554673949684004409484639336417431285061889554892096426" - "752261915e-1", - "-9." - "66210139195431691033548069227792927999642647449593184440815029076272297050360196975341458076547426373476590671" - "462150981e-1", - "-6." - "12007278553856790723803948280976098970972124581361775428331444376106018942231526074915731012122426588769327127" - "413045994e-1", - "4." - "91927698740873688392439262912409276430264703350691359723802294639643655296838880236042651349290074585311025856" - "549893171e-1", - "9." - "93232596718899824059271235487971663771012607519717340071654721877802691370866768064059943491135925674950430467" - "047724563e-1", - "2." - "77789911520199551017947550534057049374212876971194676010301098598339529915403722848373365985645657342475739669" - "568931563e-1", - "-7." - "77955945956221239101360662190442739163791527953499629555756394261998892874934847131138921705713935365505245406" - "994428077e-1", - "-8." - "80676278306736581575818642341143682410874043182925227659938804267878718513212454821032629378618345485453587099" - "696563832e-1", - "9." - "54652155963865007116798560589970996367213754762169439269792747771200843006278637115722685610960738675814993576" - "019945344e-2", - "9." - "54658201427917718824191302196929158303422390793460018465335986921801519149657723689322277773550748806000948225" - "466432438e-1", - "6." - "44358700620889799575033272322899136331490664925359198096632560532437137894857803619177106562399406351419810452" - "110265174e-1", - "-4." - "55304635273050571206400777159475409897339683148730716647371922365967582339285347105376503917296765204188604297" - "021364549e-1", - "-9." - "97202532932553753622481171186283382950122646390227670693679248197349800205205290898290539070732778341271049474" - "946533154e-1", - "-3." - "17489525058325500707686194437148362752290391406825231198381521862930317513649081353670386166519524315810546189" - "268634469e-1", - "7." - "51160186640147504067744846462384089742696250681200524524912647858645140367792164416711871535116761744380912486" - "921554617e-1", - "8." - "99610194168373157174515848193119670768490559799348397680196213249921436405001710937402190319584272526657508442" - "591319630e-1", - "-5." - "39963892484342940823660554048696208293700871414984387094529796385334086703752106515008832585578915389731907422" - "242902573e-2", - "-9." - "41455348900839346761557896365239742769987576963330061702397697388879776230596944312519157729410022380228287314" - "835345969e-1", - "-6." - "75595816763857390859268297670835380459024839344154743310231115864242050771191159334664874097564054770066166961" - "642073448e-1", - "4." - "17894201894880415042381733708896725748531223743344790054523182948440843948904650988733732381978194392219295696" - "279423635e-1", - "9." - "99447981389824371458566861195586395552622718284098766856978062347139060489410032781030191080200904443096549587" - "568037683e-1", - "3." - "56640095868759075150409032448421838265699043643228482503057299699740924345262819242042067863780263400092250418" - "388628640e-1", - "-7." - "23065426868134142613141384486526262450487633432466529798821958977732347646832059032382447792655111641456570392" - "189752211e-1", - "-9." - "16988391192434436877664999042786024703848714036221388727578305299843547352325574309860356272561772723624753484" - "063972217e-1", - "1." - "24341855683226931265962750806821531283439413068694552738675989282017066737438591268502070364982899342633928417" - "210588531e-2", - "9." - "26624413643579136646620112107410908114766812511471130116341925013001661546817531064974089666536893346764523464" - "250445838e-1", - "7." - "05664607841658050248613256866289182754229289446384595719719495272020558391145537620968819401219414243210529013" - "148958366e-1", - "-3." - "79761093422301890838671114556341706055562482358183402807224298533060188038450560241345615647754569347252101282" - "386222173e-1", - "-9." - "99965058979463689113370264378210962384824970050865061898892508056811665771886385589295806419278045318841717598" - "003331419e-1", - "-3." - "95173919871548266286836251448043149039940610894391718791244019288314418437411707835924620250473697245151743147" - "215758686e-1", - "6." - "93720251624319621941983929806434090162802383400620564454074825718151625795576680427510026452063593762417421561" - "201654156e-1", - "9." - "32780816819880202610269817418700102084277332259524791943833699964920012022753227823298655560837271746316929623" - "378078695e-1", - "2." - "91495208658083070508005579692813621670878962971611104453227900103973434149303469066898102622556226584993895360" - "896300290e-2", - "-9." - "10191043170480685360743788297835112117551819731152897291272407935139876953384666161532187572493791297095784055" - "525159185e-1", - "-7." - "34513075127503122343910106816656237074878218180284276449954797048122379869002663646507706411949095015624141821" - "039453971e-1", - "3." - "40971254411713599427147477626159847871020791931107106418841144080445813896332252160005593096670674809345703079" - "384115052e-1", - "9." - "98752871506016936810666998588493462933191829230756181478046320353377054175122206889047094521687205093218701141" - "334147081e-1", - "4." - "33024359542714849537532946954507232835434973891665238942502273464321666207117525270650546741831354943253652514" - "490075246e-1", - "-6." - "63175408268187738636594884921931867786416057472876635147295424128144233911929585327601381618059327766986981109" - "409782838e-1", - "-9." - "46960160806563725719808910991708075372282242401645009270517113290439792088443109178772446465191984149998211903" - "724560065e-1", - "-7." - "06828182905581345108929510344440443421290640066613022421187316650733628538705972455891575947230299102119854983" - "197703150e-2", - "8." - "92183656127948379886438402777950080111433733329436790239129260607557296960582455582584117031260710927499215646" - "838011844e-1", - "7." - "62091330231640362984555508176991632755732840163230620595759320390970951235395195394649584713540498911356433919" - "369698423e-1", - "-3." - "01591765120371930643555588643712101466544136366607065361801475091335195383846047491935017919396438040414024941" - "341524187e-1", - "-9." - "95813515236177554177387795413035497724212540625760091518605741283184405719984044075159457509720410668598540884" - "613985023e-1", - "-4." - "70125959152223022135690700550251564040118601846181392455764893020377582359429013073566263451488554529709131439" - "092909247e-1", - "6." - "31483718775865440843182928017874708719203714677143270278178885379757350754752477512514449375355491054871712891" - "789652146e-1", - "1." - "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" - "000000000", - "3." - "87481045630097871028201331640164477694000480353342897357083794605539506785023570062767753819472037935010414476" - "627195076e-1", - "-6." - "99716878554812023132822640034166338740077082416915046841339368979161296335086955803240899441098534898926193252" - "558848693e-1", - "-9." - "29735101124991407032113033015438177585645722877060262785796302722011806301680288369763295777635760805579255008" - "366302180e-1", - "-2." - "07925797310208845709174899248298159909010721767168338004516304026594885686024530923209628704670627250569637267" - "490913462e-2", - "9." - "13621640053945104047985280883096238900189007462190433514805702721127019097915088259906184736442916334750420359" - "005079959e-1", - "7." - "28814716527795995795780587639833705107995825167970668466246348938821997240383021826681253777014938636567626203" - "524137506e-1", - "-3." - "48817863192357573536083313907744269588018702862402502601699983054718835012048372083235768555953613790431700360" - "695537918e-1", - "-9." - "99135337256258278958854200595331742602280601557283993231562055717063052179292021052372510863057206152466386086" - "657442382e-1", - "-4." - "25474147219713305654097901385832164424798803616095278869643928816776198489330071073326518019520590535564717523" - "756486665e-1", - "6." - "69409002349720857726983952566596052122726437391092096671257338244059819036586172017092390651026654050631669646" - "310910927e-1", - "9." - "44240747589054266930136705015787520728797286842746645573763175559132491628984502333043316023599487896169049499" - "868916865e-1", - "6." - "23417820549832676844933182722733277887833220127638406914080428946880981800946578131712749910941183940944526141" - "109771339e-2", - "-8." - "95928229794837090592434136137683839101829890460754766346170956577979909285084363961363023377587044303560652568" - "203578379e-1", - "-7." - "56652196635835430995109388017590459596111729342964992503572530290981857981790620732129221157071082788019187787" - "999930361e-1", - "3." - "09551461133309219674309651201007026752336319933918953736299690287371505733386433918863300129026763968979930342" - "098019300e-1", - "9." - "96542844308353945757715814452637400116215448012622700698887257177706625278927018059066920597035660000571997275" - "705962011e-1", - "4." - "62731465522276407764000677957978862104808823938378826581864482071733508960062598574638347814740748458034065235" - "894523010e-1", - "-6." - "37943500095315456672541800050589670140910744260281868746767523730582697622604545933849801882909439609368258115" - "114388202e-1", - "-9." - "57113494461990955768932962010819183910065445494138937651443249061391692258872250121438832853873660881630205561" - "168895590e-1", - "-1." - "03783175146302830356973378710923690121182237844646430783773333188328606275124873219756415071202025673009660963" - "930966273e-1", - "8." - "76685468012988943166112725030293740012198666616661362437433807594683780986916439696374569274720383546275206733" - "493672834e-1", - "7." - "83181178815072182812568575402104911406191663934571600092749188502783771503475038116599065276589122015600004250" - "624262132e-1", - "-2." - "69749743842835294071354429049113807280228918034124159074991560056663623624511602063409428877143567459307323934" - "051784210e-1", - "-9." - "92227004420417932443416371636723983768124774541445787394585828303853075015733744933294181104002649816119116502" - "663362907e-1", - "-4." - "99188570507651271652464431008309802023236218596632956064119419694573621896525872847587264755853127438644874992" - "889777436e-1", - "6." - "05374785886620830935500306718810628353011877048386199574451402773468315797082901705593423724389976967865835641" - "164117478e-1", - "9." - "68331080574540181354402420018944004334504868848934676984951546671476956051983469715128604348963016773169794077" - "158289730e-1", - "1." - "45045093347669933436797325432376656017480150281100519869038554695618054318368975927557872948037203212941966706" - "926758604e-1", - "-8." - "55926631706799584065153976496431313099942493164544290051315786450857575707615522517293656706329757352795226750" - "189755758e-1", - "-8." - "08355785820466703104647317116964786017731181599256098405978700298563758509572188640629418770593008092680980412" - "866065299e-1", - "2." - "29481541445091823694157468006983283649885473964756916206813927875661041834620526229807744443043682778028709792" - "615798955e-1", - "9." - "86195281084368344446227722442335005500018635181693920385626820970119467136148305491035657795704047666385553672" - "680209923e-1", - "5." - "34782415974986828906369231191245075731384342252264783019973387059318216570499447505623911253042567598873910043" - "381675873e-1", - "-5." - "71759181631212640256161075896307515511612057247572886814941945052483422285718810088660759708176904381865453799" - "197101481e-1", - "-9." - "77874107069129472007009478090869879295520839405452365411822873037906082086100232576241983901051327761231156641" - "104065497e-1", - "-1." - "86056181372276495846711248156316208757691570931906856005697361080864028851991674077024223201008430626166447144" - "444086146e-1", - "8." - "33687619660983803179149188531271900120055171980951416163724579833511897001564116810390933587615557717585362295" - "882429826e-1", - "8." - "32132482562487183916482822112362004641509381783438374175226355792137053285527706239574867923387554339582561002" - "247202518e-1", - "-1." - "88816490768820368180947188938258919466912959009058295775702554895970560887437777994365295452696990115940651570" - "073217522e-1", - "-9." - "78458105113103660973458641126689066610890753079836635611789969774219913050456840122278188955139015473252491612" - "410972950e-1", - "-5." - "69451448580118869157805059117807250106203230622762838051154208713065707949727035884250775206017528612930773233" - "017928006e-1", - "5." - "37154819650306918873973169624898539483418364490295996462663218848771864764982600193558748568095521886456306061" - "269765631e-1", - "9." - "85726070946814004698231423834505649751779161578718404221294527194525251740198034173542003704080544827976936213" - "857653517e-1", - "2." - "26745517700332138489400566746499809209783385009289423848083137846668382711005704387134606000570923556980021574" - "851618566e-1", - "-8." - "10006890365888881023982873786181048364505748637138923322482323010218991062084191379116946709356002103893071903" - "481540337e-1", - "-8." - "54470151393449484710948210543666267680196067632693416660536443330720708402601669617638569732848938319544250428" - "600991723e-1", - "1." - "47824914922605209542648603104533928946885824995208478684499907657728115943168395067575842431291755277452367320" - "596435067e-1", - "9." - "69028856602232134498324179654622883463820270279077886397861028881882684131282848087869087883519707948141915733" - "221980948e-1", - "6." - "03135714281336943093251136556365407562473924416812270469171432809743173719168209727199952532489544254928975940" - "518615351e-1", - "-5." - "01621542149055350065079347615664213658089623368745676779267390227688581807037821041573344917735076902116221444" - "127518632e-1", - }}; - - boost::uintmax_t max_err = 0; - for (unsigned k = 0; k < data.size(); k++) { - static const T euler_gamma = static_cast( - "5." - "7721566490153286060651209008240243104215933593992359880576723488486772677766467093694706329174674951463144" - "7249807082480960504014486542836224173997644923536253500333742937337737673942792595258247094916008735203948" - "165670853233151776611528621199501507984793745085705740029921354786146694029604325421519e-1"); - T val = cos(euler_gamma * ((100 * k) - 5000)); - T e = relative_error(val, T(data[k])); - unsigned err = e.template convert_to(); - if (err > max_err) - max_err = err; - val = cos(-euler_gamma * ((100 * k) - 5000)); - e = relative_error(val, T(data[k])); - err = e.template convert_to(); - if (err > max_err) - max_err = err; - } - std::cout << "Max error was: " << max_err << std::endl; - BOOST_TEST(max_err < 5000000000ULL); - - static const boost::array near_one = {{ - "0." - "00110366261514314701760139373423242154915684721997331411894924799093985950797185797611128868398841547825787890" - "29173541058712364395631700458578107381027292873036746420205387223485877413957850165491398541686055903366332748" - "90874911975139498047488076101124170425114828336211817830671418321600962996502656221412102902998671173649312277" - "667706874059520046508702908872747388744526457997404065469953155187340837", - "0." - "00301570415724321900197177647763221470492248879133312120541736694616735167707691487355585402909157545142690977" - "99280330158745508542936966046640795712691698490758472574837678659161855207596563250546269614348515005196657786" - "35964602053723130112149272857741021255035007050242648280249045257241587921499420186440290159530972645802667288" - "8041860289772080407882673424767232857435141510615538430445535588448032261", - "0." - "00492773467417506941191096162314029013605001850224827873626164128562333386792088309741247498307937783239976846" - "40684587346403570647040211088376986993615001420565608501262335822815041623056442245053684626079448221530207757" - "67293904803094516494852132040157407480296626097590447877531473000279989504965298305212515143651158933512325458" - "2883803928373794668948878049089088843407672795237410750365571990834236348", - "0." - "00683974717571121080445443392813999685632538584115280163639002456100681615640914993980241106350898662127895834" - "03491711476788985949178019078796740862827299289838108117219486357027460681238178010067475221327133396780718266" - "88054027293686018578397693756990377816017022516632892020169982747289382436383843962743718776515977026228293029" - "3057633886299749088561182830982345936603553661004526800797082995898813903", - "0." - "00875173467169001855272097602878830498126325132779978740284784353109833803345638909895616095616059746086966621" - "15691834835879797726785572307430505839752709777545184759704897411565241193788473054468453310985269625798043619" - "60647344836744631465315238254178161716870409320747176674142306881908614436607977326507761331050644035013756409" - "444911127742401762647885817361924274132830920030936589562922803846509607", - "0." - "01066369017204128630619294878289599088122703310476300562904756326253141837346523787668052900505853398101079375" - "94469668686284809087098124021790477748880947611042381318432390371672122064698944855990857172168556376203187234" - "57013401360290343196462723174177342294339229792213396006286331141933952648238459364417067676760977202812721209" - "681621184724443514062993874571816382775241753902032787099435678672474841", - "0." - "01257560668681178111677881586444664374671816674492792378513923371024001720173762508840686118578173962829321343" - "63233143767089335349337484367207215684622673170266885614381441138552901409251204353175061698564613866238289415" - "31577425811393721991195661429557079268566156800689149725770186985872449679872155877537432897653904213375816262" - "709009448220490217917537801655330411526526290708967440087145630462068976", - "0." - "01448747722619079813723045783566494487281080221130834268505563740030547402155202849377855910255202538088047710" - "30651876883379317135405575623739914318802515536209478369407265445536477399941573009672629419769333751159466292" - "04615918888689039777423610894099269527633757403818072000860056651445780074486612843419789636984117740884711882" - "675016016919064788076097669389652323393864660933705259163296837955978748", - "0." - "01639929480053571479848938435852490010528683615442189056243891786250141194724503798645591969636530166611241489" - "00972464797621494569628096385882454669885840933802635455430234110872033519486815599053360100669006671017871388" - "62856447778428938265451537422367650992162004154495705878092019403922006152498705687706013973674800621422751806" - "347308220226407830977673540994341535381202679482907460136241543505771361", - "0." - "01831105242039754437253785820100114508391422302962227147815985292569212444264024710033626204144036041239231890" - "25582951084525131234541035045166074987638637282847972029789754092641411388617381844682575761572045523836754427" - "80049333490201800526935793000727771598103735596829143729912656158790924063286176336412427525710457367751437348" - "230246446466833498557166002214984255422115833828533909144072330080184872", - "0." - "02022274309654648882733319123724659176063973070470414879500960262717528101345886555723824083020397369049288293" - "55531115197594748355566868125534301344427130576222743485105269313331244379284820013012147761113588480261646884" - "47150395879262705323533149853785508106018564787140458587165768350143018847840661371060583295055600185059031740" - "386698369796694993301139380463919242175430688496936048982929502368583755", - "0." - "02213435983999749088040606072701436212579363086495183327060157486170002544810918630175583386283034397310018118" - "09957519245146115781496877328088402123991347355593551168167003461966850579164614448891791171428078588835744260" - "62415931319905031345377305247124198345242221848293630112578508459623098934259229893301963120289071135120089672" - "338617200639338087265986570094025605269870532431816151660553037324591448", - "0." - "02404589566203578515770662377856932950543269950417165906429674776176194691029507429183882698171279236828234955" - "39051759968586459672801354175774888106515947766265622526867584638138207910315805797217822517056005708380441583" - "57396828391251385978824608388341556751951593319015721256942139947235672567093309227673005475237474351604086627" - "391812539914665025071874865132198040631867741985556198082915821590691115", - "0." - "02595734357424244836428547904034421154921442177233640890479169021044982558086884122972893790914113611665289447" - "54769914714945245010358099562882470108614643020661542547364254604680243505715847804892130564280985606863769995" - "62953811729945811217829999284678155635497607933780499844559793793320393174691097636750027421158473345884329284" - "455326733063073401001936304522649050748641723222539485352644237494855455", - "0." - "02786869658851994837340013731772800760858742770166896433084496039323296265934708860449270625153048714880568350" - "58831528822041777234043074653243834084187165792805158719497902045861718859817616990663010094101768016350039611" - "67315448162116236938093263170474354430610732127054993766008385425707409224417795873645410443727472246508894027" - "549288331903202127478347028519320691939639175445464091747341289465807076", - "0." - "02977994771711769214064161695942308897505915896467130739365457176349155359058255901528353353298601861402999585" - "42787480391551770888394144504544095712671107207133742883636708046922893947708040511825104959003229152946134791" - "46430103948686457060129295537542317247965142780968717375277053102667416124807987527429828758851341378395347636" - "356414345553353015296944031211364374602764176767114282660874356057979248", - "0." - "03169108997265757234968007548831539092664261419258315028339932724609641378752993073240305448323210275610250474" - "04838751800329369142967019031683971889264747515160555711385296692528872255726174898100171764266107573499374851" - "05062771657304722076477636782048137141940828525026216230072442146056460947877309925103189247723289581298576409" - "53691466395972638014259980360897599169526022683004620965496473543834477", - "0." - "03360211636815951269623302604906544623950481693175472231431690699171989413559977782675060918501864763374802360" - "26625685533644552537419947015117524785061756714490298591935833323809242981643506270237972180985394412289864926" - "01142199774579432202424360114528105854714450548265654769162069979862894518829365029262734944196495563243510942" - "310738160350648115273816371164862001848102516957052031698646996790510953", - "0." - "03551301991706701171686466579169359170126622106906614298872651683203672861330045700640329960138592297328557312" - "41476697176184865709868600085643096416579431727579124515065727834498305861638144775027203410108701192310305116" - "64725149033496023356743601581035789746158436049009960920433265660001864258067191594425969638702851317416487965" - "304378219676062220223886417078628342731900948906319081697480745936074075", - "0." - "03742379363327268506923016328909941054820146048508325058481589054569550176063473734802710692115534956480532122" - "22828247090725822341858495644406700008475715613593246298773686202227758560685692785905828435500960966275101092" - "10574429458414697641703261368397349100700647508781941466979105505468662952228018391181441110331804231754679360" - "190526351574820397399161022517352576803713854137820941977691824804918229", - "0." - "03933443053114380617038441347727393691454078249067953255979519905208426335398124312840825908661959393894615829" - "41754657926335844215923500114551981248467781944172810056202589826152272348717806793272892320728587512853079553" - "84102986030326321993554199425677956531006546270705693578070953933490084008156062047268010604414954653769711129" - "551190023978078265436680151306319349753427763894284339669614362603225399", - "0." - "04124492362554784509978077138923576064529252794948104409449088377792129014065050432251647263718480321413071443" - "12794744044345131670885432021719221788741189679913017441868580545084734136471487442600574239310331779731191109" - "21967581379650616945061418716237102199971097086754171168500651650526166023618723542873290120298640370217463634" - "503988257867984189842393302366909916756244585593509804376197012137137735", - "0." - "04315526593187800567359162010550325021364842256850034799352917194217685500024708214705218927539412743238996642" - "76684131276653664897092296029263845883610711262970405471806229893952535182591977420538104193724523725065343132" - "64090033740095357809571640645325965973975968081307185286025492280541542290934505383760407808393490207181258819" - "590768103829347539943429968533891105456889889207923129412409325200337396", - "0." - "04506545046607876059698931384201095697288926962984099661854147107645614534157634603714073755408708959823265734" - "05418651083892582655114623077088559323082846108052090844134606145985700623540889311795879847020068475661624924" - "14964136182928014974554852612762940578089297583097434972291633301329615187665009664697057933900728259220674217" - "919826618275818024987757805509580781060051826778978395144370327934582031", - "0." - "04697547024467138460103306391634724027149630100803003888530052526798529225905129916603848616846213109692607792" - "06112549663229653956732213245062135934152631896673937271249784541251041922360043030563483207060910187819908031" - "64595039969574510002737990997634364247271320535459089400357647302806652831431190979518269432197656547265417669" - "309719787317687585776029758282182901563328846367691507505917911626458378", - "0." - "04888531828477948547081470344934277987415714118827253901246150779059879616984405442070140074728810386335100859" - "38343753360089524191612977876803559816725058844056452570946166834970404717219802416796169124837888440076494479" - "69703512155758482444019770785766752697959554691538291379700303132353876869628124563105576278585509058450081192" - "711918856522653293896204836307264696289474219755720645459588331890558889", - "0." - "05079498760415453287152397604443868847898854652227570259113516529507568483477506978208754021215531159992463221" - "68787173632790384062037479686375739946881463292967550237291705059309350281073595300429098223692456090916967040" - "70694133386183688825674952803613566914142157159664703170379754943610785780639205752343103591085978554489192416" - "588288410803225066825839880971435465232206429722600557780654218330146221", - "0." - "05270447122120138487910204431372351921454183084429433900200615029500026180362977793066820271387562936891401261" - "38401801741565983990969846058420009177093308938713659612428128606330221326634350788694332623710622005553335085" - "65564704972551921154864927879748108180002977668648111714062992755985320189721615088748697314805428967770533095" - "416911693326757965362169171309026356339280576158225848771071227224373815", - "0." - "05461376215500381212216030595761814768611374506398965060717916315739882081771507944926880218936299871925694703" - "55415525248394971197218845368652407050174034090533016251526851516447613344098971998100935050975286508977292790" - "62117617766845257388412635800174656504897022571125534403010151970450307624961920347280823962725005822339087173" - "498538012712497715370388872960900453285934131578336748483622553313648565", - "0." - "05652285342535001944185033812422642040437262822947495473031646122402927979344912114894183015570585636429065529" - "66960088653490586503962976679517456392663449939111112720760195224763152549209314694063810887403924363529971787" - "77214659473302034620137440843681809428909274912969436139312159105442160243076856936138443854294531618433726198" - "293972487505166088883354213979143973990964298454127970039847456893860203", - "0." - "05843173805275816497637986494243039655597709873498601130932141310480208079882403956546152160835512210202272546" - "12202699672516198433948606410706219514337657633697616589168168808681882750324531371842116739340792772855939351" - "59478757148621410070196500221526968060556586710920750728824112282461003224923995158937905479480579208549847478" - "185757177039153501786271361921802927586114942206193581554801605680183774", - "0." - "06034040905850187657687905840671755037544989792286634902461253137367772496569289676345169003475021480739308606" - "02321839627418934556308002825287060946343124978678631942529144550621275446719094245053675595036498904775701167" - "67021509485710626043408265846213906257952113003324887350087083283630715857354116849013376841533857321740197047" - "217435805280085872071354373524395263864933170034771001607559366437835689", - "0." - "06224885946463576546133123915706193746686049729742751789281333411875145041642253752249398319274836506892916659" - "69433184976628447281196360778248899395966991394244099581633952977765674029786747119154090952068012290915918241" - "18034413910654682971112744820893477373223133341441618370357576610552838101432388468114962860869260750080684897" - "24098160672664550444107807861952850135669761489736449089327971794824585", - "0." - "06415708229402093701329214110827358506893318568172280658617313651296908656115100058608322882770447492213365936" - "82084994285175609372677112875582758563258517355270475255491356028099539243462323935753545053415164088770347951" - "44989051337120442048812961016500803766780090428411925756071299228254760633032932651170483895163866111455935100" - "454818941073761804284777739005007991141161823471943803047351369535073521", - "0." - "06606507057035049863213234230316493277441147645258154898838614545430984417078463121990068754537566972606241127" - "82101488337618870758893826317113197620667175188427872735431439698741770593860032625169412151682349972454207359" - "13778365997498382320917159517052861653706668051150014889560865161606396037665048820655743861710636504450723955" - "435275019348223982732095398949832565423361714391500479155224225613768011", - "0." - "06797281731817506454154824375449801542992858851651718382231326444687963568209311338426499328040848278019304768" - "73703058923091067488755194865408790201429023623072376896846970637922258381117422417147898236012519982993312540" - "97504567214769822096812914869886418586879378868131071702869283011709161582762527864014863950459121468893761825" - "841337802563429112718615110803469902519051203360473993644451463303576859", - "0." - "06988031556292825746309809836256267170918370639812214696909812917947237945553998427031788938272567855131467803" - "09025157821882038023624602140701923786663113697307559126706609703784082848764651923563403352772254577760915159" - "34608751710356445501169982098020701963512215973413220903547301855847279762573955110834619967590588317288171580" - "291576756417265600792610005176888567344924086299458709493921684370833814", - "0." - "07178755833095220706153105320773939112422621828807137340295968530357389407193799909693128341539738529630622848" - "41287261252235682927601107630757396121741828401481935175403793028969383753577447548318855704822998029852785256" - "92833941172622048860945698352794727105726197891701070706523197225463566498764869186174536278875440544967870368" - "440256565084805804998877012238900798874720340885805165811704445925369809", - "0." - "07369453864952304506868897057861922170414313661538863465614770246556638808351254050794164760581857499175318127" - "11774559759504639945373741523496609046081938327833818426551829439358931606743429630732087351487337553449900089" - "55070929201231627937227422789029562631786758739801210895258148401153007301244579596320133604797765542622108017" - "98434607194598511786777350540581826836696200671400628870250659962729555", - "0." - "07560124954687639699277293596304007783475912288726432487682674659729850704257079531594037895736964666654561692" - "79300466771796467221875578604425060251105419682574060526796046818920865179516481122017670290446371423349377861" - "45563391280677987040697732028896674786378870229133792190093646530752257521390201161387698590619925316803401938" - "362974478273195688740273778224688121208296858072701246429755713258468481", - "0." - "07750768405223287031977884485736048308798866580915737599480523539069522794527382684233591697126224532246386169" - "89879884914330927594156206857548134562479892871579096013767421416478866843804733794030673439776333476556837458" - "71434202230624968375294472571053679501320680048739346844244553807193670436672857163839591129928936603341033670" - "518982144557944158002407590669543043048232580344768659176122645763500513", - "0." - "07941383519582353911391928459278913150807428005691345661714886319007726058418647615016810176603269249958501957" - "23000094771073423257318060035396457497209982600748940055032437157777881877545502864883169663206237074038469739" - "34258796072434720381188302956748572794547906591019552569722211941807674118070825610462581312695693650893380241" - "875873254675082431417454526920871842555422162216221640850141209989864308", - "0." - "08131969600891542492386209238973689981181951147511231088791689043624679770473070467372905608832478409692135372" - "17910551025638125923751893468163489526216032488275289234339985975584783667126582356569246017749210950793565658" - "67874041683517103417362062033545480747089630436317004907748679995334911923789802669273406449877710501792905734" - "235548100216242648355048174292232350538531258791292074224222773259366265", - "0." - "08322525952383697390162947648382688257049509740972294821115665187141191592634769844331760632491209501384638614" - "48480760193349830603239963645756222312841563713112098033838682976660271427764926047134514011163049519160373513" - "15288808149328656282592946622481248077426878390562084748274992526750980236994304445617883874613002677387890383" - "751048690275480465558930319669630406765794141303531112767626885032234711", - "0." - "08513051877400353004101543337101216212359033856529771289945157227404487085813240168529498972643275680825161819" - "88094971170314287542241824637681893339926104117503242492837866476059645935565808414886861893743107033284906383" - "78071341189999989736919850819640255203388192531225871093915262442913255553964348789674386732423763999398384843" - "950222967487918049677831350991752153610543052586794779289758903475438463", - "0." - "08703546679394280444239338094358977387480738413770177780775585860655580609004531379334974366769766649578482854" - "02475876273815815456209187951078777150862279321927561447800868565156412981955582044847281155194455147327555721" - "78929839231921546119143469647706999890259163924570037168105911942268212237224359201159897493303064534985539474" - "450028748960081579369980283792804593122976296597796047722827878891322393", - "0." - "08894009661932034051080045448189717964378771450498890477954943042290588204478205437582890610045687999231364014" - "49342424181294006797068656443166644580619536848566073418116675764181633398433720412953227097970078716047404914" - "53013916791024918954258557372755707588171502529270934617054742841996068375532958173787119651672031238405892943" - "090742861150287144368470297356054911834742041692715934237148148936307154", - "0." - "09084440128696497499419978007502428517353424061697293830856612400231817615623334333379765277125022803359776734" - "08464760942108132997230663449555424552468973029459083367564645821898293353150553185091716230723825736561729913" - "07091055717376996812421994002305994837615827430425975713541786272473174908117299253875064746541808768776888139" - "494200307162476704515967971265236163183394620211890252072718610942571965", - "0." - "09274837383489429476883724801361486954592004075766677188979226434736733592228398794408137035693921479951082255" - "86389354861121903597017906627929257731868976712448319714504749520366189378337068990060484697912131299223027984" - "62311426294239282200248625552430083292818594731518350634587677158329361662244008606299358410273467156168469937" - "529868888478684257396004386633746334360279683178784117372066095688934486", - "0." - "09465200730234008927862485697316713821725813756576269941336416399395064198979833690322405942579887230845186693" - "07808428784355038323663162451591540443505177273126549804552901635140218608020282519819547245802922478878511856" - "39950862672925642859475325430465650514258094310141033116303195908372018392349011340787373492402788283020594141" - "795669947097771918542864972570255253465754192708165241608041715996375567", - "0." - "09655529472977379853549858833033074225823562054271495313739665642376685099661084023094270272485976247900824483" - "81091163463581955833463091026735332002926133029697729272026665530851355953058684355022920851738878978301188745" - "08654885541434753025903539157323216634180575675730425948018662589483806840007690913531658799531110462605327968" - "91917772727185993569684246844052518121013717183610828519193371796413317", - }}; - - T half_pi = static_cast( - "1." - "57079632679489661923132169163975144209858469968755291048747229615390820314310449931401741267105853399107404325" - "66411533235469223047752911158626797040642405587251420513509692605527798223114744774651909822144054878329667230" - "6423782411689339158263560095457282428346173017430522716332410669680363012457064"); - - max_err = 0; - for (unsigned k = 0; k < near_one.size(); k++) { - static const T euler_gamma = static_cast( - "5." - "7721566490153286060651209008240243104215933593992359880576723488486772677766467093694706329174674951463144" - "7249807082480960504014486542836224173997644923536253500333742937337737673942792595258247094916008735203948" - "165670853233151776611528621199501507984793745085705740029921354786146694029604325421519e-1"); - T val = cos(half_pi - (euler_gamma + k) / 523); - T e = relative_error(val, T(near_one[k])); - unsigned err = e.template convert_to(); - if (err > max_err) - max_err = err; - val = cos(-half_pi + (euler_gamma + k) / 523); - e = relative_error(val, T(near_one[k])); - err = e.template convert_to(); - if (err > max_err) - max_err = err; - } - std::cout << "Max error was: " << max_err << std::endl; -#if defined(BOOST_INTEL) && defined(TEST_FLOAT128) - BOOST_TEST(max_err < 8000); -#else - BOOST_TEST(max_err < 750); -#endif - - // - // Test with some exact binary values as input - this tests our code - // rather than the test data: - // - static const boost::array, 8> exact_data = { - {{{0.5, static_cast("0." - "877582561890372716116281582603829651991645197109744052997610868315950763274213947405794" - "184084682258355478400593109053993")}}, - {{0.25, static_cast("0." - "96891242171064478414459544949418919980413419028744283114812812428894256118452332726465" - "5202799685025510352709626116202617")}}, - {{0.75, static_cast("0." - "73168886887382088631183875300008454384054127605077248250768322022075008250156949954096" - "7562610201174960122884908227300721")}}, - {{std::ldexp(1.0, -20), static_cast("0." - "9999999999995452526491135703469013368438582357746312643224146889053936" - "5027135494672267164697779879113636143901797362388")}}, - {{2, static_cast("-0." - "41614683654714238699756822950076218976600077107554489075514997378196493612407916907453177" - "7860169140367366791365215728559")}}, - {{5, static_cast("0." - "28366218546322626446663917151355730833442259225221594493035906658615145676738270228617698" - "1668344573238827368717546699737")}}, - {{10, static_cast("-0." - "8390715290764524522588639478240648345199301651331685468359537310487925868662707684009337" - "12760422138927451054405350243624")}}, - {{8.5, static_cast("-0." - "602011902684823615348426522956998700296067763604355235396366061455725158767706195460253" - "51418378467287262574566665150299")}}}}; - max_err = 0; - for (unsigned k = 0; k < exact_data.size(); k++) { - T val = cos(exact_data[k][0]); - T e = relative_error(val, exact_data[k][1]); - unsigned err = e.template convert_to(); - if (err > max_err) - max_err = err; - val = cos(-exact_data[k][0]); - e = relative_error(val, exact_data[k][1]); - err = e.template convert_to(); - if (err > max_err) - max_err = err; - } - std::cout << "Max error was: " << max_err << std::endl; - BOOST_TEST(max_err < 20); - - BOOST_TEST(cos(T(0)) == 1); -#if defined(BOOST_INTEL) && defined(TEST_FLOAT128) - BOOST_TEST(fabs(cos(half_pi)) < 4 * std::numeric_limits::epsilon()); -#else - BOOST_TEST(fabs(cos(half_pi)) < std::numeric_limits::epsilon()); -#endif - -#include "sincos.ipp" - max_err = 0; - for (unsigned k = 0; k < sincos.size(); k++) { - T val = cos(sincos[k][0]); - T e = relative_error(val, sincos[k][2]); - unsigned err = e.template convert_to(); - if (err > max_err) - max_err = err; - } - std::cout << "Max error was: " << max_err << std::endl; - BOOST_TEST(max_err < 20); - - if (has_poor_large_value_support::value) { - T bug_value = 12 / std::numeric_limits::epsilon(); - for (unsigned i = 0; i < 20; ++i, bug_value *= 1.1) { - BOOST_TEST(cos(bug_value) == 1); - } - } -} - -int main() { -#ifdef TEST_BACKEND - test< - boost::multiprecision::number>(); -#endif -#ifdef TEST_MPF_50 - test(); - test(); -#endif -#ifdef TEST_MPFR_50 - test(); - test(); -#endif -#ifdef TEST_MPFI_50 - test(); - test(); -#endif -#ifdef TEST_CPP_DEC_FLOAT - test(); - test(); -#ifndef SLOW_COMPLER - // Some "peculiar" digit counts which stress our code: - test>>(); - test>>(); - test>>(); - test>>(); - test>>(); - test>>(); - test>>>(); - test>>>(); -#endif -#endif -#ifdef TEST_FLOAT128 - test(); -#endif -#ifdef TEST_CPP_BIN_FLOAT - test(); - test, boost::long_long_type>>>(); -#endif - return boost::report_errors(); -} diff --git a/libs/multiprecision/test/test_cos_near_half_pi.cpp b/libs/multiprecision/test/test_cos_near_half_pi.cpp deleted file mode 100644 index bf6c8a9b6..000000000 --- a/libs/multiprecision/test/test_cos_near_half_pi.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2002 - 2011. -// 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 -// -// This work is based on an earlier work: -// "Algorithm 910: A Portable C++ Multiple-Precision System for Special-Function Calculations", -// in ACM TOMS, {VOL 37, ISSUE 4, (February 2011)} (C) ACM, 2011. http://doi.acm.org/10.1145/1916461.1916469 - -#ifdef _MSC_VER -#define _SCL_SECURE_NO_WARNINGS -#endif - -#include -#include -#include -#include "test.hpp" - -#if !defined(TEST_MPF_50) && !defined(TEST_MPF) && !defined(TEST_CPP_DEC_FLOAT) && !defined(TEST_FLOAT128) && \ - !defined(TEST_CPP_BIN_FLOAT) -#define TEST_MPF_50 -#define TEST_CPP_DEC_FLOAT -#define TEST_FLOAT128 -#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 - -#include - -#if defined(TEST_MPF_50) -#include -#endif -#ifdef TEST_CPP_DEC_FLOAT -#include -#endif -#ifdef TEST_FLOAT128 -#include -#endif -#ifdef TEST_CPP_BIN_FLOAT -#include -#endif - -template -void test() { - typedef boost::multiprecision::number> - mpfr_float_1000; - - for (int n = -20; n <= 20; ++n) { - std::cout << "Testing n = " << n << std::endl; - T boundary = boost::math::constants::half_pi() * n; - T val = boundary; - for (unsigned i = 0; i < 200; ++i) { - mpfr_float_1000 comparison(val); - comparison = cos(comparison); - T found = cos(val); - T expected = T(comparison); - BOOST_CHECK_LE(boost::math::epsilon_difference(found, expected), 20); - // std::cout << std::setprecision(10) << val << std::endl; - // std::cout << std::setprecision(50) << found << std::endl; - // std::cout << std::setprecision(50) << comparison << std::endl; - // std::cout << std::setprecision(50) << expected << std::endl; - val = boost::math::float_next(val); - } - val = boundary; - for (unsigned i = 0; i < 200; ++i) { - val = boost::math::float_prior(val); - mpfr_float_1000 comparison(val); - comparison = cos(comparison); - T found = cos(val); - T expected = T(comparison); - BOOST_CHECK_LE(boost::math::epsilon_difference(found, expected), 20); - } - } -} - -int main() { -#ifdef TEST_MPF_50 - test(); - test(); - boost::multiprecision::mpfr_float::default_precision(50); - test(); - boost::multiprecision::mpfr_float::default_precision(100); - test(); -#endif -#ifdef TEST_CPP_DEC_FLOAT - test(); - test(); -#ifndef SLOW_COMPLER - // Some "peculiar" digit counts which stress our code: - test>>(); - test>>(); - test>>(); - test>>(); - test>>(); - test>>(); - test>>>(); - test>>>(); - // Check low multiprecision digit counts. - test>>(); - test>>(); -#endif -#endif -#ifdef TEST_FLOAT128 - test(); -#endif -#ifdef TEST_CPP_BIN_FLOAT - test(); - test(); - test, boost::long_long_type>>>(); -#endif - return boost::report_errors(); -} diff --git a/libs/multiprecision/test/test_cosh.cpp b/libs/multiprecision/test/test_cosh.cpp deleted file mode 100644 index 0764abe8b..000000000 --- a/libs/multiprecision/test/test_cosh.cpp +++ /dev/null @@ -1,393 +0,0 @@ -/////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2002 - 2011. -// 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 -// -// This work is based on an earlier work: -// "Algorithm 910: A Portable C++ Multiple-Precision System for Special-Function Calculations", -// in ACM TOMS, {VOL 37, ISSUE 4, (February 2011)} (C) ACM, 2011. http://doi.acm.org/10.1145/1916461.1916469 - -#ifdef _MSC_VER -#define _SCL_SECURE_NO_WARNINGS -#endif - -#include -#include -#include "test.hpp" - -#if !defined(TEST_MPF_50) && !defined(TEST_MPF) && !defined(TEST_BACKEND) && !defined(TEST_CPP_DEC_FLOAT) && \ - !defined(TEST_MPFR) && !defined(TEST_MPFR_50) && !defined(TEST_MPFI_50) && !defined(TEST_FLOAT128) && \ - !defined(TEST_CPP_BIN_FLOAT) -#define TEST_MPF_50 -//# define TEST_MPF -#define TEST_BACKEND -#define TEST_CPP_DEC_FLOAT -#define TEST_MPFI_50 -#define TEST_FLOAT128 -#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_50) -#include -#endif -#if defined(TEST_MPFR_50) -#include -#endif -#if defined(TEST_MPFI_50) -#include -#endif -#ifdef TEST_BACKEND -#include -#endif -#ifdef TEST_CPP_DEC_FLOAT -#include -#endif -#ifdef TEST_FLOAT128 -#include -#endif -#ifdef TEST_CPP_BIN_FLOAT -#include -#endif - -template -void test() { - std::cout << "Testing type: " << typeid(T).name() << std::endl; - static const boost::array data = {{ - "1." - "05601911274598447512590381143952412839655905253029178781664646797295627642392664834198240236790418665694318420" - "53263976225991679105269492268050148624443706785607467750929028856273183654547152707568642275917435773104050171" - "28458077394931390630307481158609621477187980187222550023754072559228816790398715200717139120768003451766421896" - "5133028298959753155835975555361514087618679892905973726581183754237665", - "6." - "05779176509744960239810393466946892048509279589412265077753665894155880302328307581392220107160990591557998531" - "88868489737439396141346120898610181630988217093945337280471788812956307352429914669334599644412036010014302812" - "55570090549006203066648238700838485664553310026620512293045549623425247887894967588812261579545107652124477155" - "4025667181070733415815608287241160724578541982548132473721865287585003", - "383." - "32956577005424506758441449272199796616394738942294350035763341369127219359132618750028176886177362785452836065" - "73588972009869993736599262024616796537678896317165953035019819015627583654728543736601237117591049083582338935" - "27169814645036727498291835695505095615791814340884076522134211056933589601960444479481908235672911533970397598" - "20680087749250557665869797605969680417240900163183563482342795870741", - "180470." - "88335034971169904627554690213669106779370247753503772451628313223853228134148123711258586005038324156900626143" - "04738338277308316418851540976695284329448459866830479918641141132957536754633273119043116661326787117700849392" - "14166497926465680967899714660643449228736431204467593286384477815049329287459745841360396982206040998168778470" - "80168890581112550484205291341188894903342677757367415636409890558", - "6." - "27814979541895132876192971751427700258260524769556003234957905309469004062097894372129233818308898465786517939" - "22971071825731424267985994598149826652782605981764572599129753631344305259620294513472869937699509893247230674" - "85002506654766456326395867202986798129602985567509594758730594963413073611869404060857398156019256993547746212" - "1110619100122692626135788198431038121227062383110684489973794745342204e8", - "1." - "61378311475085211322322671024463457408265436342793174717797061014256003543481932366519797827079570761159096101" - "95029060790302619201096497489621259308501986256217927638422240968232992503387509534910044087310828806601256416" - "28213970297576817341593254767125933119462446651783267917469179893016103516988279473907996009458208097272806046" - "395206212403180775656514566222835047724943633607736647735739948551096e13", - "3." - "06512100486509488695311966713424774152266431233506177152689718348818346151389259085187035845064471384366136323" - "41330640449725016173384960626760387649747643297918807083363913015806893683786389067836005832038060734248371426" - "88680817555421031775601884610962757254631417249270154434596594040877757051931283786001417787275435866246342393" - "9942202520475422342889660750666147940146262635303938752019875745307992e18", - "4." - "30168936021062158647714344640257355471929568870505370146962315269547133313517913760695066887951593166251544581" - "15179050297716224800318064110052445970764898870599885508391064218065806885129697936678362276766771902589638957" - "53716833919048827355575387616263323799046261795589223842440212435312473687947465197742235085664298644659194116" - "3073842974714357745162365700428610167249762162775568692443158879770006e24", - "4." - "46086859296813600010249357918906616555060494871223312224917892771380830925078449334838584683411076136574487830" - "43064935174812965310544903547535217357996429824403225005261842368679242972243707736489629610256554995236901040" - "77390296237013098988396029898780800800165165079989226776108930213274903706949745230907438984649314022293171461" - "8697738906019885122076310868220596765753447232222740129365498326869428e31", - "3." - "41813159558168064725693574411003900295360033129819319540917443049744915277436012850174566244872649299710227465" - "16079644284683284072159616291298593217459064246713801084801182706805865477209408120733740982340972570739267039" - "63058246887607557470618711564386144993942950373060674346608601011512746470631579176526457207045280081605459065" - "3675962889901898843712936126341807733200610910325052666512334161414655e39", - "1." - "93529462827279081014145302127852497636407769190524801588816591906251667334497709126264426283293489997182437317" - "16720372493614918444193023235879429151628596659929166256368132445762101099318527619217199876328555966639074943" - "03248513195744818730879742963301327852160193919379798462926667740594397712731448572837824802330973561570848397" - "758210619453310032286208701226098998940360395267237151018055781640126e48", - "8." - "09644495118900985658414964360164316516923077647027842349017414081353813746684390209864706759411109236144469056" - "96411023621632714191313583360826598468217983223558130595633054971338824192327248896500337050246640453410159732" - "18441909691717104407571115686780485101838857637153052094369643991767372045091172546678123534721270084970274262" - "5663288687644090935756560022610000629006347244369388824818661974220426e57", - "2." - "50282570926251745491750089522225691418163836379049816443794738582507368961742165396737335216276072093220194134" - "20937570273676341726636307131078699799472622998437404149614292337267153201903296102921815263736653035269935857" - "81615908649659426918708244224428089825839704704574672872907979616798789536861403777028637119153057581469585943" - "3478185016171380286325273493350193132538052551497175771289873181595171e68", - "5." - "71683702137926499674663153128641796628951701926950507890613628395108364181246459680329891490683110189943245174" - "20345278843446068634292140996241291031113395887832891095928020095581695527354104986223411349657526888924224926" - "67568203204336327977494797605389581967100327640029775835977970360597050732870606469292348116867675199912407369" - "7599262277247814864401196929320497117521176016017349797292609303756215e79", - "9." - "64872611696700312079558418997293865027081250983947778086151839273421639092840259922432010204359151226988086497" - "11566042372911206942311277943247994427354130507790526857797833309691667380623792736661655695464087154725768656" - "50760337805322021206789491468614730155076404533751236147883103499967429683763574434403990673410956090879392156" - "8633128400104314078575159786136202769893309913175064586488844295321363e91", - "1." - "20329776602386082325370051588516683110899862359654632492203777786384899723559748482090350823338223099022371650" - "42868213438627625544096344578102199846440476859557339736747791529782018329078191477783605471526120466881600981" - "86989037991787881169155531644884273108521898871057121195697201642464975822660650060319497296603203621421375999" - "1156778846329137084961334557845326183588274571457361004704490747798678e105", - "1." - "10883060812782887544924011308975902624045718132814606056838361396692812184425014219355331706369908661651816645" - "61596333701204545493730707210930818738817252706131805203538144119244917164949716209095542194899833868499263375" - "70031393425715560127552692130233211800996665099162487822710826507921949736677021914109805096502300591949504802" - "2616553249266192057652205987267068584616625670961423579715954410508985e119", - "7." - "54998805916259656638680428326753009017992457324185017076467921355120532848351382947969760486916683154424278349" - "49618514094329533376442442492757936744857569785450769927581802961191319878260712808001736830227501518832554201" - "81622420730061431071243047053802294895743300482972527306792144363552696567397141204969355200425982017338968164" - "7135125678701502084190660111860351299407405357314966388044340723077086e133", - "3." - "79853635800679762402503301653007069582698268515493717324602209234598228090079184957804121097003783527039828995" - "61570150646963751463572075768540297484136809462018052149545042828665345287117150392150513078663739946623681053" - "68505465037259587291440042344663580680646178313958620437868058550744621854406884524675301085056534185211101772" - "8985713047360191412931479535524815646071456825031827933342626130249175e149", - "1." - "41213193415725812702153598487066305427766336757115296875934873462592839607080956014948231124866310237211242356" - "40943167173029348028743563902367757599140008654691320430919753414890689949599421028277624880392344132646738394" - "54619563826127968754320850393217292627529421842908681656021339918017949400410916454684489963238517783544294617" - "4689070525154077366030192931540897742543089509897490703511310531249977e166", - "3." - "87903077199979745106643397442602333738810961999331522026625565567797837751065639869118595264132820552586125224" - "99767709123313205863879946518297779104337686883587019222829967005608205535314284003183828513113021722123872387" - "03643511351735667644737671559540817955526787194767167909898665166571927934802505871381779687679591584415171910" - "3197410787508530261619841035613531488383930867055908047961915279983259e183", - "7." - "87336053738358403974345232640385984056728299256511658470656683243854307460876333488489056378354287394014396798" - "96923081980364912472282573695612463537585283007941057172128277340402716645674443632827653710173742423648839359" - "54777769477857667560464588021983337522794199842632588655843521435502224085456355886408062775865343942991707275" - "3785194675103766900514602432580639079224631229479607396935864512990879e201", - "1." - "18082629950389009425178914579262000630180796953484697627255203778763700057715189542510153384028860976897628950" - "44056273430051256244413916763438966705458118354189107806216991150264176024521937328179762640422127608560103802" - "43167214486601321640515719770978848419772005770211878816878981607456020807826043354828388153590907111655389789" - "3659656781376448427981358955547508806938614921874867135186509274509121e221", - "1." - "30858174999878426551305488271689556558384321402452281696918922677077787904987739148331993689161140439661973295" - "62444577848635313938483757629541576533880917215885485474416704968999200090496252044959849927443732134176975867" - "86998601131597562586800906537304622471606316897778810386688572047109554738534286863201895191060393683578938746" - "4412366605713487321530237148912677199033012777178113821791621549557963e241", - "1." - "07153081480068991619038813538296440692171211386826580344130515756045616495762614285688880942186204446350132207" - "05511245290719605273316790249367622122178650529000528086055415007045458486410501636380119413632657994999412652" - "18843006312847033681740148217258036637407933129512920093624644634783238060635329385822275868747961292718153023" - "6387227215663399410099251455256898414199913458340065553949424990477448e262", - "6." - "48331965100630950223764050595501238429357093260235378484937789053462018029627222607642449009757709351188650397" - "35904093764776116679888935421171735987167888371792653849212017720136116318927292508358228044947423163304066884" - "75091973437669111728949960922002370308207819760146543720499389938855072810566961589413895110830251224194598788" - "696990065693705615156654866578134664648091752361824241438921952031149e283", - "2." - "89853913045427682931727097752307679814777215288854083053556195306901194262072695630497568249393971572218777755" - "31212262059946098575425050827283362457005503261796116156917077778477251551070762614233325253060283603452216492" - "68153183915464923208092878706633839991585032738161467245610237424895021024826679607245762337007919557432284659" - "4267768883120374288952014885152055438195794090975578878933873824774214e306", - "9." - "57524433627083921372674145950563946532138741951042299439035158875449060589509856903496678820625880407684156184" - "67576300179061328983586984432582196507026188089413820743600336619502440390216246792909515578785240971073577534" - "74909093111963153327116805520444674581696153661168724694358406085344894253222472789266720597479112669810243669" - "89976214521515026692183039600169984107883592297128416659318858313127e329", - "2." - "33727345033623693753810095241973508303164720347217597617975362377386704710094235435422515724882290456995981608" - "34162677357730620072441755506075897500940629883044875771104686291523502165266242030847074909362622098365719455" - "33235993874613862916130471738526530998089807948995995515764456623244080513770107131149565333060607161133194124" - "6434767948905863368638163788562679785940566685500460815077065003612487e354", - "4." - "21558791269371992409699094485991868684847178872987296051500332991235349928573329181681352308437386959256983838" - "15575417820480732378749635394939513838137876524333991937836847074991505476867647762082587225838063325020413513" - "07712832158143942900148597775176579801110109207261305368742298335214046856917156477394123225605706416114234166" - "1775359191159220450305300322654184921617310753474842253496677498824723e379", - "5." - "61818116133757012489702243782567404946920662424376026524697405127382975992354145939996168919451561868277363261" - "84687322137498447792007445397397290336810468925670064733464757082986791232916898141597610692740388799796632396" - "70814902724343685975252680511277879064509655577022780987369558996980567860110615755638697422164766959082771235" - "3133603091803570183764883405340587430017053183637835511899658145649708e405", - "5." - "53251106928220535092383018707346612727458446719546860788676375087729439299366382143215888575356349523813139437" - "38654286540526043262643301046462576597601613866207167167036316086433126132458046255118139642751094515137365585" - "14977338129201153666764317441936156609643185133981728847167450887861106642311329612564652645663234240748195490" - "808151911497393974690166034839217817023634217121406163178148652748479e432", - "4." - "02566663067613312406532171367315316230170176957139429170278517627053463573307885864114313789720099805323107576" - "89380174461664677676028378924382554201434975574729861177781849023768222381429947872325368088023224591306630434" - "88752921545958076086307590768624852116859030963646844864851375289385176731569346963898087464845711433555720211" - "5472595647478331668869318302753802858726588719006447471192697846325955e460", - "2." - "16442373466816634246017817691597979198342453652307355890587969859747455944859888559714139368208719357146022376" - "43458356241187573307428309041919648027960168541647193436225977495680484218384107820095589356463058222584008532" - "49706917999367853343113123362931285077152897044363460429014314907920951386813058571300608073348849116032114573" - "5562062411305931183571279530201672366980412430529846635995189699318073e489", - "8." - "59875809811959836620472472169360664857317603153715063860770566914095798560147630326195395399352997161104116887" - "93466397984311640631361934500807639285587334983206556915704635831992012926186843826981296831658998834850783404" - "71305082909375312618955662509599462160530004719996233209885723635980168115741960667641219878309281636433604730" - "6243999363335004760439115355072350465422891365411868472688286678516314e518", - "2." - "52416731631871272761346107169547241622702902287736417344208646182452119260176248298406858601305792577721263986" - "22324109858115624706486522844752512951837805396709793171502497523431473021570806024043139443284538862368635312" - "79953910826408402803273129548728218861682026168963492642713506088794279763514769384995005867275345857647649173" - "3064455826768562371858057444914175251596852571637211466017938478085247e549", - "5." - "47506791182338766132594205708195704492779627444127804280501483514467832109262303414703151880706323497607310257" - "42570791702834581720467527197241529413168425211960698044258765079274184234095237392617266811206620971599430494" - "01039490818332686968135012747332468921142470970507219403290422458185430415836291605355383658657658638112408092" - "789126678938878667507151950931633694006471359998448912249374833586727e580", - "8." - "77505496899502567766394687245741586296033200143902756810286745508263570801364223994762134327913766562227638006" - "28593282303459051561266270006921840049305819767639184391149913915312831894296821356222752594264134130151457242" - "71353924842188383735344218172453070693322015850724076032518206800155329494926859617841863416432387497193799707" - "2367419479635154591248667559627811893588163238012665671798461211917208e612", - "1." - "03920001583377732737511565764160246646536796899738563734563048433393029779232542383764970440277281580589033023" - "90909588333829463843362779584402914847447592731182614369968957680281500946805571235013941407979569788567794900" - "81025715443359295816754518668713781010184800010733507448605095938797451641465463887974096617578601649279784516" - "9374594168995878543584318334800124941205910589727264397237600733483158e646", - "9." - "09363267536367272405745466788391706650191691109438788949330932115559769957014680414493273700736818986906384661" - "36204694745206283652338526673125958055131610409923286526192661778126811265116493171283319361595267283588121098" - "34970395192966928196667559689026648386421759155570755276556575684270105614429007586789352037941952177591304796" - "4393758374891516340929062076304350159966063972713118995033247759001609e679", - "5." - "87982816369304899641620094290092578679067925080588016270421219535999129512653159337234401858255190801029880568" - "36911095299854840387008575164090793635997912930561430335216151607097220208013034399895832350235280120270626904" - "35619693516670177376868031106326438089133102151451875783922081850690599784722878343901525276805516616594158203" - "0353226255576433910936297965207260585437762430381969160714956727596198e714", - "2." - "80918812929111084043459758968155589584778352607377945794172845124134733889680575870885550412662974868419236287" - "02282019643659456724373332519583025947015025975126598748630623031951723754960589046233996595466021913942587558" - "32666059306319790528857335355910688464528553149762694037980050047428244692923791456853466586870374273171363234" - "9090897884403966643055728471509474896855575286123275564417626861566706e750", - "9." - "91712937259767113206767386673924623817974241723106406296023286672533757528193859721207369716800015502715814816" - "58616174000808376999687855051075798318036855160548374473251503888674887541706772280965242243924102322062382639" - "33144338637103531441623303187445874039234973380151391274490746625993568552049954630793219419614845431626975962" - "881182662815760423226111647056071831411664335144052772436215105801395e786", - "2." - "58690271635431111218786799870816477151878728266773984750967386405836598000689673795513763221703475374549181906" - "03891312949716382621902484616361664158953484778255247083652726854621059785392022847887382779010079407502679229" - "02108532067590310957376933127741337227236321889639796566258135788673969137620431690897408182198043217806539422" - "8926767529685562155837452626029223937027004015040825450642409597700449e824", - "4." - "98612519312070809237856867988817891938138796108426752053612101558947746863287108939065436824470292069289349675" - "25495260314937837003448878215156341411477636831113484416124080974502217578408248150338565305116223944900839866" - "52862296035272393854871331942579845334540299214607886805326360623407444302415524345062363472091243884102296990" - "9473424559262711669905282193529250216454066716533180418518228387188393e862", - "7." - "10125690143390682411017512339532342165228402803424065209092882320127995478719607237198365163595481988427495369" - "61644100550279020276709043358260853581760590386456213180291689322352732545965831405519844109680619067101311180" - "95939933992270659609852696914898117351986513950866563131731042417837883337060592244909474551081261856381353734" - "7841030916512147874232760564378443782164868016244561788356251308121716e901", - "7." - "47302153604866421354317547470748853778401956835830182548925022450119737120842211168133644234928020807997681745" - "34590613188275471080608467087354983850284805514875889145266688973752185071777341375422809910165581997555433091" - "93995940656983118345987234477870709809494119348906153216024977585642656969612719345333954837167922967627266308" - "4782830276508737129506676031759345288056484158647796152349867328841634e941", - "5." - "81093753642091122275796546587309770308694543886070769036394659922966168320029641380009476688371405433259082226" - "88655359602408511410663722770167244801973012245657865182739637159804595049180263175014778215232564251739259624" - "75958995367766135610455483155107326366818828386112352168844513216414776232111159702852313009386415399997437679" - "0494383016372210442340324038686843345053322425194077414241243050491297e982", - "3." - "33875955701899627718146291382268063073604182131575843695486667154496711979350813988644889979275310892951143249" - "90139844785908367473984008445446585047577469632514214867193740710854025084590094114280015734566576140393088979" - "74248089795695503252715585184045590075516256377611426621077579137632219122829576817840535643871040623177297887" - "37215450574233690655931888608424916152893688106181220341997128198692e1024", - "1." - "41746728778233347096101173197688307390807344073539051456326120888249557201987349966042612500192919558836203335" - "45750761619015467840567122066622229379056280064206319780047687015558007624774062399477328822231085767309831266" - "03261605306585873937381865168712809333564038851339619111853718128033443029243918873752436226978927230890572381" - "2818882228503013875816702686587035844437102478263525616196832018321602e1067", - "4." - "44661890167910915168017238808125335284385970805494109112356556113820105031457892861587455557714835779436627687" - "73465284793798720178177605712848440200402906836390133865748188969184005230383247111166918721449908133920663776" - "95278668383703818043626473893735410115386717180431576947105030318212926944229235438803729812517794121792684580" - "3005587166270803697433886463469168814941555804311717400657004050157245e1110", - }}; - - T eg = static_cast( - "5." - "77215664901532860606512090082402431042159335939923598805767234884867726777664670936947063291746749514631447249" - "80708248096050401448654283622417399764492353625350033374293733773767394279259525824709491600873520394816567085" - "3233151776611528621199501507984793745085705740029921354786146694029604325421519e-1"); - - unsigned max_err = 0; - for (unsigned k = 0; k < data.size(); k++) { - const T x = eg + k; - T val = boost::multiprecision::cosh(x * x); - T e = relative_error(val, T(data[k])); - unsigned err = e.template convert_to(); - if (err > max_err) { - std::cout << x * x << std::endl; - max_err = err; - } - val = boost::multiprecision::cosh(-x * x); - e = relative_error(val, T(data[k])); - err = e.template convert_to(); - if (err > max_err) { - std::cout << x * x << std::endl; - max_err = err; - } - } - std::cout << "Max error was: " << max_err << std::endl; - BOOST_TEST(max_err < 2000); -} - -int main() { -#ifdef TEST_BACKEND - test< - boost::multiprecision::number>(); -#endif -#ifdef TEST_MPF_50 - test(); - test(); -#endif -#ifdef TEST_MPFR_50 - test(); - test(); -#endif -#ifdef TEST_MPFI_50 - test(); - test(); -#endif -#ifdef TEST_CPP_DEC_FLOAT - test(); - test(); -#ifndef SLOW_COMPLER - // Some "peculiar" digit counts which stress our code: - test>>(); - test>>(); - test>>(); - test>>(); - test>>(); - test>>(); - test>>>(); - test>>>(); -#endif -#endif -#ifdef TEST_FLOAT128 - test(); -#endif -#ifdef TEST_CPP_BIN_FLOAT - test(); - test, boost::long_long_type>>>(); -#endif - return boost::report_errors(); -} diff --git a/libs/multiprecision/test/test_round.cpp b/libs/multiprecision/test/test_round.cpp deleted file mode 100644 index ff33c6bf2..000000000 --- a/libs/multiprecision/test/test_round.cpp +++ /dev/null @@ -1,466 +0,0 @@ -// (C) Copyright John Maddock 2007. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifdef _MSC_VER -#define _SCL_SECURE_NO_WARNINGS -#endif - -#include -#include -#include -#include -#include -#include -#include "test.hpp" - -#if !defined(TEST_MPF_50) && !defined(TEST_MPF) && !defined(TEST_BACKEND) && !defined(TEST_CPP_DEC_FLOAT) && \ - !defined(TEST_MPFR) && !defined(TEST_MPFR_50) && !defined(TEST_MPFI_50) && !defined(TEST_FLOAT128) && \ - !defined(TEST_CPP_BIN_FLOAT) -#define TEST_MPF_50 -#define TEST_MPFR_50 -#define TEST_MPFI_50 -#define TEST_BACKEND -#define TEST_CPP_DEC_FLOAT -#define TEST_FLOAT128 -#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_50) -#include -#endif -#ifdef TEST_MPFR_50 -#include -#endif -#ifdef TEST_MPFI_50 -#include -#endif -#ifdef TEST_BACKEND -#include -#endif -#ifdef TEST_CPP_DEC_FLOAT -#include -#endif -#ifdef TEST_CPP_BIN_FLOAT -#include -#endif -#ifdef TEST_FLOAT128 -#include -#endif - -#ifdef BOOST_MSVC -#pragma warning(disable : 4127) -#endif - -boost::mt19937 rng; - -template -T get_random() { - // - // Fill all the bits in T with random values, - // likewise set the exponent to a random value - // that will still fit inside a T, and always - // have a remainder as well as an integer part. - // - int bits = boost::math::tools::digits(); - int shift = 0; - int exponent = rng() % (bits - 4); - T result = 0; - while (bits > 0) { - result += ldexp(static_cast(rng()), shift); - shift += std::numeric_limits::digits; - bits -= std::numeric_limits::digits; - } - return rng() & 1u ? T(-ldexp(frexp(result, &bits), exponent)) : T(ldexp(frexp(result, &bits), exponent)); -} - -template -typename boost::disable_if_c::value>::type check_within_half(T a, - U u) { - BOOST_MATH_STD_USING - if (fabs(a - u) > 0.5f) { - BOOST_ERROR("Rounded result differed by more than 0.5 from the original"); - std::cerr << "Values were: " << std::setprecision(35) << std::setw(40) << std::left << a << u << std::endl; - } - if ((fabs(a - u) == 0.5f) && (fabs(static_cast(u)) < fabs(a))) { - BOOST_ERROR("Rounded result was towards zero with boost::round"); - std::cerr << "Values were: " << std::setprecision(35) << std::setw(40) << std::left << a << u << std::endl; - } -} -template -typename boost::enable_if_c::value>::type check_within_half(T a, - U u) { - BOOST_MATH_STD_USING - if (upper(T(fabs(a - u))) > 0.5f) { - BOOST_ERROR("Rounded result differed by more than 0.5 from the original"); - std::cerr << "Values were: " << std::setprecision(35) << std::setw(40) << std::left << a << u << std::endl; - } - if ((upper(T(fabs(a - u))) == 0.5f) && (fabs(static_cast(u)) < fabs(a))) { - BOOST_ERROR("Rounded result was towards zero with boost::round"); - std::cerr << "Values were: " << std::setprecision(35) << std::setw(40) << std::left << a << u << std::endl; - } -} - -// -// We may not have an abs overload for long long so provide a fall back: -// -inline unsigned safe_abs(int const& v) { - return v < 0 ? static_cast(1u) + static_cast(-(v + 1)) : v; -} -inline unsigned long safe_abs(long const& v) { - return v < 0 ? static_cast(1u) + static_cast(-(v + 1)) : v; -} -inline unsigned long long safe_abs(long long const& v) { - return v < 0 ? static_cast(1u) + static_cast(-(v + 1)) : v; -} -template -inline typename boost::disable_if_c::value, T>::type safe_abs(T const& v) { - return v < 0 ? -v : v; -} - -template -void check_trunc_result(T a, U u) { - BOOST_MATH_STD_USING - if (fabs(a - u) >= 1) { - BOOST_ERROR("Rounded result differed by more than 1 from the original"); - std::cerr << "Values were: " << std::setprecision(35) << std::setw(40) << std::left << a << u << std::endl; - } - if (abs(a) < safe_abs(u)) { - BOOST_ERROR("Truncated result had larger absolute value than the original"); - std::cerr << "Values were: " << std::setprecision(35) << std::setw(40) << std::left << a << u << std::endl; - } - if (fabs(static_cast(u)) > fabs(a)) { - BOOST_ERROR("Rounded result was away from zero with boost::trunc"); - std::cerr << "Values were: " << std::setprecision(35) << std::setw(40) << std::left << a << u << std::endl; - } -} - -template -void check_modf_result(T a, T fract, U ipart) { - BOOST_MATH_STD_USING - if (fract + ipart != a) { - BOOST_ERROR("Fractional and integer results do not add up to the original value"); - std::cerr << "Values were: " << std::setprecision(35) << " " << std::left << a << ipart << " " << fract - << std::endl; - } - if ((boost::math::sign(a) != boost::math::sign(fract)) && boost::math::sign(fract)) { - BOOST_ERROR("Original and fractional parts have differing signs"); - std::cerr << "Values were: " << std::setprecision(35) << " " << std::left << a << ipart << " " << fract - << std::endl; - } - if ((boost::math::sign(a) != boost::math::sign(ipart)) && boost::math::sign(ipart)) { - BOOST_ERROR("Original and integer parts have differing signs"); - std::cerr << "Values were: " << std::setprecision(35) << " " << std::left << a << ipart << " " << ipart - << std::endl; - } - if (fabs(a - ipart) >= 1) { - BOOST_ERROR("Rounded result differed by more than 1 from the original"); - std::cerr << "Values were: " << std::setprecision(35) << std::setw(40) << std::left << a << ipart << std::endl; - } -} - -template -void test() { - BOOST_MATH_STD_USING - - for (int i = 0; i < 1000; ++i) { - T arg = get_random(); - T r = round(arg); - check_within_half(arg, r); - BOOST_TEST(r == round(arg + 0)); - r = trunc(arg); - check_trunc_result(arg, r); - BOOST_TEST(r == trunc(arg + 0)); - T frac = modf(arg, &r); - check_modf_result(arg, frac, r); - - if (abs(r) < (std::numeric_limits::max)()) { - int i = iround(arg); - check_within_half(arg, i); - BOOST_TEST(i == iround(arg + 0)); - i = itrunc(arg); - check_trunc_result(arg, i); - BOOST_TEST(i == itrunc(arg + 0)); - r = modf(arg, &i); - check_modf_result(arg, r, i); - } - if (abs(r) < (std::numeric_limits::max)()) { - long l = lround(arg); - check_within_half(arg, l); - BOOST_TEST(l == lround(arg + 0)); - l = ltrunc(arg); - check_trunc_result(arg, l); - BOOST_TEST(l == ltrunc(arg + 0)); - r = modf(arg, &l); - check_modf_result(arg, r, l); - } - -#ifdef BOOST_HAS_LONG_LONG - if (abs(r) < (std::numeric_limits::max)()) { - boost::long_long_type ll = llround(arg); - check_within_half(arg, ll); - BOOST_TEST(ll == llround(arg + 0)); - ll = lltrunc(arg); - check_trunc_result(arg, ll); - BOOST_TEST(ll == lltrunc(arg + 0)); - r = modf(arg, &ll); - check_modf_result(arg, r, ll); - } -#endif - } - // - // Test boundary cases: - // - if (std::numeric_limits::digits >= std::numeric_limits::digits) { - int si = iround(static_cast((std::numeric_limits::max)())); - check_within_half(static_cast((std::numeric_limits::max)()), si); - BOOST_TEST(si == iround(static_cast((std::numeric_limits::max)()) + 0)); - si = iround(static_cast((std::numeric_limits::min)())); - check_within_half(static_cast((std::numeric_limits::min)()), si); - BOOST_TEST(si == iround(static_cast((std::numeric_limits::min)()) + 0)); - si = itrunc(static_cast((std::numeric_limits::max)())); - check_trunc_result(static_cast((std::numeric_limits::max)()), si); - BOOST_TEST(si == itrunc(static_cast((std::numeric_limits::max)()) + 0)); - si = itrunc(static_cast((std::numeric_limits::min)())); - check_trunc_result(static_cast((std::numeric_limits::min)()), si); - BOOST_TEST(si == itrunc(static_cast((std::numeric_limits::min)()) + 0)); - - si = iround(static_cast((std::numeric_limits::max)() - 1)); - check_within_half(static_cast((std::numeric_limits::max)() - 1), si); - si = iround(static_cast((std::numeric_limits::min)() + 1)); - check_within_half(static_cast((std::numeric_limits::min)() + 1), si); - si = itrunc(static_cast((std::numeric_limits::max)() - 1)); - check_trunc_result(static_cast((std::numeric_limits::max)() - 1), si); - si = itrunc(static_cast((std::numeric_limits::min)() + 1)); - check_trunc_result(static_cast((std::numeric_limits::min)() + 1), si); - } - if (std::numeric_limits::digits >= std::numeric_limits::digits) { - long k = lround(static_cast((std::numeric_limits::max)())); - check_within_half(static_cast((std::numeric_limits::max)()), k); - BOOST_TEST(k == lround(static_cast((std::numeric_limits::max)()) + 0)); - k = lround(static_cast((std::numeric_limits::min)())); - check_within_half(static_cast((std::numeric_limits::min)()), k); - BOOST_TEST(k == lround(static_cast((std::numeric_limits::min)()) + 0)); - k = ltrunc(static_cast((std::numeric_limits::max)())); - check_trunc_result(static_cast((std::numeric_limits::max)()), k); - BOOST_TEST(k == ltrunc(static_cast((std::numeric_limits::max)()) + 0)); - k = ltrunc(static_cast((std::numeric_limits::min)())); - check_trunc_result(static_cast((std::numeric_limits::min)()), k); - BOOST_TEST(k == ltrunc(static_cast((std::numeric_limits::min)()) + 0)); - - k = lround(static_cast((std::numeric_limits::max)() - 1)); - check_within_half(static_cast((std::numeric_limits::max)() - 1), k); - k = lround(static_cast((std::numeric_limits::min)() + 1)); - check_within_half(static_cast((std::numeric_limits::min)() + 1), k); - k = ltrunc(static_cast((std::numeric_limits::max)() - 1)); - check_trunc_result(static_cast((std::numeric_limits::max)() - 1), k); - k = ltrunc(static_cast((std::numeric_limits::min)() + 1)); - check_trunc_result(static_cast((std::numeric_limits::min)() + 1), k); - } -#ifndef BOOST_NO_LONG_LONG - if (std::numeric_limits::digits >= std::numeric_limits::digits) { - boost::long_long_type j = llround(static_cast((std::numeric_limits::max)())); - check_within_half(static_cast((std::numeric_limits::max)()), j); - BOOST_TEST(j == llround(static_cast((std::numeric_limits::max)()) + 0)); - j = llround(static_cast((std::numeric_limits::min)())); - check_within_half(static_cast((std::numeric_limits::min)()), j); - BOOST_TEST(j == llround(static_cast((std::numeric_limits::min)()) + 0)); - j = lltrunc(static_cast((std::numeric_limits::max)())); - check_trunc_result(static_cast((std::numeric_limits::max)()), j); - BOOST_TEST(j == lltrunc(static_cast((std::numeric_limits::max)()) + 0)); - j = lltrunc(static_cast((std::numeric_limits::min)())); - check_trunc_result(static_cast((std::numeric_limits::min)()), j); - BOOST_TEST(j == lltrunc(static_cast((std::numeric_limits::min)()) + 0)); - - j = llround(static_cast((std::numeric_limits::max)() - 1)); - check_within_half(static_cast((std::numeric_limits::max)() - 1), j); - j = llround(static_cast((std::numeric_limits::min)() + 1)); - check_within_half(static_cast((std::numeric_limits::min)() + 1), j); - j = lltrunc(static_cast((std::numeric_limits::max)() - 1)); - check_trunc_result(static_cast((std::numeric_limits::max)() - 1), j); - j = lltrunc(static_cast((std::numeric_limits::min)() + 1)); - check_trunc_result(static_cast((std::numeric_limits::min)() + 1), j); - } -#endif - // - // Finish off by testing the error handlers: - // - T result; -#ifndef BOOST_NO_EXCEPTIONS - BOOST_CHECK_THROW(result = static_cast(iround(static_cast(1e20))), boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(iround(static_cast(-1e20))), boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(lround(static_cast(1e20))), boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(lround(static_cast(-1e20))), boost::math::rounding_error); -#ifdef BOOST_HAS_LONG_LONG - BOOST_CHECK_THROW(result = static_cast(llround(static_cast(1e20))), boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(llround(static_cast(-1e20))), boost::math::rounding_error); -#endif - if (std::numeric_limits::has_infinity) { - BOOST_CHECK_EQUAL(static_cast(round(std::numeric_limits::infinity())), - std::numeric_limits::infinity()); // See C99 Annex F. - BOOST_CHECK_THROW(result = static_cast(iround(std::numeric_limits::infinity())), - boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(iround(-std::numeric_limits::infinity())), - boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(lround(std::numeric_limits::infinity())), - boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(lround(-std::numeric_limits::infinity())), - boost::math::rounding_error); -#ifdef BOOST_HAS_LONG_LONG - BOOST_CHECK_THROW(result = static_cast(llround(std::numeric_limits::infinity())), - boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(llround(-std::numeric_limits::infinity())), - boost::math::rounding_error); -#endif - } - if (std::numeric_limits::has_quiet_NaN) { - BOOST_CHECK((boost::multiprecision::isnan)(round(std::numeric_limits::quiet_NaN()))); - BOOST_CHECK_THROW(result = static_cast(iround(std::numeric_limits::quiet_NaN())), - boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(lround(std::numeric_limits::quiet_NaN())), - boost::math::rounding_error); -#ifdef BOOST_HAS_LONG_LONG - BOOST_CHECK_THROW(result = static_cast(llround(std::numeric_limits::quiet_NaN())), - boost::math::rounding_error); -#endif - } - BOOST_CHECK_THROW(result = static_cast(itrunc(static_cast(1e20))), boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(itrunc(static_cast(-1e20))), boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(ltrunc(static_cast(1e20))), boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(ltrunc(static_cast(-1e20))), boost::math::rounding_error); -#ifdef BOOST_HAS_LONG_LONG - BOOST_CHECK_THROW(result = static_cast(lltrunc(static_cast(1e20))), boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(lltrunc(static_cast(-1e20))), boost::math::rounding_error); -#endif - if (std::numeric_limits::has_infinity) { - BOOST_CHECK_EQUAL(static_cast(trunc(std::numeric_limits::infinity())), - std::numeric_limits::infinity()); - BOOST_CHECK_EQUAL(static_cast(trunc(-std::numeric_limits::infinity())), - -std::numeric_limits::infinity()); - BOOST_CHECK_THROW(result = static_cast(itrunc(std::numeric_limits::infinity())), - boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(itrunc(-std::numeric_limits::infinity())), - boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(ltrunc(std::numeric_limits::infinity())), - boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(ltrunc(-std::numeric_limits::infinity())), - boost::math::rounding_error); -#ifdef BOOST_HAS_LONG_LONG - BOOST_CHECK_THROW(result = static_cast(lltrunc(std::numeric_limits::infinity())), - boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(lltrunc(-std::numeric_limits::infinity())), - boost::math::rounding_error); -#endif - } - if (std::numeric_limits::has_quiet_NaN) { - BOOST_CHECK((boost::multiprecision::isnan)(trunc(std::numeric_limits::quiet_NaN()))); - BOOST_CHECK_THROW(result = static_cast(itrunc(std::numeric_limits::quiet_NaN())), - boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(ltrunc(std::numeric_limits::quiet_NaN())), - boost::math::rounding_error); -#ifdef BOOST_HAS_LONG_LONG - BOOST_CHECK_THROW(result = static_cast(lltrunc(std::numeric_limits::quiet_NaN())), - boost::math::rounding_error); -#endif - } - if (std::numeric_limits::digits >= std::numeric_limits::digits) { - BOOST_CHECK_THROW(result = static_cast(itrunc(static_cast((std::numeric_limits::max)()) + 1)), - boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(itrunc(static_cast((std::numeric_limits::min)()) - 1)), - boost::math::rounding_error); - } - if (std::numeric_limits::digits >= std::numeric_limits::digits) { - BOOST_CHECK_THROW(result = static_cast(ltrunc(static_cast((std::numeric_limits::max)()) + 1)), - boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(ltrunc(static_cast((std::numeric_limits::min)()) - 1)), - boost::math::rounding_error); - } -#ifndef BOOST_NO_LONG_LONG - if (std::numeric_limits::digits >= std::numeric_limits::digits) { - BOOST_CHECK_THROW( - result = static_cast(lltrunc(static_cast((std::numeric_limits::max)()) + 1)), - boost::math::rounding_error); - BOOST_CHECK_THROW( - result = static_cast(lltrunc(static_cast((std::numeric_limits::min)()) - 1)), - boost::math::rounding_error); - } -#endif - if (std::numeric_limits::digits >= std::numeric_limits::digits) { - BOOST_CHECK_THROW(result = static_cast(iround(static_cast((std::numeric_limits::max)()) + 1)), - boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(iround(static_cast((std::numeric_limits::min)()) - 1)), - boost::math::rounding_error); - } - if (std::numeric_limits::digits >= std::numeric_limits::digits) { - BOOST_CHECK_THROW(result = static_cast(lround(static_cast((std::numeric_limits::max)()) + 1)), - boost::math::rounding_error); - BOOST_CHECK_THROW(result = static_cast(lround(static_cast((std::numeric_limits::min)()) - 1)), - boost::math::rounding_error); - } -#ifndef BOOST_NO_LONG_LONG - if (std::numeric_limits::digits >= std::numeric_limits::digits) { - BOOST_CHECK_THROW( - result = static_cast(llround(static_cast((std::numeric_limits::max)()) + 1)), - boost::math::rounding_error); - BOOST_CHECK_THROW( - result = static_cast(llround(static_cast((std::numeric_limits::min)()) - 1)), - boost::math::rounding_error); - } -#endif -#endif -} - -int main() { -#ifdef TEST_MPF_50 - test(); - test(); -#endif -#ifdef TEST_MPFR_50 - test(); - test(); -#endif -#ifdef TEST_MPFI_50 - test(); - test(); -#endif -#ifdef TEST_CPP_DEC_FLOAT - test(); - test(); -#ifndef SLOW_COMPLER - // Some "peculiar" digit counts which stress our code: - test>>(); - test>>(); - test>>(); - test>>(); - test>>(); - test>>(); - test>>>(); - test>>>(); -#endif -#endif -#ifdef TEST_CPP_BIN_FLOAT - test(); - test(); - test, boost::long_long_type>>>(); -#endif -#ifdef TEST_BACKEND - test< - boost::multiprecision::number>(); -#endif -#ifdef TEST_FLOAT128 - test(); -#endif - return boost::report_errors(); -} diff --git a/libs/multiprecision/test/test_test.cpp b/libs/multiprecision/test/test_test.cpp deleted file mode 100644 index 0cc82c72f..000000000 --- a/libs/multiprecision/test/test_test.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/////////////////////////////////////////////////////////////// -// 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 - -#ifdef _MSC_VER -#define _SCL_SECURE_NO_WARNINGS -#endif - -#include "test.hpp" -#include - -void proc_that_throws() { - throw std::runtime_error(""); -} - -int main() { - boost::multiprecision::cpp_dec_float_50 a1(1), a2(1), b(3), c(-2); - - BOOST_WARN(a1); - BOOST_WARN(a1 == b); - BOOST_CHECK(a1); - BOOST_CHECK(a1 == b); - BOOST_CHECK(boost::detail::test_errors() == 1); - --boost::detail::test_errors(); - - boost::multiprecision::cpp_dec_float_50 a_tol = - a1 + a1 * 100 * std::numeric_limits::epsilon(); - boost::multiprecision::cpp_dec_float_50 tol = - 100 * std::numeric_limits::epsilon(); - - BOOST_CHECK_CLOSE(a1, a_tol, tol * 102); // Passes - BOOST_WARN_CLOSE(a1, a_tol, tol * 98); // fails - BOOST_CHECK_CLOSE(a1, a_tol, tol * 98); // fails - BOOST_CHECK(boost::detail::test_errors() == 1); - --boost::detail::test_errors(); - - BOOST_CHECK_CLOSE_FRACTION(a1, a_tol, tol * 1.02); // Passes - BOOST_WARN_CLOSE_FRACTION(a1, a_tol, tol * 0.98); // fails - BOOST_CHECK_CLOSE_FRACTION(a1, a_tol, tol * 0.98); // fails - BOOST_CHECK(boost::detail::test_errors() == 1); - --boost::detail::test_errors(); - - BOOST_CHECK_EQUAL(a1, a2); - BOOST_WARN_EQUAL(a1, b); - BOOST_CHECK_EQUAL(a1, b); - BOOST_CHECK(boost::detail::test_errors() == 1); - --boost::detail::test_errors(); - - BOOST_CHECK_NE(a1, b); - BOOST_WARN_NE(a1, a2); - BOOST_CHECK_NE(a1, a2); - BOOST_CHECK(boost::detail::test_errors() == 1); - --boost::detail::test_errors(); - - BOOST_CHECK_GT(a1, c); - BOOST_WARN_GT(a1, a2); - BOOST_CHECK_GT(a1, a2); - BOOST_CHECK(boost::detail::test_errors() == 1); - --boost::detail::test_errors(); - - BOOST_CHECK_LT(a1, b); - BOOST_WARN_LT(a1, a2); - BOOST_CHECK_LT(a1, a2); - BOOST_CHECK(boost::detail::test_errors() == 1); - --boost::detail::test_errors(); - - BOOST_CHECK_GE(a1, a2); - BOOST_CHECK_GE(a1, c); - BOOST_WARN_GE(a1, b); - BOOST_CHECK_GE(a1, b); - BOOST_CHECK(boost::detail::test_errors() == 1); - --boost::detail::test_errors(); - - BOOST_CHECK_LE(a1, a2); - BOOST_CHECK_LE(a1, b); - BOOST_WARN_LE(a1, c); - BOOST_CHECK_LE(a1, c); - BOOST_CHECK(boost::detail::test_errors() == 1); - --boost::detail::test_errors(); - -#ifndef BOOST_NO_EXCEPTIONS - BOOST_CHECK_THROW(proc_that_throws(), std::runtime_error); - BOOST_CHECK_THROW(a1 + b + c, std::runtime_error); -#endif - BOOST_CHECK(boost::detail::test_errors() == 1); - --boost::detail::test_errors(); - - return boost::report_errors(); -} diff --git a/libs/zk/test/bench_test/CMakeLists.txt b/libs/zk/test/bench_test/CMakeLists.txt index 72e11a016..c784162db 100644 --- a/libs/zk/test/bench_test/CMakeLists.txt +++ b/libs/zk/test/bench_test/CMakeLists.txt @@ -35,8 +35,8 @@ macro(define_runtime_zk_test name) endmacro() set(RUNTIME_TESTS_NAMES - "bench_pedersen" - "bench_lpc" + "pedersen" + "lpc" ) foreach(TEST_NAME ${RUNTIME_TESTS_NAMES})