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

C++23 Floats #978

Merged
merged 53 commits into from
Jun 28, 2023
Merged
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
7a6efab
First draft of promotion
mborland Apr 24, 2023
5dcf5a9
Test beta dist for F64, F32, and F16
mborland Apr 24, 2023
4c753c2
Reverse 128bits and prefer F64 over long double when it's 64bits
mborland Apr 25, 2023
2f0b0ed
Add more testing
mborland Apr 25, 2023
bc79263
Add compile tests for F32 and F64
mborland May 2, 2023
2b1d5b6
Cast assignment of promoted type
mborland May 2, 2023
be37704
Explicit casting of promoted types
mborland May 2, 2023
5d044d5
Remove cast for output iterator
mborland May 9, 2023
6a3a89b
Add testing to quadrature
mborland May 11, 2023
3c2a04e
Add gcc-13 to drone config
mborland May 11, 2023
ac4605b
Fix Minw-64 C++23 compile failures.
jzmaddock May 13, 2023
b3f361c
Fix the promote_args<float32_t, float32_t> case.
jzmaddock May 14, 2023
58264c0
Add test case for promote_args.
jzmaddock May 14, 2023
c5b4d28
Suppress lots of warnings for std::float32_t.
jzmaddock May 15, 2023
ac8765b
Update drone to use Ubuntu 23.04 for g++13
mborland May 15, 2023
fa8a83f
Enable testing of new floats
mborland May 15, 2023
d217813
Fix stack overflow on test_finite_singular_boundary with _Float64
mborland May 16, 2023
8433636
Fix remaining warnings from float32.cpp.
jzmaddock May 16, 2023
6104363
Add float128 testing
mborland May 16, 2023
5045047
Use charconv instead of streaming operator for std::float128_t
mborland May 16, 2023
0c1920b
Move macro definitions to config
mborland May 16, 2023
a0360d8
Use charconv in convert_from_string for arithmetic types
mborland May 16, 2023
edf6597
inline template specialization
mborland May 16, 2023
55eaf05
Add additional conversion function for C++23 types
mborland May 16, 2023
00facdc
Fix cardinal cubic b spline for std::float32_t
mborland May 17, 2023
f86ea8e
Begin adding interpolator tests
mborland May 17, 2023
41be4fb
Improve to/from_chars configuration.
jzmaddock May 21, 2023
51d7011
Fix formatting and missing header
mborland May 22, 2023
c4c8c69
Add wavelet transform test with additional casts
mborland May 22, 2023
aef5713
Add rsqrt test and update type traits for control path
mborland May 22, 2023
ca31dcf
Add AGM test
mborland May 22, 2023
faaf475
Fix stack overflow in cohen acceleration from GCC bug
mborland May 22, 2023
ebcc430
Add casting to whittaker shannon for conversion rank errors
mborland May 22, 2023
d1bd7b6
Add casting and tests
mborland May 22, 2023
823fcd4
Add test and cast to finite differences
mborland May 30, 2023
c249bfe
Fix -Wreturn-type
mborland May 30, 2023
6d37555
Collected autodiff fixes
mborland May 30, 2023
ae56ab2
Fix conversion errors in digamma
mborland May 31, 2023
7a66a98
Fix for autodiff 3
mborland May 31, 2023
b66264f
Collected special functions warning fixes
mborland May 31, 2023
a7f98db
Add casts to all two argument cmath functions to work around GCC bug
mborland May 31, 2023
ff1a265
Add to test_constants
mborland May 31, 2023
a6bc6c7
Add <stdfloat> constructor to real_concept
mborland Jun 5, 2023
bc9d4b1
Fix failures and warnings in test_autodiff_6
mborland Jun 5, 2023
677f3b6
Collected fixes for test_autodiff_8
mborland Jun 5, 2023
7a0e8e0
More casting of pow
mborland Jun 16, 2023
37df734
Add integer exponent function to chebyshev detail
mborland Jun 16, 2023
0117f4a
Fix multiprecision concept failure
mborland Jun 16, 2023
ef423e8
Restore drone config
mborland Jun 16, 2023
e62a284
Fix multiprecision failures
mborland Jun 19, 2023
b57749d
Fix casting errors
mborland Jun 20, 2023
0a014fd
Fix for expression template use in chebyshev.hpp.
jzmaddock Jun 21, 2023
851b357
Fix pessimization on unaffected platforms
mborland Jun 27, 2023
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
Next Next commit
First draft of promotion
mborland committed Apr 24, 2023

