Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge for 1.86 #628

Merged
merged 8 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,23 @@ jobs:
matrix:
include:
- { name: Collect coverage 1, coverage: yes,
compiler: gcc-12, cxxstd: '20', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '64', suite: 'github_ci_block_1' }
compiler: gcc-12, cxxstd: '20', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '64', suite: 'arithmetic_tests' }
- { name: Collect coverage 2, coverage: yes,
compiler: gcc-12, cxxstd: '20', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '64', suite: 'github_ci_block_2' }
compiler: gcc-12, cxxstd: '20', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '64', suite: 'cpp_int_tests' }
- { name: Collect coverage 3, coverage: yes,
compiler: gcc-12, cxxstd: '20', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '64', suite: 'functions_and_limits' }
- { name: Collect coverage 4, coverage: yes,
compiler: gcc-12, cxxstd: '20', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '64', suite: 'conversions' }
- { name: Collect coverage 5, coverage: yes,
compiler: gcc-12, cxxstd: '20', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '64', suite: 'performance' }
- { name: Collect coverage 6, coverage: yes,
compiler: gcc-12, cxxstd: '20', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '64', suite: 'misc' }
- { name: Collect coverage 7, coverage: yes,
compiler: gcc-12, cxxstd: '20', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '64', suite: 'compile_fail' }
- { name: Collect coverage 8, coverage: yes,
compiler: gcc-12, cxxstd: '20', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '64', suite: 'examples' }
- { name: Collect coverage 9, coverage: yes,
compiler: gcc-12, cxxstd: '20', os: ubuntu-22.04, install: 'g++-12-multilib', address-model: '64', suite: 'concepts' }

#timeout-minutes: 120
runs-on: ${{matrix.os}}
Expand Down Expand Up @@ -186,3 +200,15 @@ jobs:
- name: Upload coverage
if: matrix.coverage
run: ci/codecov.sh "upload"
env:
BOOST_CI_CODECOV_IO_UPLOAD: skip

