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

First cut at new rational_adaptor. #366

Merged
merged 22 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e6d136b
First cut at new rational_adaptor.
jzmaddock Sep 2, 2021
8bac317
Add int128 inter-operability to gmp_rational
jzmaddock Sep 6, 2021
b7031c9
Add proper tests for rational_adaptor.
jzmaddock Sep 6, 2021
1b31fbe
Correct bug in rational division logic.
jzmaddock Sep 6, 2021
8ac8f48
Fix include guard name.
jzmaddock Sep 7, 2021
1e612d2
Correct preprocessor snafu.
jzmaddock Sep 7, 2021
b979e0b
Remove Boost.Hash dependency.
jzmaddock Sep 7, 2021
3d05cf0
Optimize default construct, comparisons and scalar operations.
jzmaddock Sep 11, 2021
6d4cd18
Update for better interoperability of rationals and integers.
jzmaddock Sep 15, 2021
142fb95
Add benchmark programs.
jzmaddock Sep 15, 2021
df4b196
Improve efficiency of rvalue-ref operator overloads.
jzmaddock Sep 20, 2021
b010f17
Add forwarding 2-arg constructors.
jzmaddock Sep 20, 2021
7d94c9c
Add improved gmp related constructors.
jzmaddock Sep 20, 2021
43f8469
Add forwarding rvalue-ref 2-arg constructors.
jzmaddock Sep 20, 2021
b80a573
Correct and improve 2-arg pass through constructors.
jzmaddock Sep 25, 2021
dd4f4cc
Fix some clang issues.
jzmaddock Sep 25, 2021
a47e3fc
Merge branch 'develop' into rational_adaptor_standalone
jzmaddock Sep 29, 2021
f5144e5
Merge branch 'develop' into rational_adaptor_standalone
jzmaddock Sep 29, 2021
a9b14a3
Add determinant calculation benchmark.
jzmaddock Sep 29, 2021
7a9d5f2
Update performance result logs
jzmaddock Sep 30, 2021
ae9cf23
Documentation update for the new rational_adaptor.
jzmaddock Sep 30, 2021
e4827ce
Change type casts to std::move calls to better reflect what's going on.
jzmaddock Oct 1, 2021
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
7 changes: 6 additions & 1 deletion include/boost/multiprecision/cpp_int/misc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,12 @@ BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR limb_type eval_gcd(limb_type u, li

inline BOOST_MP_CXX14_CONSTEXPR double_limb_type eval_gcd(double_limb_type u, double_limb_type v)
{
#if (__cpp_lib_gcd_lcm >= 201606L) && (!defined(BOOST_HAS_INT128) || !defined(__STRICT_ANSI__))
#if 0 && (__cpp_lib_gcd_lcm >= 201606L) && (!defined(BOOST_HAS_INT128) || !defined(__STRICT_ANSI__))
return std::gcd(u, v);
#else
if (u == 0)
return v;

unsigned shift = boost::multiprecision::detail::find_lsb(u | v);
u >>= boost::multiprecision::detail::find_lsb(u);
do
Expand Down Expand Up @@ -1110,6 +1113,7 @@ BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<is_trivial
eval_gcd(cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& result, const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& a, const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& b) noexcept
{
*result.limbs() = boost::integer::gcd(*a.limbs(), *b.limbs());
result.sign(false);
}
// This one is only enabled for unchecked cpp_int's, for checked int's we need the checking in the default version:
template <unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1>
Expand All @@ -1118,6 +1122,7 @@ eval_lcm(cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& r
{
*result.limbs() = boost::integer::lcm(*a.limbs(), *b.limbs());
result.normalize(); // result may overflow the specified number of bits
result.sign(false);
}

inline void conversion_overflow(const std::integral_constant<int, checked>&)
Expand Down
14 changes: 14 additions & 0 deletions include/boost/multiprecision/gmp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2283,6 +2283,20 @@ struct gmp_rational
mpq_div_2exp(m_data, m_data, -e);
return *this;
}
#ifdef BOOST_HAS_INT128
gmp_rational& operator=(unsigned __int128 i)
{
gmp_int gi;
gi = i;
return *this = gi;
}
gmp_rational& operator=(__int128 i)
{
gmp_int gi;
gi = i;
return *this = gi;
}
#endif
gmp_rational& operator=(const char* s)
{
if (m_data[0]._mp_den._mp_d == 0)
Expand Down
Loading