Line |
Branch |
Exec |
Source |
1 |
|
|
// |
2 |
|
|
// Copyright (c) 2016-2024 CNRS INRIA |
3 |
|
|
// |
4 |
|
|
|
5 |
|
|
#ifndef __pinocchio_math_fwd_hpp__ |
6 |
|
|
#define __pinocchio_math_fwd_hpp__ |
7 |
|
|
|
8 |
|
|
#include "pinocchio/fwd.hpp" |
9 |
|
|
#include <math.h> |
10 |
|
|
#include <boost/math/constants/constants.hpp> |
11 |
|
|
#include <boost/type_traits/is_floating_point.hpp> |
12 |
|
|
|
13 |
|
|
namespace pinocchio |
14 |
|
|
{ |
15 |
|
|
|
16 |
|
|
template<typename T> |
17 |
|
|
struct is_floating_point : boost::is_floating_point<T> |
18 |
|
|
{ |
19 |
|
|
}; |
20 |
|
|
|
21 |
|
|
/// |
22 |
|
|
/// \brief Returns the value of PI according to the template parameters Scalar |
23 |
|
|
/// |
24 |
|
|
/// \tparam Scalar The scalar type of the return pi value |
25 |
|
|
/// |
26 |
|
|
template<typename Scalar> |
27 |
|
50 |
const Scalar PI() |
28 |
|
|
{ |
29 |
|
50 |
return boost::math::constants::pi<Scalar>(); |
30 |
|
|
} |
31 |
|
|
|
32 |
|
|
/// \brief Foward declaration of TaylorSeriesExpansion. |
33 |
|
|
template<typename Scalar> |
34 |
|
|
struct TaylorSeriesExpansion; |
35 |
|
|
|
36 |
|
|
namespace math |
37 |
|
|
{ |
38 |
|
|
|
39 |
|
|
#define PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(name) \ |
40 |
|
|
template<typename Scalar> \ |
41 |
|
|
Scalar name(const Scalar & value) \ |
42 |
|
|
{ \ |
43 |
|
|
using std::name; \ |
44 |
|
|
return name(value); \ |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
#define PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(name) \ |
48 |
|
|
namespace internal \ |
49 |
|
|
{ \ |
50 |
|
|
template<typename T1, typename T2> \ |
51 |
|
|
struct return_type_##name \ |
52 |
|
|
{ \ |
53 |
|
|
typedef T1 type; \ |
54 |
|
|
}; \ |
55 |
|
|
template<typename T1, typename T2> \ |
56 |
|
|
struct call_##name \ |
57 |
|
|
{ \ |
58 |
|
|
static inline typename return_type_##name<T1, T2>::type run(const T1 & a, const T2 & b) \ |
59 |
|
|
{ \ |
60 |
|
|
using std::name; \ |
61 |
|
|
return name(a, b); \ |
62 |
|
|
} \ |
63 |
|
|
}; \ |
64 |
|
|
} \ |
65 |
|
|
template<typename T1, typename T2> \ |
66 |
|
|
inline typename internal::return_type_##name<T1, T2>::type name(const T1 & a, const T2 & b) \ |
67 |
|
|
{ \ |
68 |
|
|
return internal::call_##name<T1, T2>::run(a, b); \ |
69 |
|
|
} |
70 |
|
|
|
71 |
|
8746 |
PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(fabs) |
72 |
|
13264 |
PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(sqrt) |
73 |
|
|
PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(atan) |
74 |
|
1393 |
PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(acos) |
75 |
|
|
PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(asin) |
76 |
|
✗ |
PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(cos) |
77 |
|
261 |
PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(sin) |
78 |
|
✗ |
PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(log) |
79 |
|
|
PINOCCHIO_OVERLOAD_MATH_UNARY_OPERATOR(exp) |
80 |
|
|
|
81 |
|
10004 |
PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(pow) |
82 |
|
✗ |
PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(min) |
83 |
|
261152 |
PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(max) |
84 |
|
9966 |
PINOCCHIO_OVERLOAD_MATH_BINARY_OPERATOR(atan2) |
85 |
|
|
} // namespace math |
86 |
|
|
} // namespace pinocchio |
87 |
|
|
|
88 |
|
|
#endif // #ifndef __pinocchio_math_fwd_hpp__ |
89 |
|
|
|