- name: Upload coverage
if: matrix.coverage
uses: codecov/codecov-action@v4
with:
disable_search: true
file: coverage.info
name: Github Actions
token: ${{secrets.CODECOV_TOKEN}}
verbose: true
2 changes: 1 addition & 1 deletion doc/html/boost_multiprecision/indexes/s01.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id1243940"></a>Function Index</h3></div></div></div>
<a name="id1248604"></a>Function Index</h3></div></div></div>
<p><a class="link" href="s01.html#idx_id_0">A</a> <a class="link" href="s01.html#idx_id_1">B</a> <a class="link" href="s01.html#idx_id_2">C</a> <a class="link" href="s01.html#idx_id_3">D</a> <a class="link" href="s01.html#idx_id_4">E</a> <a class="link" href="s01.html#idx_id_5">F</a> <a class="link" href="s01.html#idx_id_6">G</a> <a class="link" href="s01.html#idx_id_7">H</a> <a class="link" href="s01.html#idx_id_8">I</a> <a class="link" href="s01.html#idx_id_9">L</a> <a class="link" href="s01.html#idx_id_10">M</a> <a class="link" href="s01.html#idx_id_11">N</a> <a class="link" href="s01.html#idx_id_12">O</a> <a class="link" href="s01.html#idx_id_13">P</a> <a class="link" href="s01.html#idx_id_14">R</a> <a class="link" href="s01.html#idx_id_15">S</a> <a class="link" href="s01.html#idx_id_16">T</a> <a class="link" href="s01.html#idx_id_17">V</a> <a class="link" href="s01.html#idx_id_18">X</a> <a class="link" href="s01.html#idx_id_19">Z</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>
Expand Down
2 changes: 1 addition & 1 deletion doc/html/boost_multiprecision/indexes/s02.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id1251007"></a>Class Index</h3></div></div></div>
<a name="id1255921"></a>Class Index</h3></div></div></div>
<p><a class="link" href="s02.html#idx_id_22">C</a> <a class="link" href="s02.html#idx_id_23">D</a> <a class="link" href="s02.html#idx_id_24">E</a> <a class="link" href="s02.html#idx_id_25">F</a> <a class="link" href="s02.html#idx_id_26">G</a> <a class="link" href="s02.html#idx_id_28">I</a> <a class="link" href="s02.html#idx_id_29">L</a> <a class="link" href="s02.html#idx_id_30">M</a> <a class="link" href="s02.html#idx_id_31">N</a> <a class="link" href="s02.html#idx_id_34">R</a> <a class="link" href="s02.html#idx_id_36">T</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>
Expand Down
2 changes: 1 addition & 1 deletion doc/html/boost_multiprecision/indexes/s03.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id1251871"></a>Typedef Index</h3></div></div></div>
<a name="id1259199"></a>Typedef Index</h3></div></div></div>
<p></p>
<div class="variablelist"><dl class="variablelist"></dl></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion doc/html/boost_multiprecision/indexes/s04.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="id1251888"></a>Index</h3></div></div></div>
<a name="id1259200"></a>Index</h3></div></div></div>
<p><a class="link" href="s04.html#idx_id_60">A</a> <a class="link" href="s04.html#idx_id_61">B</a> <a class="link" href="s04.html#idx_id_62">C</a> <a class="link" href="s04.html#idx_id_63">D</a> <a class="link" href="s04.html#idx_id_64">E</a> <a class="link" href="s04.html#idx_id_65">F</a> <a class="link" href="s04.html#idx_id_66">G</a> <a class="link" href="s04.html#idx_id_67">H</a> <a class="link" href="s04.html#idx_id_68">I</a> <a class="link" href="s04.html#idx_id_69">L</a> <a class="link" href="s04.html#idx_id_70">M</a> <a class="link" href="s04.html#idx_id_71">N</a> <a class="link" href="s04.html#idx_id_72">O</a> <a class="link" href="s04.html#idx_id_73">P</a> <a class="link" href="s04.html#idx_id_74">R</a> <a class="link" href="s04.html#idx_id_75">S</a> <a class="link" href="s04.html#idx_id_76">T</a> <a class="link" href="s04.html#idx_id_77">V</a> <a class="link" href="s04.html#idx_id_78">X</a> <a class="link" href="s04.html#idx_id_79">Z</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>
Expand Down
10 changes: 10 additions & 0 deletions doc/html/boost_multiprecision/tut/ints/cpp_int.html
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@
</tr>
</tbody>
</table></div>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
When an exception is thrown as a result of using a checked type, then
the value of the target operand after the exception is caught is unspecified.
</p></td></tr>
</table></div>
<p>
Things you should know when using this type:
</p>
Expand Down
2 changes: 2 additions & 0 deletions doc/tutorial_cpp_int.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ result from treating the unsigned type as a 2's complement signed type.]]
that would result from performing the operation on a 2's complement integer type.]]
]

[note When an exception is thrown as a result of using a checked type, then the value of the target operand after the exception is caught is unspecified.]

Things you should know when using this type:

* Default constructed `cpp_int_backend`s have the value zero.
Expand Down
16 changes: 14 additions & 2 deletions include/boost/multiprecision/cpp_int.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,10 +844,17 @@ struct cpp_int_base<MinBits, MinBits, unsigned_magnitude, Checked, void, false>
BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR void normalize() noexcept((Checked == unchecked))
{
limb_pointer p = limbs();
detail::verify_limb_mask(m_limbs == internal_limb_count, p[internal_limb_count - 1], upper_limb_mask, checked_type());

limb_type c = p[internal_limb_count - 1];
bool full_limbs = m_limbs == internal_limb_count;

p[internal_limb_count - 1] &= upper_limb_mask;
while ((m_limbs - 1) && !p[m_limbs - 1])
--m_limbs;
//
// Verification at the end, so that we're in a valid state if we throw:
//
detail::verify_limb_mask(full_limbs, c, upper_limb_mask, checked_type());
}

