diff --git a/include/boost/multiprecision/cpp_double_float.hpp b/include/boost/multiprecision/cpp_double_float.hpp index 7c4a3281..6ae40ccb 100644 --- a/include/boost/multiprecision/cpp_double_float.hpp +++ b/include/boost/multiprecision/cpp_double_float.hpp @@ -394,11 +394,12 @@ class cpp_double_float cpp_double_float& operator*=(const cpp_double_float& other) { - rep_type p = exact_product(first(), other.first()); + rep_type tmp = exact_product(data.first, other.data.first); - p.second += first() * other.second() + second() * other.first(); + tmp.second += ( data.first * other.data.second + + data.second * other.data.first); - data = p; + data = tmp; return *this; } diff --git a/test/test_cpp_double_float_arithmetic.cpp b/test/test_cpp_double_float_arithmetic.cpp index 329ec104..803b965c 100644 --- a/test/test_cpp_double_float_arithmetic.cpp +++ b/test/test_cpp_double_float_arithmetic.cpp @@ -1,3 +1,5 @@ +#if 1 + /////////////////////////////////////////////////////////////////////////////// // Copyright 2021 Fahad Syed. // Copyright 2021 Christopher Kormanyos. @@ -52,7 +54,7 @@ struct control static constexpr int max_exponent10 = std::numeric_limits::max_exponent10; using double_float_type = boost::multiprecision::number, boost::multiprecision::et_off>; - using control_float_type = boost::multiprecision::number::digits10) + 1>, boost::multiprecision::et_off>; + using control_float_type = boost::multiprecision::number, boost::multiprecision::et_off>; using random_engine_type = std::linear_congruential_engine; @@ -127,7 +129,7 @@ struct control dist_exp ( 0, - unsigned(float(max_exponent10) * 0.15F) + unsigned(float(max_exponent10) * 0.30F) ); std::string str_exp = ((exp_is_neg == false) ? "E+" : "E-"); @@ -174,8 +176,25 @@ bool test_op(char op, const unsigned count = 10000U) const double_float_type df_a(str_a); const double_float_type df_b(str_b); - const control_float_type ctrl_a = control_float_type(double_float_type::canonical_value(df_a).first()) + control_float_type(double_float_type::canonical_value(df_a).second()); - const control_float_type ctrl_b = control_float_type(double_float_type::canonical_value(df_b).first()) + control_float_type(double_float_type::canonical_value(df_b).second()); + #if 0 + const control_float_type ctrl_a = control_float_type(double_float_type::canonical_value(df_a).crep().first.crep().first) + + control_float_type(double_float_type::canonical_value(df_a).crep().first.crep().second) + + control_float_type(double_float_type::canonical_value(df_a).crep().second.crep().first) + + control_float_type(double_float_type::canonical_value(df_a).crep().second.crep().second) + ; + const control_float_type ctrl_b = control_float_type(double_float_type::canonical_value(df_b).crep().first.crep().first) + + control_float_type(double_float_type::canonical_value(df_b).crep().first.crep().second) + + control_float_type(double_float_type::canonical_value(df_b).crep().second.crep().first) + + control_float_type(double_float_type::canonical_value(df_b).crep().second.crep().second) + ; + #else + const control_float_type ctrl_a = control_float_type(double_float_type::canonical_value(df_a).crep().first) + + control_float_type(double_float_type::canonical_value(df_a).crep().second) + ; + const control_float_type ctrl_b = control_float_type(double_float_type::canonical_value(df_b).crep().first) + + control_float_type(double_float_type::canonical_value(df_b).crep().second) + ; + #endif double_float_type df_c; control_float_type ctrl_c; @@ -208,7 +227,19 @@ bool test_op(char op, const unsigned count = 10000U) break; } - control_float_type ctrl_df_c = control_float_type(control_float_type(double_float_type::canonical_value(df_c).first()) + control_float_type(double_float_type::canonical_value(df_c).second())); + #if 0 + const control_float_type ctrl_df_c = control_float_type(double_float_type::canonical_value(df_c).crep().first.crep().first) + + control_float_type(double_float_type::canonical_value(df_c).crep().first.crep().second) + + control_float_type(double_float_type::canonical_value(df_c).crep().second.crep().first) + + control_float_type(double_float_type::canonical_value(df_c).crep().second.crep().second) + ; + #else + const control_float_type ctrl_df_c = control_float_type(double_float_type::canonical_value(df_c).crep().first) + + control_float_type(double_float_type::canonical_value(df_c).crep().second) + ; + #endif + + //const control_float_type ctrl_df_c = control_float_type(control_float_type(double_float_type::canonical_value(df_c).first()) + control_float_type(double_float_type::canonical_value(df_c).second())); const control_float_type delta = fabs(1 - fabs(ctrl_c / ctrl_df_c)); @@ -256,17 +287,46 @@ int main() #endif #if defined(CPP_DOUBLE_FLOAT_REDUCE_TEST_DEPTH) - constexpr unsigned int test_cases_float128 = 500U; + constexpr unsigned int test_cases_float128 = 1000U; #else - constexpr unsigned int test_cases_float128 = 10000U; + constexpr unsigned int test_cases_float128 = 20000U; #endif result_is_ok &= local::test_arithmetic (test_cases_built_in); result_is_ok &= local::test_arithmetic (test_cases_built_in); //result_is_ok &= local::test_arithmetic(test_cases_built_in); + //result_is_ok &= local::test_arithmetic> (test_cases_built_in); #ifdef BOOST_MATH_USE_FLOAT128 result_is_ok &= local::test_arithmetic(test_cases_float128); #endif return (result_is_ok ? 0 : -1); } + +#else + +/////////////////////////////////////////////////////////////// +// Copyright 2012 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt + +#ifdef _MSC_VER +#define _SCL_SECURE_NO_WARNINGS +#endif + +#include + +#include "test_arithmetic.hpp" + +// cd /mnt/c/Users/User/Documents/Ks/PC_Software/Test +// g++ -O3 -Wall -march=native -std=c++11 -I/mnt/c/boost/modular_boost/boost/libs/multiprecision/test -I/mnt/c/MyGitRepos/BoostGSoC21_multiprecision/include -I/mnt/c/boost/boost_1_76_0 test.cpp -o test_arithmetic.exe + +int main() +{ + using double_float_type = boost::multiprecision::number, boost::multiprecision::et_off>; + + test(); + return boost::report_errors(); +} + +#endif