Verified

This commit was signed with the committer’s verified signature.
jaybuidl jaybuidl
commit 7a6efabba5af757defc87aedecc1cc4d18d52b4d
123 changes: 122 additions & 1 deletion include/boost/math/tools/promotion.hpp
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

// Copyright John Maddock 2006.
// Copyright Paul A. Bristow 2006.
// Copyright Matt Borland 2023.

// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0.
@@ -25,6 +26,10 @@
#include <boost/math/tools/config.hpp>
#include <type_traits>

#if __has_include(<stdfloat>)
# include <stdfloat>
#endif

namespace boost
{
namespace math
@@ -63,6 +68,19 @@ namespace boost
template <> struct promote_arg<long double> { using type = long double; };
template <> struct promote_arg<int> { using type = double; };

#ifdef __STDCPP_FLOAT16_T__
template <> struct promote_arg<std::float16_t> { using type = std::float16_t; };
#endif
#ifdef __STDCPP_FLOAT32_T__
template <> struct promote_arg<std::float32_t> { using type = std::float32_t; };
#endif
#ifdef __STDCPP_FLOAT64_T__
template <> struct promote_arg<std::float64_t> { using type = std::float64_t; };
#endif
#ifdef __STDCPP_FLOAT128_T__
template <> struct promote_arg<std::float128_t> { using type = std::float128_t; };
#endif

template <typename T>
using promote_arg_t = typename promote_arg<T>::type;

@@ -78,14 +96,35 @@ namespace boost
#ifdef BOOST_MATH_USE_FLOAT128
typename std::conditional<std::is_same<__float128, T1P>::value || std::is_same<__float128, T2P>::value, // either long double?
__float128,
#endif
#endif
#ifdef __STDCPP_FLOAT128_T__
typename std::conditional<std::is_same<std::float128_t, T1P>::value || std::is_same<std::float128_t, T2P>::value, // either long double?
std::float128_t,
#endif
typename std::conditional<std::is_same<long double, T1P>::value || std::is_same<long double, T2P>::value, // either long double?
long double, // then result type is long double.
#ifdef __STDCPP_FLOAT64_T__
typename std::conditional<std::is_same<std::float64_t, T1P>::value || std::is_same<std::float64_t, T2P>::value, // either float64?
std::float64_t, // then result type is float64_t.
#endif
typename std::conditional<std::is_same<double, T1P>::value || std::is_same<double, T2P>::value, // either double?
double, // result type is double.
#ifdef __STDCPP_FLOAT32_T__
typename std::conditional<std::is_same<std::float32_t, T1P>::value || std::is_same<std::float32_t, T2P>::value, // either float32?
std::float32_t, // then result type is float32_t.
#endif
float // else result type is float.
>::type
#ifdef BOOST_MATH_USE_FLOAT128
>::type,
#endif
#ifdef __STDCPP_FLOAT128_T__
>::type
#endif
#ifdef __STDCPP_FLOAT64_T__
>::type
#endif
#ifdef __STDCPP_FLOAT32_T__
>::type
#endif
>::type,
@@ -111,6 +150,88 @@ namespace boost
template <> struct promote_args_2<double, long double> { using type = long double; };
template <> struct promote_args_2<long double, double> { using type = long double; };

#ifdef __STDCPP_FLOAT128_T__
template <> struct promote_args_2<int, std::float128_t> { using type = std::float128_t; };
template <> struct promote_args_2<std::float128_t, int> { using type = std::float128_t; };
template <> struct promote_args_2<std::float128_t, float> { using type = std::float128_t; };
template <> struct promote_args_2<float, std::float128_t> { using type = std::float128_t; };
template <> struct promote_args_2<std::float128_t, double> { using type = std::float128_t; };
template <> struct promote_args_2<double, std::float128_t> { using type = std::float128_t; };
template <> struct promote_args_2<std::float128_t, long double> { using type = std::float128_t; };
template <> struct promote_args_2<long double, std::float128_t> { using type = std::float128_t; };

#ifdef __STDCPP_FLOAT16_T__
template <> struct promote_args_2<std::float128_t, std::float16_t> { using type = std::float128_t; };
template <> struct promote_args_2<std::float16_t, std::float128_t> { using type = std::float128_t; };
#endif

#ifdef __STDCPP_FLOAT32_T__
template <> struct promote_args_2<std::float128_t, std::float32_t> { using type = std::float128_t; };
template <> struct promote_args_2<std::float32_t, std::float128_t> { using type = std::float128_t; };
#endif

#ifdef __STDCPP_FLOAT64_T__
template <> struct promote_args_2<std::float128_t, std::float64_t> { using type = std::float128_t; };
template <> struct promote_args_2<std::float64_t, std::float128_t> { using type = std::float128_t; };
#endif

template <> struct promote_args_2<std::float128_t, std::float128_t> { using type = std::float128_t; };
#endif

#ifdef __STDCPP_FLOAT64_T__
template <> struct promote_args_2<int, std::float64_t> { using type = std::float64_t; };
template <> struct promote_args_2<std::float64_t, int> { using type = std::float64_t; };
template <> struct promote_args_2<std::float64_t, float> { using type = std::float64_t; };
template <> struct promote_args_2<float, std::float64_t> { using type = std::float64_t; };
template <> struct promote_args_2<std::float64_t, double> { using type = std::float64_t; };
template <> struct promote_args_2<double, std::float64_t> { using type = std::float64_t; };
template <> struct promote_args_2<std::float64_t, long double> { using type = long double; };
template <> struct promote_args_2<long double, std::float64_t> { using type = long double; };

#ifdef __STDCPP_FLOAT16_T__
template <> struct promote_args_2<std::float64_t, std::float16_t> { using type = std::float64_t; };
template <> struct promote_args_2<std::float16_t, std::float64_t> { using type = std::float64_t; };
#endif

#ifdef __STDCPP_FLOAT32_T__
template <> struct promote_args_2<std::float64_t, std::float32_t> { using type = std::float64_t; };
template <> struct promote_args_2<std::float32_t, std::float64_t> { using type = std::float64_t; };
#endif

template <> struct promote_args_2<std::float64_t, std::float64_t> { using type = std::float64_t; };
#endif

#ifdef __STDCPP_FLOAT32_T__
template <> struct promote_args_2<int, std::float32_t> { using type = std::float32_t; };
template <> struct promote_args_2<std::float32_t, int> { using type = std::float32_t; };
template <> struct promote_args_2<std::float32_t, float> { using type = std::float32_t; };
template <> struct promote_args_2<float, std::float32_t> { using type = std::float32_t; };
template <> struct promote_args_2<std::float32_t, double> { using type = double; };
template <> struct promote_args_2<double, std::float32_t> { using type = double; };
template <> struct promote_args_2<std::float32_t, long double> { using type = long double; };
template <> struct promote_args_2<long double, std::float32_t> { using type = long double; };

#ifdef __STDCPP_FLOAT16_T__
template <> struct promote_args_2<std::float32_t, std::float16_t> { using type = std::float32_t; };
template <> struct promote_args_2<std::float16_t, std::float32_t> { using type = std::float32_t; };
#endif

template <> struct promote_args_2<std::float32_t, std::float32_t> { using type = std::float64_t; };
#endif

#ifdef __STDCPP_FLOAT16_T__
template <> struct promote_args_2<int, std::float16_t> { using type = std::float16_t; };
template <> struct promote_args_2<std::float16_t, int> { using type = std::float16_t; };
template <> struct promote_args_2<std::float16_t, float> { using type = float; };
template <> struct promote_args_2<float, std::float16_t> { using type = float; };
template <> struct promote_args_2<std::float16_t, double> { using type = double; };
template <> struct promote_args_2<double, std::float16_t> { using type = double; };
template <> struct promote_args_2<std::float16_t, long double> { using type = long double; };
template <> struct promote_args_2<long double, std::float16_t> { using type = long double; };

template <> struct promote_args_2<std::float16_t, std::float16_t> { using type = std::float16_t; };
#endif

template <typename T, typename U>
using promote_args_2_t = typename promote_args_2<T, U>::type;