5 #ifndef __pinocchio_autodiff_cppad_hpp__
6 #define __pinocchio_autodiff_cppad_hpp__
8 #include "pinocchio/math/fwd.hpp"
9 #define PINOCCHIO_WITH_CPPAD_SUPPORT
16 #define EIGEN_MATRIXBASE_PLUGIN <pinocchio/autodiff/cppad/math/eigen_plugin.hpp>
18 #include <cppad/cppad.hpp>
19 #include <Eigen/Dense>
29 template<
typename Scalar>
30 struct constant_pi< CppAD::AD<Scalar> > : constant_pi<Scalar>
32 typedef CppAD::AD<Scalar> ADScalar;
35 static inline ADScalar get(
const mpl::int_<N>& n)
37 return ADScalar(constant_pi<Scalar>::get(n));
40 #if BOOST_VERSION >= 107700
41 template <
class T, T value>
42 static inline ADScalar get(
const std::integral_constant<T, value> &n)
44 return ADScalar(constant_pi<Scalar>::get(n));
47 template <
class T, T value>
48 static inline ADScalar get(
const boost::integral_constant<T, value> &n)
50 return ADScalar(constant_pi<Scalar>::get(n));
64 template<
typename Scalar>
65 struct cast_impl<CppAD::AD<Scalar>,Scalar>
67 #if EIGEN_VERSION_AT_LEAST(3,2,90)
70 static inline Scalar run(
const CppAD::AD<Scalar> & x)
72 return CppAD::Value(x);
81 template <
class Base>
struct NumTraits< CppAD::AD<Base> >
83 typedef CppAD::AD<Base> Real;
85 typedef CppAD::AD<Base> NonInteger;
87 typedef CppAD::AD<Base> Literal;
89 typedef CppAD::AD<Base> Nested;
99 RequireInitialization = 1 ,
108 static CppAD::AD<Base> epsilon(
void)
109 {
return CppAD::numeric_limits< CppAD::AD<Base> >::epsilon(); }
113 static CppAD::AD<Base> dummy_precision(
void)
115 CppAD::numeric_limits< CppAD::AD<Base> >::epsilon();
119 static CppAD::AD<Base> lowest(
void)
120 {
return CppAD::numeric_limits< CppAD::AD<Base> >::min(); }
123 static CppAD::AD<Base> highest(
void)
124 {
return CppAD::numeric_limits< CppAD::AD<Base> >::max(); }
127 static int digits10(
void)
128 {
return CppAD::numeric_limits< CppAD::AD<Base> >::digits10; }
133 #include "pinocchio/utils/static-if.hpp"
139 template <
class Base>
const AD<Base>& conj(
const AD<Base>& x)
141 template <
class Base>
const AD<Base>& real(
const AD<Base>& x)
145 template <
class Base> AD<Base> imag(
const AD<Base>& )
146 {
return CppAD::AD<Base>(0.); }
147 template <
class Base> AD<Base> abs2(
const AD<Base>& x)
150 template<
typename Scalar>
151 AD<Scalar> min(
const AD<Scalar>& x,
const AD<Scalar>& y)
153 using ::pinocchio::internal::if_then_else;
154 using ::pinocchio::internal::LT;
155 return if_then_else(LT, y, x, y, x);
158 template<
typename Scalar>
159 AD<Scalar> max(
const AD<Scalar>& x,
const AD<Scalar>& y)
161 using ::pinocchio::internal::if_then_else;
162 using ::pinocchio::internal::LT;
163 return if_then_else(LT, x, y, y, x);
168 #include "pinocchio/utils/static-if.hpp"
172 template<
typename Scalar>
176 typedef CppAD::AD<Scalar> ADScalar;
181 return ADScalar(Base::template precision<degree>());
188 #include "pinocchio/autodiff/cppad/spatial/se3-tpl.hpp"
189 #include "pinocchio/autodiff/cppad/spatial/log.hxx"
190 #include "pinocchio/autodiff/cppad/utils/static-if.hpp"
191 #include "pinocchio/autodiff/cppad/math/quaternion.hpp"
192 #include "pinocchio/autodiff/cppad/algorithm/aba.hpp"
195 #endif // #ifndef __pinocchio_autodiff_cppad_hpp__