Skip to content

Commit 0d8ae7c

Browse files
committed
Add trivial expm1 test for SYCL functionality
1 parent 898a8fa commit 0d8ae7c

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

test/sycl_jamfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ run test_beta_simple.cpp ;
1818
run test_cbrt.cpp ;
1919
run test_sign.cpp ;
2020
run test_round.cpp ;
21+
run test_expm1_simple.cpp;

test/test_expm1_simple.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright Matt Borland 2024.
2+
// Use, modification and distribution are subject to the
3+
// Boost Software License, Version 1.0. (See accompanying file
4+
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5+
6+
#include <random>
7+
#include <cmath>
8+
#include <boost/math/special_functions/expm1.hpp>
9+
#include "math_unit_test.hpp"
10+
11+
constexpr int N = 50000;
12+
13+
template <typename T>
14+
void test()
15+
{
16+
std::mt19937_64 rng(42);
17+
std::uniform_real_distribution<T> dist(0, 0.01);
18+
19+
for (int n = 0; n < N; ++n)
20+
{
21+
const T value (dist(rng));
22+
CHECK_ULP_CLOSE(std::expm1(value), boost::math::expm1(value), 10);
23+
}
24+
}
25+
26+
int main()
27+
{
28+
test<float>();
29+
test<double>();
30+
31+
return boost::math::test::report_errors();
32+
}

0 commit comments

Comments
 (0)