pinocchio  3.7.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
 
Loading...
Searching...
No Matches
eigen-macros.hpp
1//
2// Copyright (c) 2017-2024 CNRS INRIA
3//
4
5#ifndef __pinocchio_eigen_macros_hpp__
6#define __pinocchio_eigen_macros_hpp__
7
8#include "pinocchio/utils/eigen-fix.hpp"
9
11#define PINOCCHIO_EIGEN_PLAIN_TYPE(D) \
12 Eigen::internal::plain_matrix_type<typename pinocchio::helper::argument_type<void(D)>::type>::type
13#define PINOCCHIO_EIGEN_PLAIN_TYPE_NO_PARENS(D) \
14 Eigen::internal::plain_matrix_type<typename pinocchio::helper::argument_type<void D>::type>::type
15
18#define PINOCCHIO_EIGEN_PLAIN_COLUMN_MAJOR_TYPE(D) \
19 pinocchio::helper::handle_return_type_without_typename< \
20 D, Eigen::internal::plain_matrix_type_column_major>::type
21
23#define PINOCCHIO_EIGEN_PLAIN_ROW_MAJOR_TYPE(D) \
24 pinocchio::helper::handle_return_type_without_typename< \
25 D, ::pinocchio::fix::Eigen::internal::plain_matrix_type_row_major>::type
26
28#define PINOCCHIO_EIGEN_REF_CONST_TYPE(D) Eigen::internal::ref_selector<D>::type
29#if EIGEN_VERSION_AT_LEAST(3, 2, 90)
30 #define PINOCCHIO_EIGEN_REF_TYPE(D) Eigen::internal::ref_selector<D>::non_const_type
31#else
32 #define PINOCCHIO_EIGEN_REF_TYPE(D) \
33 Eigen::internal::conditional< \
34 bool(Eigen::internal::traits<D>::Flags & Eigen::NestByRefBit), D &, D>::type
35#endif
36
38#if EIGEN_VERSION_AT_LEAST(3, 3, 0)
39 #define PINOCCHIO_EIGEN_DOT_PRODUCT_RETURN_TYPE(D1, D2) \
40 Eigen::ScalarBinaryOpTraits< \
41 typename Eigen::internal::traits<D1>::Scalar, \
42 typename Eigen::internal::traits<D2>::Scalar>::ReturnType
43#else
44 #define PINOCCHIO_EIGEN_DOT_PRODUCT_RETURN_TYPE(D1, D2) \
45 Eigen::internal::scalar_product_traits< \
46 typename Eigen::internal::traits<D1>::Scalar, \
47 typename Eigen::internal::traits<D2>::Scalar>::ReturnType
48#endif
49
51#define PINOCCHIO_EIGEN_CONST_CAST(TYPE, OBJ) const_cast<TYPE &>(OBJ.derived())
52
54#if EIGEN_VERSION_AT_LEAST(3, 2, 90)
55 #define PINOCCHIO_WITH_EIGEN_TENSOR_MODULE
56#endif
57
61
62#ifdef PINOCCHIO_EIGEN_CHECK_MALLOC
63 #define PINOCCHIO_EIGEN_MALLOC(allowed) ::Eigen::internal::set_is_malloc_allowed(allowed)
64 #define PINOCCHIO_EIGEN_MALLOC_ALLOWED() PINOCCHIO_EIGEN_MALLOC(true)
65 #define PINOCCHIO_EIGEN_MALLOC_NOT_ALLOWED() PINOCCHIO_EIGEN_MALLOC(false)
66 #define PINOCCHIO_EIGEN_MALLOC_SAVE_STATUS() ::pinocchio::internal::save_eigen_malloc_status()
67 #define PINOCCHIO_EIGEN_MALLOC_RESTORE_STATUS() \
68 PINOCCHIO_EIGEN_MALLOC((::pinocchio::internal::get_saved_eigen_malloc_status()))
69#else
70 #define PINOCCHIO_EIGEN_MALLOC(allowed)
71 #define PINOCCHIO_EIGEN_MALLOC_ALLOWED()
72 #define PINOCCHIO_EIGEN_MALLOC_NOT_ALLOWED()
73 #define PINOCCHIO_EIGEN_MALLOC_SAVE_STATUS()
74 #define PINOCCHIO_EIGEN_MALLOC_RESTORE_STATUS()
75#endif
76
77#ifdef PINOCCHIO_EIGEN_CHECK_MALLOC
78namespace pinocchio
79{
80 namespace internal
81 {
82
83 inline bool save_or_get_malloc_status(bool update, bool new_value = false)
84 {
85 thread_local static bool value;
86 if (update)
87 value = new_value;
88 return value;
89 }
90
91 inline void save_eigen_malloc_status()
92 {
93 save_or_get_malloc_status(true, ::Eigen::internal::is_malloc_allowed());
94 }
95
96 inline bool get_saved_eigen_malloc_status()
97 {
98 return save_or_get_malloc_status(false);
99 }
100 } // namespace internal
101} // namespace pinocchio
102#endif // ifdef PINOCCHIO_EIGEN_CHECK_MALLOC
103
104#endif // ifndef __pinocchio_eigen_macros_hpp__
Main pinocchio namespace.
Definition treeview.dox:11