5 #ifndef __pinocchio_math_mutliprecision_hpp__
6 #define __pinocchio_math_mutliprecision_hpp__
10 #ifndef PINOCCHIO_WITH_CXX11_SUPPORT
11 #error C++11 compiler required.
14 #include <boost/multiprecision/number.hpp>
15 #include <boost/random.hpp>
16 #include <Eigen/Dense>
22 template<
typename Backend, boost::multiprecision::expression_
template_option ET>
24 : boost::integral_constant<
26 ((!std::numeric_limits<boost::multiprecision::number<Backend, ET>>::is_integer
27 && std::numeric_limits<boost::multiprecision::number<Backend, ET>>::has_infinity))>
38 boost::multiprecision::expression_template_option ExpressionTemplates,
40 struct cast_impl<
boost::multiprecision::number<Backend, ExpressionTemplates>,
Scalar>
42 #if EIGEN_VERSION_AT_LEAST(3, 2, 90)
46 run(
const boost::multiprecision::number<Backend, ExpressionTemplates> & x)
48 return x.template convert_to<Scalar>();
54 #ifndef BOOST_MP_EIGEN_HPP
62 template<
class Backend, boost::multiprecision::expression_
template_option ExpressionTemplates>
63 struct NumTraits<boost::multiprecision::number<Backend, ExpressionTemplates>>
65 typedef boost::multiprecision::number<Backend, ExpressionTemplates>
self_type;
66 #if BOOST_VERSION / 100 % 1000 >= 68
77 #if BOOST_VERSION / 100 % 1000 >= 68
78 IsComplex = boost::multiprecision::number_category<self_type>::value
79 == boost::multiprecision::number_kind_complex,
83 IsInteger = boost::multiprecision::number_category<self_type>::value
84 == boost::multiprecision::number_kind_integer,
88 IsSigned = std::numeric_limits<self_type>::is_specialized
89 ? std::numeric_limits<self_type>::is_signed
91 RequireInitialization = 1
95 return std::numeric_limits<Real>::epsilon();
99 return 1000 * epsilon();
111 return std::numeric_limits<Real>::digits10;
116 return static_cast<int>(Real::default_precision());
121 boost::mpl::bool_ < std::numeric_limits<Real>::digits10
122 && (std::numeric_limits<Real>::digits10 != INT_MAX)
132 #if EIGEN_VERSION_AT_LEAST(3, 4, 90)
133 constexpr
static inline int max_digits10()
140 template<
class tag,
class Arg1,
class Arg2,
class Arg3,
class Arg4>
141 struct NumTraits<
boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>>
143 typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type>
147 #if EIGEN_VERSION_AT_LEAST(3, 4, 90)
152 template<
class Backend, boost::multiprecision::expression_
template_option ExpressionTemplates>
153 struct random_default_impl<
154 boost::multiprecision::number<Backend, ExpressionTemplates>,
158 typedef boost::multiprecision::number<Backend, ExpressionTemplates>
Scalar;
172 #if EIGEN_VERSION_AT_LEAST(3, 2, 93)
173 #define BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(A) \
175 class Backend, boost::multiprecision::expression_template_option ExpressionTemplates, \
177 struct ScalarBinaryOpTraits< \
178 boost::multiprecision::number<Backend, ExpressionTemplates>, A, BinaryOp> \
183 typedef boost::multiprecision::number<Backend, ExpressionTemplates> ReturnType; \
186 class Backend, boost::multiprecision::expression_template_option ExpressionTemplates, \
188 struct ScalarBinaryOpTraits< \
189 A, boost::multiprecision::number<Backend, ExpressionTemplates>, BinaryOp> \
194 typedef boost::multiprecision::number<Backend, ExpressionTemplates> ReturnType; \
197 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
float)
198 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
double)
199 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
long double)
200 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
char)
201 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
unsigned char)
202 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
signed char)
203 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
short)
204 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
unsigned short)
205 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
int)
206 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
unsigned int)
207 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
long)
208 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
unsigned long)
212 boost::multiprecision::expression_template_option ExpressionTemplates,
219 struct ScalarBinaryOpTraits<
220 boost::multiprecision::number<Backend, ExpressionTemplates>,
221 boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>,
225 boost::is_convertible<
226 typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::
228 boost::multiprecision::number<Backend, ExpressionTemplates>>::value,
229 "Interoperability with this arithmetic type is not supported.");
230 typedef boost::multiprecision::number<Backend, ExpressionTemplates> ReturnType;
240 boost::multiprecision::expression_template_option ExpressionTemplates,
242 struct ScalarBinaryOpTraits<
243 boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>,
244 boost::multiprecision::number<Backend, ExpressionTemplates>,
248 boost::is_convertible<
249 typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::
251 boost::multiprecision::number<Backend, ExpressionTemplates>>::value,
252 "Interoperability with this arithmetic type is not supported.");
253 typedef boost::multiprecision::number<Backend, ExpressionTemplates> ReturnType;
262 boost::multiprecision::expression_template_option ExpressionTemplates,
268 struct scalar_product_traits<
269 boost::multiprecision::number<Backend, ExpressionTemplates>,
270 boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>>
273 boost::is_convertible<
274 typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::
276 boost::multiprecision::number<Backend, ExpressionTemplates>>::
value,
277 "Interoperability with this arithmetic type is not supported.");
278 typedef boost::multiprecision::number<Backend, ExpressionTemplates>
ReturnType;
288 boost::multiprecision::expression_template_option ExpressionTemplates>
289 struct scalar_product_traits<
290 boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>,
291 boost::multiprecision::number<Backend, ExpressionTemplates>>
294 boost::is_convertible<
295 typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::
297 boost::multiprecision::number<Backend, ExpressionTemplates>>::
value,
298 "Interoperability with this arithmetic type is not supported.");
299 typedef boost::multiprecision::number<Backend, ExpressionTemplates>
ReturnType;
302 template<
typename Scalar>
305 template<
typename Scalar,
bool IsComplex>
306 #if EIGEN_VERSION_AT_LEAST(3, 3, 9)
307 struct conj_default_impl;
312 template<
class tag,
class Arg1,
class Arg2,
class Arg3,
class Arg4>
316 typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type
320 template<
class tag,
class Arg1,
class Arg2,
class Arg3,
class Arg4>
321 #if EIGEN_VERSION_AT_LEAST(3, 3, 9)
322 struct conj_default_impl<
323 boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>,
326 struct
conj_impl<boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>, true>
329 #if EIGEN_VERSION_AT_LEAST(3, 2, 90)
333 typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type
335 const typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4> & x)
345 #endif // ifndef BOOST_MP_EIGEN_HPP
347 #endif // ifndef __pinocchio_math_mutliprecision_hpp__