codegen/cppadcg.hpp
Go to the documentation of this file.
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  template <class T, T value>
41  static inline CGScalar get(const std::integral_constant<T, value> &n)
42  {
43  return CGScalar(constant_pi<Scalar>::get(n));
44  }
45  };
46  }
47  }
48  }
49 }
50 
51 namespace Eigen
52 {
53  namespace internal
54  {
55  // Specialization of Eigen::internal::cast_impl for CppAD input types
56  template<typename Scalar>
57  struct cast_impl<CppAD::cg::CG<Scalar>,Scalar>
58  {
59 #if EIGEN_VERSION_AT_LEAST(3,2,90)
61 #endif
62  static inline Scalar run(const CppAD::cg::CG<Scalar> & x)
63  {
64  return x.getValue();
65  }
66  };
67  }
68 } // namespace Eigen
69 
70 namespace CppAD
71 {
72  template <class Scalar>
73  bool isfinite(const AD<Scalar> & x) { return isfinite(Value(x)); }
74 
75  namespace cg
76  {
77  template <class Scalar>
78  bool isfinite(const CG<Scalar> &x) { return std::isfinite(x.getValue()); }
79  }
80 }
81 
82 namespace pinocchio
83 {
84  template<typename Scalar>
85  struct TaylorSeriesExpansion< CppAD::cg::CG<Scalar> >
86  {
88  typedef CppAD::cg::CG<Scalar> CGScalar;
89 
90  template<int degree>
91  static CGScalar precision()
92  {
93  return CGScalar(Base::template precision<degree>());
94  }
95 
96  };
97 } // namespace pinocchio
98 
99 #endif // #ifndef __pinocchio_codegen_ccpadcg_hpp__
bool isfinite(const CG< Scalar > &x)
Vec3f n
SE3::Scalar Scalar
Definition: conversions.cpp:13
#define EIGEN_DEVICE_FUNC
Definition: tensor.hpp:11
static Scalar run(const CppAD::cg::CG< Scalar > &x)
Main pinocchio namespace.
Definition: timings.cpp:28


pinocchio
Author(s):
autogenerated on Fri Jun 23 2023 02:38:29