pinocchio
4.1.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
Toggle main menu visibility
Loading...
Searching...
No Matches
cppadcg.hpp
1
//
2
// Copyright (c) 2018-2023 CNRS INRIA
3
//
4
5
#pragma once
6
7
// IWYU pragma: always_keep
8
9
#define PINOCCHIO_WITH_CPPADCG_SUPPORT
10
11
// IWYU pragma: begin_keep
12
#include <cmath>
13
#include <type_traits>
14
15
#include <Eigen/Core>
16
17
#include <boost/version.hpp>
18
#include <boost/math/constants/constants.hpp>
19
#include <boost/mpl/int.hpp>
20
21
#include <cppad/cg.hpp>
22
#include <cppad/cg/support/cppadcg_eigen.hpp>
23
24
#include "pinocchio/math.hpp"
25
#include "pinocchio/autodiff/cppad.hpp"
26
// IWYU pragma: end_keep
27
28
namespace
boost
29
{
30
namespace
math
31
{
32
namespace
constants
33
{
34
namespace
detail
35
{
36
template
<
typename
Scalar>
37
struct
constant_pi<CppAD::cg::CG<Scalar>> : constant_pi<Scalar>
38
{
39
typedef
CppAD::cg::CG<Scalar> CGScalar;
40
41
template
<
int
N>
42
static
inline
CGScalar get(
const
mpl::int_<N> & n)
43
{
44
return
CGScalar(constant_pi<Scalar>::get(n));
45
}
46
47
#if BOOST_VERSION >= 107700
48
template
<
class
T, T value>
49
static
inline
CGScalar get(
const
std::integral_constant<T, value> & n)
50
{
51
return
CGScalar(constant_pi<Scalar>::get(n));
52
}
53
#else
54
template
<
class
T, T value>
55
static
inline
CGScalar get(
const
boost::integral_constant<T, value> & n)
56
{
57
return
CGScalar(constant_pi<Scalar>::get(n));
58
}
59
#endif
60
};
61
}
// namespace detail
62
}
// namespace constants
63
}
// namespace math
64
}
// namespace boost
65
66
namespace
Eigen
67
{
68
namespace
internal
69
{
70
// Specialization of Eigen::internal::cast_impl for CppAD input types
71
template
<
typename
Scalar>
72
struct
cast_impl<CppAD::cg::CG<Scalar>, Scalar>
73
{
74
EIGEN_DEVICE_FUNC
75
static
inline
Scalar run(
const
CppAD::cg::CG<Scalar> & x)
76
{
77
return
x.getValue();
78
}
79
};
80
81
// Specialization of Eigen::internal::cast_impl for CppAD input types
82
template
<
typename
Scalar>
83
struct
cast_impl<CppAD::AD<CppAD::cg::CG<Scalar>>, Scalar>
84
{
85
EIGEN_DEVICE_FUNC
86
static
inline
Scalar run(
const
CppAD::AD<CppAD::cg::CG<Scalar>> & x)
87
{
88
return
CppAD::Value(x).getValue();
89
}
90
};
91
92
}
// namespace internal
93
}
// namespace Eigen
94
95
namespace
CppAD
96
{
97
namespace
cg
98
{
99
template
<
class
Scalar>
100
bool
isfinite(
const
CG<Scalar> & x)
101
{
102
return
std::isfinite(x.getValue());
103
}
104
}
// namespace cg
105
}
// namespace CppAD
106
107
// IWYU pragma: begin_exports
108
#include "pinocchio/src/codegen/cppadcg/math/cast.hxx"
109
#include "pinocchio/src/codegen/cppadcg/math/taylor-series-expansion.hxx"
110
// IWYU pragma: end_exports
include
pinocchio
codegen
cppadcg.hpp
Generated by
1.17.0