Skip to content

Commit 6bd07ec

Browse files
committed
Add any numerical type (int, floating, complex) concept
1 parent b03cbf5 commit 6bd07ec

File tree

2 files changed

+77
-59
lines changed

2 files changed

+77
-59
lines changed

include/boost/math/concepts/concepts.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ concept real_or_complex = real<T> || complex<T>;
111111
template <typename T>
112112
concept arithmetic = std::is_arithmetic_v<T>;
113113

114+
template <typename T>
115+
concept numerical = arithmetic<T> || real_or_complex<T>;
116+
114117
template <typename T>
115118
concept signed_arithmetic = arithmetic<T> && std::is_signed_v<T>;
116119

@@ -165,6 +168,10 @@ template <typename T>
165168
concept arbitrary_real_or_complex_type = arbitrary_real_type<T> ||
166169
arbitrary_complex_type<T>;
167170

171+
template <typename T>
172+
concept arbitrary_numerical_type = arbitrary_real_or_complex_type<T> ||
173+
arbitrary_arithmetic_type<T>;
174+
168175
template <typename T>
169176
concept policy = boost::math::policies::is_policy<T>::value;
170177

@@ -210,6 +217,7 @@ concept random_access_container = is_container<T> &&
210217
#define BOOST_MATH_COMPLEX boost::math::concepts::complex
211218
#define BOOST_MATH_REAL_OR_COMPLEX boost::math::concepts::real_or_complex
212219
#define BOOST_MATH_ARITHMETIC boost::math::concepts::arithmetic
220+
#define BOOST_MATH_NUMERICAL boost::math::concepts::numerical
213221
#define BOOST_MATH_SIGNED_ARITHMETIC boost::math::concepts::signed_arithmetic
214222
#define BOOST_MATH_UNSIGNED_ARITHMETIC boost::math::concepts::unsigned_arithmetic
215223
#define BOOST_MATH_ARBITRARY_UNSIGNED_ARITHMETIC boost::math::concepts::arbitrary_unsigned_arithmetic_type
@@ -221,6 +229,7 @@ concept random_access_container = is_container<T> &&
221229
#define BOOST_MATH_ARBITRARY_REAL boost::math::concepts::arbitrary_real_type
222230
#define BOOST_MATH_ARBITRARY_COMPLEX boost::math::concepts::arbitrary_complex_type
223231
#define BOOST_MATH_ARBITRARY_REAL_OR_COMPLEX boost::math::concepts::arbitrary_real_or_complex_type
232+
#define BOOST_MATH_ARBITRARY_NUMERICAL boost::math::concepts::arbitrary_numerical_type
224233
#define BOOST_MATH_POLICY boost::math::concepts::policy
225234
#define BOOST_MATH_CONTAINER boost::math::concepts::is_container
226235
#define BOOST_MATH_RANDOM_ACCESS_CONTAINER boost::math::concepts::random_access_container
@@ -288,6 +297,10 @@ concept execution_policy = std::is_execution_policy_v<std::remove_cvref_t<T>>;
288297
# define BOOST_MATH_ARITHMETIC typename
289298
#endif
290299

300+
#ifndef BOOST_MATH_NUMERICAL
301+
# define BOOST_MATH_NUMERICAL typename
302+
#endif
303+
291304
#ifndef BOOST_MATH_SIGNED_ARITHMETIC
292305
# define BOOST_MATH_SIGNED_ARITHMETIC typename
293306
#endif
@@ -332,6 +345,10 @@ concept execution_policy = std::is_execution_policy_v<std::remove_cvref_t<T>>;
332345
# define BOOST_MATH_ARBITRARY_REAL_OR_COMPLEX typename
333346
#endif
334347

348+
#ifndef BOOST_MATH_ARBITRARY_NUMERICAL
349+
# define BOOST_MATH_ARBITRARY_NUMERICAL typename
350+
#endif
351+
335352
#ifndef BOOST_MATH_POLICY
336353
# define BOOST_MATH_POLICY typename
337354
#endif

0 commit comments

Comments
 (0)