pinocchio  2.7.1
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
cppadcg.hpp
1 //
2 // Copyright (c) 2018-2023 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_codegen_ccpadcg_hpp__
6 #define __pinocchio_codegen_ccpadcg_hpp__
7 
8 #define PINOCCHIO_WITH_CPPADCG_SUPPORT
9 
10 #include "pinocchio/math/fwd.hpp"
11 
12 #include <cmath>
13 #include <cppad/cg/support/cppadcg_eigen.hpp>
14 
15 #include "pinocchio/autodiff/cppad.hpp"
16 
17 #ifndef PINOCCHIO_WITH_CXX11_SUPPORT
18  #error CppADCodeGen requires C++11 or more
19 #endif
20 
21 namespace boost
22 {
23  namespace math
24  {
25  namespace constants
26  {
27  namespace detail
28  {
29  template<typename Scalar>
30  struct constant_pi< CppAD::cg::CG<Scalar> > : constant_pi<Scalar>
31  {
32  typedef CppAD::cg::CG<Scalar> CGScalar;
33 
34  template <int N>
35  static inline CGScalar get(const mpl::int_<N>& n)
36  {
37  return CGScalar(constant_pi<Scalar>::get(n));
38  }
39 
40 #if BOOST_VERSION >= 107700
41  template <class T, T value>
42  static inline CGScalar get(const std::integral_constant<T, value> &n)
43  {
44  return CGScalar(constant_pi<Scalar>::get(n));
45  }
46 #else
47  template <class T, T value>
48  static inline CGScalar get(const boost::integral_constant<T, value> &n)
49  {
50  return CGScalar(constant_pi<Scalar>::get(n));
51  }
52 #endif
53  };
54  }
55  }
56  }
57 }
58 
59 namespace Eigen
60 {
61  namespace internal
62  {
63  // Specialization of Eigen::internal::cast_impl for CppAD input types
64  template<typename Scalar>
65  struct cast_impl<CppAD::cg::CG<Scalar>,Scalar>
66  {
67 #if EIGEN_VERSION_AT_LEAST(3,2,90)
68  EIGEN_DEVICE_FUNC
69 #endif
70  static inline Scalar run(const CppAD::cg::CG<Scalar> & x)
71  {
72  return x.getValue();
73  }
74  };
75  }
76 } // namespace Eigen
77 
78 namespace CppAD
79 {
80  template <class Scalar>
81  bool isfinite(const AD<Scalar> & x) { return isfinite(Value(x)); }
82 
83  namespace cg
84  {
85  template <class Scalar>
86  bool isfinite(const CG<Scalar> &x) { return std::isfinite(x.getValue()); }
87  }
88 }
89 
90 namespace pinocchio
91 {
92  template<typename Scalar>
93  struct TaylorSeriesExpansion< CppAD::cg::CG<Scalar> >
94  {
96  typedef CppAD::cg::CG<Scalar> CGScalar;
97 
98  template<int degree>
99  static CGScalar precision()
100  {
101  return CGScalar(Base::template precision<degree>());
102  }
103 
104  };
105 } // namespace pinocchio
106 
107 #endif // #ifndef __pinocchio_codegen_ccpadcg_hpp__
continuous.x
x
— Training
Definition: continuous.py:157
pinocchio::TaylorSeriesExpansion
&#160;
Definition: fwd.hpp:31
pinocchio::TaylorSeriesExpansion::precision
static Scalar precision()
Computes the expected tolerance of the argument of a Taylor series expansion for a certain degree acc...
Definition: taylor-expansion.hpp:30
pinocchio
Main pinocchio namespace.
Definition: treeview.dox:11