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 <boost/mpl/int.hpp>
14 #include <cppad/cg/support/cppadcg_eigen.hpp>
15 
17 
18 #ifndef PINOCCHIO_WITH_CXX11_SUPPORT
19  #error CppADCodeGen requires C++11 or more
20 #endif
21 
22 namespace boost
23 {
24  namespace math
25  {
26  namespace constants
27  {
28  namespace detail
29  {
30  template<typename Scalar>
31  struct constant_pi<CppAD::cg::CG<Scalar>> : constant_pi<Scalar>
32  {
33  typedef CppAD::cg::CG<Scalar> CGScalar;
34 
35  template<int N>
36  static inline CGScalar get(const mpl::int_<N> & n)
37  {
38  return CGScalar(constant_pi<Scalar>::get(n));
39  }
40 
41 #if BOOST_VERSION >= 107700
42  template<class T, T value>
43  static inline CGScalar get(const std::integral_constant<T, value> & n)
44  {
45  return CGScalar(constant_pi<Scalar>::get(n));
46  }
47 #else
48  template<class T, T value>
49  static inline CGScalar get(const boost::integral_constant<T, value> & n)
50  {
51  return CGScalar(constant_pi<Scalar>::get(n));
52  }
53 #endif
54  };
55  } // namespace detail
56  } // namespace constants
57  } // namespace math
58 } // namespace boost
59 
60 namespace Eigen
61 {
62  namespace internal
63  {
64  // Specialization of Eigen::internal::cast_impl for CppAD input types
65  template<typename Scalar>
66  struct cast_impl<CppAD::cg::CG<Scalar>, Scalar>
67  {
68 #if EIGEN_VERSION_AT_LEAST(3, 2, 90)
70 #endif
71  static inline Scalar run(const CppAD::cg::CG<Scalar> & x)
72  {
73  return x.getValue();
74  }
75  };
76 
77  // Specialization of Eigen::internal::cast_impl for CppAD input types
78  template<typename Scalar>
79  struct cast_impl<CppAD::AD<CppAD::cg::CG<Scalar>>, Scalar>
80  {
81 #if EIGEN_VERSION_AT_LEAST(3, 2, 90)
83 #endif
84  static inline Scalar run(const CppAD::AD<CppAD::cg::CG<Scalar>> & x)
85  {
86  return CppAD::Value(x).getValue();
87  }
88  };
89 
90  } // namespace internal
91 } // namespace Eigen
92 
93 namespace CppAD
94 {
95  namespace cg
96  {
97  template<class Scalar>
98  bool isfinite(const CG<Scalar> & x)
99  {
100  return std::isfinite(x.getValue());
101  }
102  } // namespace cg
103 } // namespace CppAD
104 
105 namespace pinocchio
106 {
107  template<typename Scalar>
108  struct TaylorSeriesExpansion<CppAD::cg::CG<Scalar>>
109  {
111  typedef CppAD::cg::CG<Scalar> CGScalar;
112 
113  template<int degree>
115  {
116  return CGScalar(Base::template precision<degree>());
117  }
118  };
119 
120  template<typename Scalar>
121  struct ScalarCast<Scalar, CppAD::cg::CG<Scalar>>
122  {
123  static Scalar cast(const CppAD::cg::CG<Scalar> & cg_value)
124  {
125  return cg_value.getValue();
126  }
127  };
128 
129 } // namespace pinocchio
130 
131 #endif // #ifndef __pinocchio_codegen_ccpadcg_hpp__
Eigen
pinocchio::TaylorSeriesExpansion< CppAD::cg::CG< Scalar > >::precision
static CGScalar precision()
Definition: codegen/cppadcg.hpp:114
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:111
pinocchio::TaylorSeriesExpansion< CppAD::cg::CG< Scalar > >::Base
TaylorSeriesExpansion< Scalar > Base
Definition: codegen/cppadcg.hpp:110
boost
CppAD
Definition: autodiff/cppad.hpp:146
boost::math::constants::detail::constant_pi< CppAD::cg::CG< Scalar > >::get
static CGScalar get(const mpl::int_< N > &n)
Definition: codegen/cppadcg.hpp:36
Eigen::internal::cast_impl< CppAD::cg::CG< Scalar >, Scalar >::run
static Scalar run(const CppAD::cg::CG< Scalar > &x)
Definition: codegen/cppadcg.hpp:71
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:33
pinocchio::ScalarCast< Scalar, CppAD::cg::CG< Scalar > >::cast
static Scalar cast(const CppAD::cg::CG< Scalar > &cg_value)
Definition: codegen/cppadcg.hpp:123
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:84
CppAD::cg::isfinite
bool isfinite(const CG< Scalar > &x)
Definition: codegen/cppadcg.hpp:98
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:49


pinocchio
Author(s):
autogenerated on Fri Nov 1 2024 02:41:43