sincos.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2018-2019 INRIA
3 //
4 
5 #include "pinocchio/fwd.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  template<>
20  inline float sinCosTolerance<float>()
21  {
22  return 1e-7f;
23  }
24 
25  template<>
26  inline double sinCosTolerance<double>()
27  {
28  return 1e-15;
29  }
30 
31  template<>
32  inline long double sinCosTolerance<long double>()
33  {
34  return 1e-19;
35  }
36 } // namespace
37 
38 template<typename Scalar>
39 void testSINCOS(int n)
40 {
41  for (int k = 0; k < n; ++k)
42  {
43  Scalar sin_value, cos_value;
44  Scalar alpha = (Scalar)std::rand() / (Scalar)RAND_MAX;
45  pinocchio::SINCOS(alpha, &sin_value, &cos_value);
46 
47  Scalar sin_value_ref = std::sin(alpha), cos_value_ref = std::cos(alpha);
48 
49  BOOST_CHECK_CLOSE_FRACTION(sin_value, sin_value_ref, sinCosTolerance<Scalar>());
50  BOOST_CHECK_CLOSE_FRACTION(cos_value, cos_value_ref, sinCosTolerance<Scalar>());
51  }
52 }
53 
54 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
55 
57 {
58 #ifndef NDEBUG
59  const int n = 1e3;
60 #else
61  const int n = 1e6;
62 #endif
63  testSINCOS<float>(n);
64  testSINCOS<double>(n);
65  testSINCOS<long double>(n);
66 }
67 
68 BOOST_AUTO_TEST_SUITE_END()
sincos.hpp
fwd.hpp
pinocchio::python::Scalar
context::Scalar Scalar
Definition: admm-solver.cpp:29
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(test_sincos)
Definition: sincos.cpp:56
pinocchio::SINCOS
void SINCOS(const S1 &a, S2 *sa, S3 *ca)
Computes sin/cos values of a given input scalar.
Definition: sincos.hpp:27
autodiff-rnea.f
f
Definition: autodiff-rnea.py:24
reachable-workspace-with-collisions.alpha
float alpha
Definition: reachable-workspace-with-collisions.py:159
testSINCOS
void testSINCOS(int n)
Definition: sincos.cpp:39
pinocchio.utils.rand
def rand(n)
Definition: bindings/python/pinocchio/utils.py:42
n
Vec3f n


pinocchio
Author(s):
autogenerated on Sat Jun 22 2024 02:41:50