diff --git a/include/boost/math/tools/config.hpp b/include/boost/math/tools/config.hpp index 9e4b7d7ca9..6d962a08a6 100644 --- a/include/boost/math/tools/config.hpp +++ b/include/boost/math/tools/config.hpp @@ -365,42 +365,62 @@ struct non_type {}; #endif // -// Tune performance options for specific compilers: +// Tune performance options for specific compilers, +// but check at each step that nothing has been previously defined by the user first // #ifdef _MSC_VER -# define BOOST_MATH_POLY_METHOD 2 +# ifndef BOOST_MATH_POLY_METHOD +# define BOOST_MATH_POLY_METHOD 2 +# endif #if _MSC_VER <= 1900 -# define BOOST_MATH_RATIONAL_METHOD 1 +# ifndef BOOST_MATH_POLY_METHOD +# define BOOST_MATH_RATIONAL_METHOD 1 +# endif #else -# define BOOST_MATH_RATIONAL_METHOD 2 +# ifndef BOOST_MATH_RATIONAL_METHOD +# define BOOST_MATH_RATIONAL_METHOD 2 +# endif #endif #if _MSC_VER > 1900 -# define BOOST_MATH_INT_TABLE_TYPE(RT, IT) RT -# define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L +# ifndef BOOST_MATH_INT_TABLE_TYPE +# define BOOST_MATH_INT_TABLE_TYPE(RT, IT) RT +# endif +# ifndef BOOST_MATH_INT_VALUE_SUFFIX +# define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L +# endif #endif #elif defined(__INTEL_COMPILER) -# define BOOST_MATH_POLY_METHOD 2 -# define BOOST_MATH_RATIONAL_METHOD 1 +# ifndef BOOST_MATH_POLY_METHOD +# define BOOST_MATH_POLY_METHOD 2 +# endif +# ifndef BOOST_MATH_RATIONAL_METHOD +# define BOOST_MATH_RATIONAL_METHOD 1 +# endif #elif defined(__GNUC__) -#if __GNUC__ < 4 -# define BOOST_MATH_POLY_METHOD 3 -# define BOOST_MATH_RATIONAL_METHOD 3 -# define BOOST_MATH_INT_TABLE_TYPE(RT, IT) RT -# define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L -#else -# define BOOST_MATH_POLY_METHOD 3 -# define BOOST_MATH_RATIONAL_METHOD 3 -#endif +# ifndef BOOST_MATH_POLY_METHOD +# define BOOST_MATH_POLY_METHOD 3 +# endif +# ifndef BOOST_MATH_RATIONAL_METHOD +# define BOOST_MATH_RATIONAL_METHOD 3 +# endif #elif defined(__clang__) #if __clang__ > 6 -# define BOOST_MATH_POLY_METHOD 3 -# define BOOST_MATH_RATIONAL_METHOD 3 -# define BOOST_MATH_INT_TABLE_TYPE(RT, IT) RT -# define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L +# ifndef BOOST_MATH_POLY_METHOD +# define BOOST_MATH_POLY_METHOD 3 +# endif +# ifndef BOOST_MATH_RATIONAL_METHOD +# define BOOST_MATH_RATIONAL_METHOD 3 +# endif +# ifndef BOOST_MATH_INT_TABLE_TYPE +# define BOOST_MATH_INT_TABLE_TYPE(RT, IT) RT +# endif +# ifndef BOOST_MATH_INT_VALUE_SUFFIX +# define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L +# endif #endif #endif diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 394f3d36f0..9571cd4ea4 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -172,6 +172,7 @@ test-suite special_fun : [ run git_issue_961.cpp ] [ run git_issue_1006.cpp ] [ run git_issue_184.cpp ] + [ run git_issue_1137.cpp ] [ run special_functions_test.cpp ../../test/build//boost_unit_test_framework ] [ run test_airy.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ] [ run test_bessel_j.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ] diff --git a/test/git_issue_1137.cpp b/test/git_issue_1137.cpp new file mode 100644 index 0000000000..268edd83ad --- /dev/null +++ b/test/git_issue_1137.cpp @@ -0,0 +1,19 @@ +// Copyright Matt Borland 2024. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See: https://github.com/boostorg/math/issues/1137 + +#define BOOST_MATH_POLY_METHOD 0 +#define BOOST_MATH_RATIONAL_METHOD 0 + +#include + +int main() +{ + static_assert(BOOST_MATH_POLY_METHOD == 0, "User defined as 0"); + static_assert(BOOST_MATH_RATIONAL_METHOD == 0, "User defined as 0"); + + return 0; +}