GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
// |
||
2 |
// Copyright (c) 2018-2019 INRIA |
||
3 |
// |
||
4 |
|||
5 |
#include "pinocchio/fwd.hpp" |
||
6 |
#include "pinocchio/math/sincos.hpp" |
||
7 |
#include <cstdlib> |
||
8 |
|||
9 |
#include "utils/macros.hpp" |
||
10 |
|||
11 |
#include <boost/test/unit_test.hpp> |
||
12 |
#include <boost/utility/binary.hpp> |
||
13 |
|||
14 |
namespace |
||
15 |
{ |
||
16 |
template <typename Scalar> |
||
17 |
Scalar sinCosTolerance(); |
||
18 |
|||
19 |
2000 |
template<> inline float sinCosTolerance<float>() |
|
20 |
{ |
||
21 |
2000 |
return 1e-7f; |
|
22 |
} |
||
23 |
|||
24 |
2000 |
template<> inline double sinCosTolerance<double>() |
|
25 |
{ |
||
26 |
2000 |
return 1e-15; |
|
27 |
} |
||
28 |
|||
29 |
2000 |
template<> inline long double sinCosTolerance<long double>() |
|
30 |
{ |
||
31 |
2000 |
return 1e-19; |
|
32 |
} |
||
33 |
} |
||
34 |
|||
35 |
|||
36 |
template<typename Scalar> |
||
37 |
6 |
void testSINCOS(int n) |
|
38 |
{ |
||
39 |
✓✓ | 6006 |
for(int k = 0; k < n; ++k) |
40 |
{ |
||
41 |
Scalar sin_value, cos_value; |
||
42 |
6000 |
Scalar alpha = (Scalar)std::rand()/(Scalar)RAND_MAX; |
|
43 |
6000 |
pinocchio::SINCOS(alpha,&sin_value,&cos_value); |
|
44 |
|||
45 |
6000 |
Scalar sin_value_ref = std::sin(alpha), |
|
46 |
6000 |
cos_value_ref = std::cos(alpha); |
|
47 |
|||
48 |
✓✗✓✗ ✓✗✓✗ ✗✓ |
6000 |
BOOST_CHECK_CLOSE_FRACTION(sin_value, sin_value_ref, sinCosTolerance<Scalar>()); |
49 |
✓✗✓✗ ✓✗✓✗ ✗✓ |
6000 |
BOOST_CHECK_CLOSE_FRACTION(cos_value, cos_value_ref, sinCosTolerance<Scalar>()); |
50 |
} |
||
51 |
6 |
} |
|
52 |
|||
53 |
BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE) |
||
54 |
|||
55 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗ |
4 |
BOOST_AUTO_TEST_CASE(test_sincos) |
56 |
{ |
||
57 |
#ifndef NDEBUG |
||
58 |
2 |
const int n = 1e3; |
|
59 |
#else |
||
60 |
const int n = 1e6; |
||
61 |
#endif |
||
62 |
2 |
testSINCOS<float>(n); |
|
63 |
2 |
testSINCOS<double>(n); |
|
64 |
2 |
testSINCOS<long double>(n); |
|
65 |
2 |
} |
|
66 |
|||
67 |
BOOST_AUTO_TEST_SUITE_END() |
Generated by: GCOVR (Version 4.2) |