5 #ifndef __pinocchio_math_mutliprecision_hpp__ 6 #define __pinocchio_math_mutliprecision_hpp__ 8 #include "pinocchio/math/fwd.hpp" 10 #ifndef PINOCCHIO_WITH_CXX11_SUPPORT 11 #error C++11 compiler required. 14 #include <boost/multiprecision/number.hpp> 15 #include <Eigen/Dense> 21 template <
typename Backend,
22 boost::multiprecision::expression_template_option ET>
24 : boost::integral_constant<
26 ((std::numeric_limits<
27 boost::multiprecision::number<Backend, ET>>::is_specialized and
29 boost::multiprecision::number<Backend, ET>>::has_infinity))>
38 template <
class Backend, boost::multiprecision::expression_
template_option ExpressionTemplates,
typename Scalar>
39 struct cast_impl<boost::multiprecision::number<Backend, ExpressionTemplates>,
Scalar>
41 #if EIGEN_VERSION_AT_LEAST(3,2,90) 44 static inline Scalar run(
const boost::multiprecision::number<Backend, ExpressionTemplates> &
x)
46 return x.template convert_to<Scalar>();
52 #ifndef BOOST_MP_EIGEN_HPP 60 template <
class Backend, boost::multiprecision::expression_
template_option ExpressionTemplates>
61 struct NumTraits<boost::multiprecision::number<Backend, ExpressionTemplates> >
63 typedef boost::multiprecision::number<Backend, ExpressionTemplates>
self_type;
64 #if BOOST_VERSION / 100 % 1000 >= 68 74 #if BOOST_VERSION / 100 % 1000 >= 68 75 IsComplex = boost::multiprecision::number_category<self_type>::value == boost::multiprecision::number_kind_complex,
79 IsInteger = boost::multiprecision::number_category<self_type>::value == boost::multiprecision::number_kind_integer,
83 IsSigned = std::numeric_limits<self_type>::is_specialized ? std::numeric_limits<self_type>::is_signed :
true,
84 RequireInitialization = 1
88 return std::numeric_limits<Real>::epsilon();
92 return 1000 * epsilon();
104 return std::numeric_limits<Real>::digits10;
109 return Real::default_precision();
113 return digits10_imp(boost::mpl::bool_ < std::numeric_limits<Real>::digits10 && (std::numeric_limits<Real>::digits10 != INT_MAX) ?
true :
false > ());
117 template <
class tag,
class Arg1,
class Arg2,
class Arg3,
class Arg4>
118 struct NumTraits<
boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4> > :
public NumTraits<typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type>
122 #if EIGEN_VERSION_AT_LEAST(3,2,93) 123 #define BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(A) \ 124 template <class Backend, boost::multiprecision::expression_template_option ExpressionTemplates, typename BinaryOp> \ 125 struct ScalarBinaryOpTraits<boost::multiprecision::number<Backend, ExpressionTemplates>, A, BinaryOp> \ 128 typedef boost::multiprecision::number<Backend, ExpressionTemplates> ReturnType; \ 130 template <class Backend, boost::multiprecision::expression_template_option ExpressionTemplates, typename BinaryOp> \ 131 struct ScalarBinaryOpTraits<A, boost::multiprecision::number<Backend, ExpressionTemplates>, BinaryOp> \ 134 typedef boost::multiprecision::number<Backend, ExpressionTemplates> ReturnType; \ 137 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
float)
138 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
double)
139 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
long double)
140 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
char)
141 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
unsigned char)
142 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
signed char)
143 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
short)
144 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
unsigned short)
145 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
int)
146 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
unsigned int)
147 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
long)
148 BOOST_MP_EIGEN_SCALAR_TRAITS_DECL(
unsigned long)
150 template <
class Backend, boost::multiprecision::expression_
template_option ExpressionTemplates,
class tag,
class Arg1,
class Arg2,
class Arg3,
class Arg4,
typename BinaryOp>
151 struct ScalarBinaryOpTraits<boost::multiprecision::number<Backend, ExpressionTemplates>, boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>, BinaryOp>
153 static_assert(boost::is_convertible<
typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type, boost::multiprecision::number<Backend, ExpressionTemplates> >::
value,
"Interoperability with this arithmetic type is not supported.");
154 typedef boost::multiprecision::number<Backend, ExpressionTemplates> ReturnType;
157 template <
class tag,
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Backend, boost::multiprecision::expression_
template_option ExpressionTemplates,
typename BinaryOp>
158 struct ScalarBinaryOpTraits<boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>, boost::multiprecision::number<Backend, ExpressionTemplates>, BinaryOp>
160 static_assert(boost::is_convertible<
typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type, boost::multiprecision::number<Backend, ExpressionTemplates> >::
value,
"Interoperability with this arithmetic type is not supported.");
161 typedef boost::multiprecision::number<Backend, ExpressionTemplates> ReturnType;
168 template <
class Backend, boost::multiprecision::expression_
template_option ExpressionTemplates,
class tag,
class Arg1,
class Arg2,
class Arg3,
class Arg4>
169 struct scalar_product_traits<boost::multiprecision::number<Backend, ExpressionTemplates>, boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4> >
171 static_assert(boost::is_convertible<
typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type, boost::multiprecision::number<Backend, ExpressionTemplates> >::value,
"Interoperability with this arithmetic type is not supported.");
172 typedef boost::multiprecision::number<Backend, ExpressionTemplates>
ReturnType;
175 template <
class tag,
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Backend, boost::multiprecision::expression_
template_option ExpressionTemplates>
176 struct scalar_product_traits<boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>, boost::multiprecision::number<Backend, ExpressionTemplates> >
178 static_assert(boost::is_convertible<
typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type, boost::multiprecision::number<Backend, ExpressionTemplates> >::value,
"Interoperability with this arithmetic type is not supported.");
179 typedef boost::multiprecision::number<Backend, ExpressionTemplates>
ReturnType;
182 template <
typename Scalar>
185 template <
typename Scalar,
bool IsComplex>
188 template <
class tag,
class Arg1,
class Arg2,
class Arg3,
class Arg4>
189 struct conj_retval<boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4> >
191 typedef typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type
type;
194 template <
class tag,
class Arg1,
class Arg2,
class Arg3,
class Arg4>
195 struct conj_impl<boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>, true>
197 #if EIGEN_VERSION_AT_LEAST(3,2,90) 200 static inline typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type
run(
const typename boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4>&
x)
210 #endif // ifndef BOOST_MP_EIGEN_HPP 212 #endif // ifndef __pinocchio_math_mutliprecision_hpp__ JointCollectionTpl const DataTpl< Scalar, Options, JointCollectionTpl > const Eigen::MatrixBase< Mat > & min
const AD< Base > & conj(const AD< Base > &x)
boost::multiprecision::number< Backend, ExpressionTemplates > ReturnType
boost::multiprecision::number< Backend, ExpressionTemplates > ReturnType
static Scalar run(const boost::multiprecision::number< Backend, ExpressionTemplates > &x)
AD< Scalar > max(const AD< Scalar > &x, const AD< Scalar > &y)
static int digits10_imp(const boost::mpl::true_ &)
boost::multiprecision::detail::expression< tag, Arg1, Arg2, Arg3, Arg4 >::result_type type
#define EIGEN_DEVICE_FUNC
boost::multiprecision::number< Backend, ExpressionTemplates > self_type
static boost::multiprecision::detail::expression< tag, Arg1, Arg2, Arg3, Arg4 >::result_type run(const typename boost::multiprecision::detail::expression< tag, Arg1, Arg2, Arg3, Arg4 > &x)
static Real dummy_precision()
Main pinocchio namespace.
static int digits10_imp(const boost::mpl::bool_< B > &)