Skip to content

Commit

Permalink
Fix and tests for issue #705 (#731)
Browse files Browse the repository at this point in the history
  • Loading branch information
mborland authored Jan 5, 2022
1 parent 60d54e5 commit e8edbb9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/boost/math/special_functions/powm1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ inline T powm1_imp(const T x, const T y, const Policy& pol)
// fall through....
}
}
else
else if (x < 0)
{
// y had better be an integer:
if (boost::math::trunc(y) != y)
Expand Down
1 change: 1 addition & 0 deletions test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ test-suite special_fun :
[ run ccmath_hypot_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr ] ]
[ run log1p_expm1_test.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ]
[ run powm1_sqrtp1m1_test.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ]
[ run git_issue_705.cpp ../../test/build//boost_unit_test_framework ]
[ 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 ]
Expand Down
29 changes: 29 additions & 0 deletions test/git_issue_705.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright Matt Borland, 2022
// 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)

#include "math_unit_test.hpp"
#include <cmath>
#include <boost/math/special_functions/powm1.hpp>

template <typename T>
void test()
{
CHECK_EQUAL(std::pow(T(0), T(2)) - 1, boost::math::powm1(T(0), T(2)));
CHECK_EQUAL(std::pow(T(0), T(-2)) - 1, boost::math::powm1(T(0), T(-2)));
CHECK_EQUAL(std::pow(T(0), T(0.1)) - 1, boost::math::powm1(T(0), T(0.1)));
CHECK_EQUAL(std::pow(T(0), T(-0.1)) - 1, boost::math::powm1(T(0), T(-0.1)));
}

int main()
{
test<float>();
test<double>();

#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
test<long double>();
#endif

return boost::math::test::report_errors();
}

0 comments on commit e8edbb9

Please sign in to comment.