eigenpy
3.13.0
Bindings between Numpy and Eigen using Boost.Python
Toggle main menu visibility
Loading...
Searching...
No Matches
fwd.hpp
1
/*
2
* Copyright 2014-2024 CNRS INRIA
3
*/
4
5
#ifndef __eigenpy_fwd_hpp__
6
#define __eigenpy_fwd_hpp__
7
8
#if defined(__clang__)
9
#define EIGENPY_CLANG_COMPILER
10
#elif defined(__GNUC__)
11
#define EIGENPY_GCC_COMPILER
12
#elif defined(_MSC_VER)
13
#define EIGENPY_MSVC_COMPILER
14
#endif
15
16
#if (__cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703))
17
#define EIGENPY_WITH_CXX17_SUPPORT
18
#endif
19
20
#if (__cplusplus >= 201402L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201403))
21
#define EIGENPY_WITH_CXX14_SUPPORT
22
#endif
23
24
#if (__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600))
25
#define EIGENPY_WITH_CXX11_SUPPORT
26
#endif
27
28
#define EIGENPY_STRING_LITERAL(string) #string
29
#define EIGENPY_STRINGIZE(string) EIGENPY_STRING_LITERAL(string)
30
#define _EIGENPY_PPCAT(A, B) A##B
31
#define EIGENPY_PPCAT(A, B) _EIGENPY_PPCAT(A, B)
32
#define EIGENPY_STRINGCAT(A, B) A B
33
34
// For more details, visit
35
// https://stackoverflow.com/questions/171435/portability-of-warning-preprocessor-directive
36
#if defined(EIGENPY_CLANG_COMPILER) || defined(EIGENPY_GCC_COMPILER)
37
#define EIGENPY_PRAGMA(x) _Pragma(#x)
38
#define EIGENPY_PRAGMA_MESSAGE(the_message) \
39
EIGENPY_PRAGMA(GCC message #the_message)
40
#define EIGENPY_PRAGMA_WARNING(the_message) \
41
EIGENPY_PRAGMA(GCC warning #the_message)
42
#define EIGENPY_PRAGMA_DEPRECATED(the_message) \
43
EIGENPY_PRAGMA_WARNING(Deprecated : #the_message)
44
#define EIGENPY_PRAGMA_DEPRECATED_HEADER(old_header, new_header) \
45
EIGENPY_PRAGMA_WARNING( \
46
Deprecated header file : #old_header has been replaced \
47
by #new_header.\n Please use #new_header instead of #old_header.)
48
#elif defined(WIN32)
49
#define EIGENPY_PRAGMA(x) __pragma(#x)
50
#define EIGENPY_PRAGMA_MESSAGE(the_message) \
51
EIGENPY_PRAGMA(message(#the_message))
52
#define EIGENPY_PRAGMA_WARNING(the_message) \
53
EIGENPY_PRAGMA(message(EIGENPY_STRINGCAT("WARNING: ", the_message)))
54
#endif
55
56
#define EIGENPY_DEPRECATED_MACRO(macro, the_message) \
57
EIGENPY_PRAGMA_WARNING( \
58
EIGENPY_STRINGCAT("this macro is deprecated: ", the_message))
59
#define EIGENPY_DEPRECATED_FILE(the_message) \
60
EIGENPY_PRAGMA_WARNING( \
61
EIGENPY_STRINGCAT("this file is deprecated: ", the_message))
62
63
#define EIGENPY_DOCUMENTATION_START_IGNORE
64
#define EIGENPY_DOCUMENTATION_END_IGNORE
65
66
#include "eigenpy/config.hpp"
67
#include <boost/type_traits/is_base_of.hpp>
68
69
// Silence a warning about a deprecated use of boost bind by boost python
70
// at least fo boost 1.73 to 1.75
71
// ref. https://github.com/stack-of-tasks/tsid/issues/128
72
#define BOOST_BIND_GLOBAL_PLACEHOLDERS
73
#include <boost/python.hpp>
74
#include <boost/python/scope.hpp>
75
76
#include <type_traits>
77
#include <utility>
78
79
namespace
eigenpy
{
80
81
namespace
bp = boost::python;
82
83
}
84
85
#define NO_IMPORT_ARRAY
86
#include "eigenpy/numpy.hpp"
87
#undef NO_IMPORT_ARRAY
88
89
#undef BOOST_BIND_GLOBAL_PLACEHOLDERS
90
91
#include <Eigen/Core>
92
#include <Eigen/Sparse>
93
#include <Eigen/Geometry>
94
95
#ifdef EIGENPY_WITH_CXX11_SUPPORT
96
#include <unsupported/Eigen/CXX11/Tensor>
97
#define EIGENPY_WITH_TENSOR_SUPPORT
98
#endif
99
100
#if EIGEN_VERSION_AT_LEAST(3, 2, 90)
101
#define EIGENPY_DEFAULT_ALIGNMENT_VALUE Eigen::Aligned16
102
#else
103
#define EIGENPY_DEFAULT_ALIGNMENT_VALUE Eigen::Aligned
104
#endif
105
106
#define EIGENPY_DEFAULT_ALIGN_BYTES EIGEN_DEFAULT_ALIGN_BYTES
107
108
#define EIGENPY_NO_ALIGNMENT_VALUE Eigen::Unaligned
109
110
#define EIGENPY_UNUSED_VARIABLE(var) (void)(var)
111
#define EIGENPY_UNUSED_TYPE(type) EIGENPY_UNUSED_VARIABLE((type*)(NULL))
112
#ifndef NDEBUG
113
#define EIGENPY_USED_VARIABLE_ONLY_IN_DEBUG_MODE(var)
114
#else
115
#define EIGENPY_USED_VARIABLE_ONLY_IN_DEBUG_MODE(var) \
116
EIGENPY_UNUSED_VARIABLE(var)
117
#endif
118
119
#ifdef EIGENPY_WITH_CXX11_SUPPORT
120
#include <memory>
121
#define EIGENPY_SHARED_PTR_HOLDER_TYPE(T) ::std::shared_ptr<T>
122
#else
123
#include <boost/shared_ptr.hpp>
124
#define EIGENPY_SHARED_PTR_HOLDER_TYPE(T) ::boost::shared_ptr<T>
125
#endif
126
127
namespace
eigenpy
{
128
129
// Default Scalar value can't be defined in the declaration
130
// because of a CL bug.
131
// See https://github.com/stack-of-tasks/eigenpy/pull/462
132
template
<
typename
MatType,
typename
Scalar>
133
struct
EigenToPy
;
134
template
<
typename
MatType,
typename
Scalar>
135
struct
EigenFromPy
;
136
137
template
<
typename
T>
138
struct
remove_const_reference
{
139
typedef
typename
boost::remove_const<
140
typename
boost::remove_reference<T>::type>::type type;
141
};
142
143
template
<
typename
EigenType>
144
struct
get_eigen_base_type
{
145
typedef
typename
remove_const_reference<EigenType>::type EigenType_;
146
typedef
typename
boost::mpl::if_<
147
boost::is_base_of<Eigen::MatrixBase<EigenType_>, EigenType_>,
148
Eigen::MatrixBase<EigenType_>,
149
typename
boost::mpl::if_<
150
boost::is_base_of<Eigen::SparseMatrixBase<EigenType_>, EigenType_>,
151
Eigen::SparseMatrixBase<EigenType_>
152
#ifdef EIGENPY_WITH_TENSOR_SUPPORT
153
,
154
typename
boost::mpl::if_<
155
boost::is_base_of<Eigen::TensorBase<EigenType_>, EigenType_>,
156
Eigen::TensorBase<EigenType_>,
void
>::type
157
#else
158
,
159
void
160
#endif
161
>::type>::type _type;
162
163
typedef
typename
boost::mpl::if_<
164
boost::is_const<typename boost::remove_reference<EigenType>::type>,
165
const
_type, _type>::type type;
166
};
167
168
template
<
typename
EigenType>
169
struct
get_eigen_plain_type
;
170
171
template
<
typename
MatType,
int
Options,
typename
Str
id
e>
172
struct
get_eigen_plain_type
<Eigen::Ref<MatType, Options, Stride>> {
173
typedef
typename
Eigen::internal::traits<
174
Eigen::Ref<MatType, Options, Stride>>::PlainObjectType type;
175
};
176
177
#ifdef EIGENPY_WITH_TENSOR_SUPPORT
178
template
<
typename
TensorType>
179
struct
get_eigen_plain_type
<Eigen::TensorRef<TensorType>> {
180
typedef
TensorType
type
;
181
};
182
#endif
183
184
namespace
internal {
185
template
<
class
T1,
class
T2>
186
struct
has_operator_equal_impl {
187
template
<
class
U,
class
V>
188
static
auto
check(U*) ->
decltype
(std::declval<U>() == std::declval<V>());
189
template
<
typename
,
typename
>
190
static
auto
check(...) -> std::false_type;
191
192
using
type =
typename
std::is_same<bool, decltype(check<T1, T2>(0))>::type;
193
};
194
}
// namespace internal
195
196
template
<
class
T1,
class
T2 = T1>
197
struct
has_operator_equal
: internal::has_operator_equal_impl<T1, T2>
::type
{};
198
199
namespace
literals {
204
inline
boost::python::arg
operator
""
_a(
const
char
* name, std::size_t) {
205
return
boost::python::arg(name);
206
}
207
}
// namespace literals
208
209
}
// namespace eigenpy
210
211
#include "eigenpy/alignment.hpp"
212
#include "eigenpy/id.hpp"
213
214
#endif
// ifndef __eigenpy_fwd_hpp__
eigenpy
Definition
alignment.hpp:14
eigenpy::EigenFromPy
Definition
eigen-from-python.hpp:296
eigenpy::EigenToPy
Definition
eigen-to-python.hpp:163
eigenpy::type
eigenpy::get_eigen_base_type
Definition
fwd.hpp:144
eigenpy::get_eigen_plain_type
Definition
fwd.hpp:169
eigenpy::has_operator_equal
Definition
fwd.hpp:197
eigenpy::remove_const_reference
Definition
fwd.hpp:138
include
eigenpy
fwd.hpp
Generated by
1.17.0