BOOST_MP_FORCEINLINE constexpr cpp_int_base() noexcept
Expand Down Expand Up @@ -1264,8 +1271,13 @@ struct cpp_int_base<MinBits, MinBits, unsigned_magnitude, Checked, void, true>
}
BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR void normalize() noexcept((Checked == unchecked))
{
detail::verify_limb_mask(true, m_data, limb_mask, checked_type());
local_limb_type c = m_data;
m_data &= limb_mask;
//
// Verification has to come afterwards, otherwise we can leave
// ourselves in an invalid state:
//
detail::verify_limb_mask(true, c, limb_mask, checked_type());
}

BOOST_MP_FORCEINLINE constexpr cpp_int_base() noexcept : m_data(0) {}
Expand Down
42 changes: 42 additions & 0 deletions include/boost/multiprecision/cpp_int/divide.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,10 @@ eval_modulus(
const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& a,
const limb_type mod)
{

if(mod == 0)
BOOST_MP_THROW_EXCEPTION(std::overflow_error("Division by zero."));

const std::ptrdiff_t n = static_cast<std::ptrdiff_t>(a.size());

const double_limb_type two_n_mod =
Expand Down Expand Up @@ -656,6 +660,44 @@ eval_modulus(
result.sign(result.sign());
}

template <std::size_t MinBits1, std::size_t MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1, class V>
BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<
is_trivial_cpp_int<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value && std::is_unsigned<V>::value>::type
eval_modulus(
cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& result,
const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& a,
V o)
{
using local_limb_type = typename cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::local_limb_type;

BOOST_IF_CONSTEXPR(std::numeric_limits<V>::digits > MaxBits1)
{
if (o >= (static_cast<V>(1u) << MaxBits1))
{
// Modulus is larger than any value that the result can hold,
// so the result is just "a":
result = a;
return;
}
}
if (!o)
BOOST_MP_THROW_EXCEPTION(std::overflow_error("Division by zero."));
*result.limbs() = *a.limbs() % static_cast<local_limb_type>(o);
result.sign(a.sign());
}

template <std::size_t MinBits1, std::size_t MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1, class V>
BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<
is_trivial_cpp_int<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value && std::is_signed<V>::value>::type
eval_modulus(
cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& result,
const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& a,
V o)
{
using unsigned_type = typename std::make_unsigned<V>::type;
eval_modulus(result, a, static_cast<unsigned_type>(o < 0 ? -o : o));
}

}}} // namespace boost::multiprecision::backends

