codegen/cppadcg.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2018-2020 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  }
41  }
42  }
43 }
44 
45 namespace Eigen
46 {
47  namespace internal
48  {
49  // Specialization of Eigen::internal::cast_impl for CppAD input types
50  template<typename Scalar>
51  struct cast_impl<CppAD::cg::CG<Scalar>,Scalar>
52  {
53 #if EIGEN_VERSION_AT_LEAST(3,2,90)
55 #endif
56  static inline Scalar run(const CppAD::cg::CG<Scalar> & x)
57  {
58  return x.getValue();
59  }
60  };
61  }
62 } // namespace Eigen
63 
64 namespace CppAD
65 {
66  template <class Scalar>
67  bool isfinite(const cg::CG<Scalar> & x) { return std::isfinite(x.getValue()); }
68 
69  template <class Scalar>
70  bool isfinite(const AD<Scalar> & x) { return isfinite(Value(x)); }
71 }
72 
73 namespace pinocchio
74 {
75  template<typename Scalar>
76  struct TaylorSeriesExpansion< CppAD::cg::CG<Scalar> >
77  {
79  typedef CppAD::cg::CG<Scalar> CGScalar;
80 
81  template<int degree>
82  static CGScalar precision()
83  {
84  return CGScalar(Base::template precision<degree>());
85  }
86 
87  };
88 } // namespace pinocchio
89 
90 #endif // #ifndef __pinocchio_codegen_ccpadcg_hpp__
bool isfinite(const AD< Scalar > &x)
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:30
x
— Training
Definition: continuous.py:157


pinocchio
Author(s):
autogenerated on Tue Jun 1 2021 02:45:02