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 
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  } // namespace detail
55  } // namespace constants
56  } // namespace math
57 } // namespace boost
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)
69 #endif
70  static inline Scalar run(const CppAD::cg::CG<Scalar> & x)
71  {
72  return x.getValue();
73  }
74  };
75 
76  // Specialization of Eigen::internal::cast_impl for CppAD input types
77  template<typename Scalar>
78  struct cast_impl<CppAD::AD<CppAD::cg::CG<Scalar>>, Scalar>
79  {
80 #if EIGEN_VERSION_AT_LEAST(3, 2, 90)
82 #endif
83  static inline Scalar run(const CppAD::AD<CppAD::cg::CG<Scalar>> & x)
84  {
85  return CppAD::Value(x).getValue();
86  }
87  };
88 
89  } // namespace internal
90 } // namespace Eigen
91 
92 namespace CppAD
93 {
94  namespace cg
95  {
96  template<class Scalar>
97  bool isfinite(const CG<Scalar> & x)
98  {
99  return std::isfinite(x.getValue());
100  }
101  } // namespace cg
102 } // namespace CppAD
103 
104 namespace pinocchio
105 {
106  template<typename Scalar>
107  struct TaylorSeriesExpansion<CppAD::cg::CG<Scalar>>
108  {
110  typedef CppAD::cg::CG<Scalar> CGScalar;
111 
112  template<int degree>
114  {
115  return CGScalar(Base::template precision<degree>());
116  }
117  };
118 
119  template<typename Scalar>
120  struct ScalarCast<Scalar, CppAD::cg::CG<Scalar>>
121  {
122  static Scalar cast(const CppAD::cg::CG<Scalar> & cg_value)
123  {
124  return cg_value.getValue();
125  }
126  };
127 
128 } // namespace pinocchio
129 
130 #endif // #ifndef __pinocchio_codegen_ccpadcg_hpp__
Eigen
pinocchio::TaylorSeriesExpansion< CppAD::cg::CG< Scalar > >::precision
static CGScalar precision()
Definition: codegen/cppadcg.hpp:113
pinocchio::python::Scalar
context::Scalar Scalar
Definition: admm-solver.cpp:29
pinocchio::TaylorSeriesExpansion< CppAD::cg::CG< Scalar > >::CGScalar
CppAD::cg::CG< Scalar > CGScalar
Definition: codegen/cppadcg.hpp:110
pinocchio::TaylorSeriesExpansion< CppAD::cg::CG< Scalar > >::Base
TaylorSeriesExpansion< Scalar > Base
Definition: codegen/cppadcg.hpp:109
boost
CppAD
Definition: autodiff/cppad.hpp:145
boost::math::constants::detail::constant_pi< CppAD::cg::CG< Scalar > >::get
static CGScalar get(const mpl::int_< N > &n)
Definition: codegen/cppadcg.hpp:35
Eigen::internal::cast_impl< CppAD::cg::CG< Scalar >, Scalar >::run
static Scalar run(const CppAD::cg::CG< Scalar > &x)
Definition: codegen/cppadcg.hpp:70
fwd.hpp
x
x
pinocchio::TaylorSeriesExpansion
&#160;
Definition: math/fwd.hpp:34
boost::math::constants::detail::constant_pi< CppAD::cg::CG< Scalar > >::CGScalar
CppAD::cg::CG< Scalar > CGScalar
Definition: codegen/cppadcg.hpp:32
pinocchio::ScalarCast< Scalar, CppAD::cg::CG< Scalar > >::cast
static Scalar cast(const CppAD::cg::CG< Scalar > &cg_value)
Definition: codegen/cppadcg.hpp:122
cppad.hpp
Eigen::internal::cast_impl< CppAD::AD< CppAD::cg::CG< Scalar > >, Scalar >::run
static Scalar run(const CppAD::AD< CppAD::cg::CG< Scalar >> &x)
Definition: codegen/cppadcg.hpp:83
CppAD::cg::isfinite
bool isfinite(const CG< Scalar > &x)
Definition: codegen/cppadcg.hpp:97
EIGEN_DEVICE_FUNC
#define EIGEN_DEVICE_FUNC
Definition: tensor.hpp:11
n
Vec3f n
pinocchio::ScalarCast
Cast scalar type from type FROM to type TO.
Definition: fwd.hpp:105
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
boost::math::constants::detail::constant_pi< CppAD::cg::CG< Scalar > >::get
static CGScalar get(const boost::integral_constant< T, value > &n)
Definition: codegen/cppadcg.hpp:48


pinocchio
Author(s):
autogenerated on Sat Jun 1 2024 02:40:34