#endif
9 changes: 6 additions & 3 deletions include/boost/multiprecision/cpp_int/misc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ eval_convert_to(R* result, const cpp_int_backend<MinBits1, MaxBits1, SignType1,

template <class R, std::size_t MinBits1, std::size_t MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1>
inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<std::is_floating_point<R>::value && !is_trivial_cpp_int<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value, void>::type
eval_convert_to(R* result, const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& backend) noexcept(boost::multiprecision::detail::is_arithmetic<R>::value && std::numeric_limits<R>::has_infinity)
eval_convert_to(R* result, const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& backend) noexcept(boost::multiprecision::detail::is_arithmetic<R>::value &&
(std::numeric_limits<R>::has_infinity ||
std::numeric_limits<R>::has_quiet_NaN))
{
BOOST_MP_FLOAT128_USING using std::ldexp;
if (eval_is_zero(backend))
Expand Down Expand Up @@ -244,10 +246,11 @@ eval_convert_to(R* result, const cpp_int_backend<MinBits1, MaxBits1, SignType1,
if ((eval_lsb_imp(backend) < static_cast<std::size_t>(bits)) || eval_bit_test(backend, static_cast<std::size_t>(bits + 1)))
{
#ifdef BOOST_MP_MATH_AVAILABLE
BOOST_IF_CONSTEXPR(std::numeric_limits<R>::has_infinity)
BOOST_IF_CONSTEXPR(std::numeric_limits<R>::has_infinity || std::numeric_limits<R>::has_quiet_NaN)
{
// Must NOT throw:
*result = boost::math::float_next(*result, boost::math::policies::make_policy(boost::math::policies::overflow_error<boost::math::policies::ignore_error>()));
*result = boost::math::float_next(*result, boost::math::policies::make_policy(boost::math::policies::overflow_error<boost::math::policies::ignore_error>(),
boost::math::policies::domain_error<boost::math::policies::ignore_error>()));
}
else
{
Expand Down
21 changes: 13 additions & 8 deletions include/boost/multiprecision/detail/default_ops.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3980,41 +3980,46 @@ ilogb(const detail::expression<tag, A1, A2, A3, A4>& val)
} //namespace multiprecision

namespace math {


//
// Overload of Boost.Math functions that find the wrong overload when used with number:
//
namespace detail {

template <class T>
T sinc_pi_imp(T);
template <class T>
T sinhc_pi_imp(T);
template <class T, class Policy>
T sinhc_pi_imp(T, const Policy&);

} // namespace detail

template <class Backend, multiprecision::expression_template_option ExpressionTemplates>
inline multiprecision::number<Backend, ExpressionTemplates> sinc_pi(const multiprecision::number<Backend, ExpressionTemplates>& x)
{
boost::multiprecision::detail::scoped_default_precision<multiprecision::number<Backend, ExpressionTemplates> > precision_guard(x);
return std::move(detail::sinc_pi_imp(x));
return detail::sinc_pi_imp(x);
}

template <class Backend, multiprecision::expression_template_option ExpressionTemplates, class Policy>
inline multiprecision::number<Backend, ExpressionTemplates> sinc_pi(const multiprecision::number<Backend, ExpressionTemplates>& x, const Policy&)
{
boost::multiprecision::detail::scoped_default_precision<multiprecision::number<Backend, ExpressionTemplates> > precision_guard(x);
return std::move(detail::sinc_pi_imp(x));
return detail::sinc_pi_imp(x);
}

template <class Backend, multiprecision::expression_template_option ExpressionTemplates>
inline multiprecision::number<Backend, ExpressionTemplates> sinhc_pi(const multiprecision::number<Backend, ExpressionTemplates>& x)
{
boost::multiprecision::detail::scoped_default_precision<multiprecision::number<Backend, ExpressionTemplates> > precision_guard(x);
return std::move(detail::sinhc_pi_imp(x));
return detail::sinhc_pi_imp(x, boost::math::policies::policy<>());
}

template <class Backend, multiprecision::expression_template_option ExpressionTemplates, class Policy>
inline multiprecision::number<Backend, ExpressionTemplates> sinhc_pi(const multiprecision::number<Backend, ExpressionTemplates>& x, const Policy&)
inline multiprecision::number<Backend, ExpressionTemplates> sinhc_pi(const multiprecision::number<Backend, ExpressionTemplates>& x, const Policy& pol)
{
boost::multiprecision::detail::scoped_default_precision<multiprecision::number<Backend, ExpressionTemplates> > precision_guard(x);
return std::move(boost::math::sinhc_pi(x));
boost::multiprecision::detail::scoped_default_precision<multiprecision::number<Backend, ExpressionTemplates> > precision_guard(x, pol);
return detail::sinhc_pi_imp(x, pol);
}

using boost::multiprecision::gcd;
Expand Down
2 changes: 2 additions & 0 deletions test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,8 @@ test-suite misc :
<define>TEST_CPP_DEC_FLOAT
<define>TEST_CPP_BIN_FLOAT ]
[ compile git_issue_608.cpp ]
[ run git_issue_624.cpp ]
[ run git_issue_626.cpp ]
[ compile git_issue_98.cpp :
[ check-target-builds ../config//has_float128 : <define>TEST_FLOAT128 <source>quadmath : ]
[ check-target-builds ../config//has_gmp : <define>TEST_GMP <source>gmp : ]
Expand Down
Loading
Loading