5#ifndef NURI_EIGEN_CONFIG_H_
6#define NURI_EIGEN_CONFIG_H_
12#include <absl/base/optimization.h>
13#include <absl/log/absl_check.h>
22#define NURI_EIGEN_TMP(type) Eigen::type
24#define NURI_EIGEN_TMP(type) \
25 { static_assert(std::is_class_v<Eigen::type>); } \
29#ifdef EIGEN_RUNTIME_NO_MALLOC
30#define NURI_EIGEN_ALLOW_MALLOC(flag) \
31 Eigen::internal::set_is_malloc_allowed(flag)
32#define NURI_EIGEN_MALLOC_ALLOWED() Eigen::internal::is_malloc_allowed()
34#define NURI_EIGEN_ALLOW_MALLOC(flag) static_cast<void>(flag)
35#define NURI_EIGEN_MALLOC_ALLOWED() true
52using ArrayXb = E::ArrayX<bool>;
53using ArrayXc = ArrayX<std::int8_t>;
67using ArrayXXc = ArrayXX<std::int8_t>;
88using E::Translation3d;
90template <
class DT,
int Dim>
91using IsometryT = E::Transform<DT, Dim, E::Isometry>;
93template <
class Raw,
int Options = 0,
95 std::conditional_t<Raw::IsVectorAtCompileTime != 0,
96 E::InnerStride<1>, E::OuterStride<>>>
97using MutRef = E::Ref<internal::remove_cvref_t<Raw>, Options, StrideType>;
99template <
class Raw,
int Options = 0,
101 std::conditional_t<Raw::IsVectorAtCompileTime != 0,
102 E::InnerStride<1>, E::OuterStride<>>>
104 const E::Ref<const internal::remove_cvref_t<Raw>, Options, StrideType> &;
106template <
class Raw,
int BlockRows = E::Dynamic,
int BlockCols = E::Dynamic,
107 bool InnerPanel =
false>
109 E::Block<internal::remove_cvref_t<Raw>, BlockRows, BlockCols, InnerPanel>;
111template <
class Raw,
int BlockRows = E::Dynamic,
int BlockCols = E::Dynamic,
112 bool InnerPanel =
false>
113using ConstBlock =
const E::Block<const internal::remove_cvref_t<Raw>,
114 BlockRows, BlockCols, InnerPanel> &;
116template <
class Raw,
int Size = E::Dynamic>
117using MutVecBlock = E::VectorBlock<internal::remove_cvref_t<Raw>, Size>;
119template <
class Raw,
int Size = E::Dynamic>
121 const E::VectorBlock<const internal::remove_cvref_t<Raw>, Size> &;
133template <
int O = 0,
int N = 0>
136 static_assert(N > 0,
"N must be positive");
138 constexpr static int size() {
return N; }
141 int before = O + i, after = i - kZeroAt;
142 return i < kZeroAt ? before : after;
146 constexpr static int kZeroAt = (N - O) % N;
147 static_assert(kZeroAt >= 0,
"Offset must be smaller than size");
154 ABSL_DCHECK(zero_at_ >= 0);
157 constexpr int size()
const {
return n_; }
160 int before = O + i, after = i - zero_at_;
161 return i < zero_at_ ? before : after;
173 : n_(n), offset_(offset), zero_at_((n - offset) % n) {
174 ABSL_DCHECK(zero_at_ >= 0);
177 constexpr int size()
const {
return n_; }
180 int before = offset_ + i, after = i - zero_at_;
181 return i < zero_at_ ? before : after;
192template <
class ML1,
class ML2,
class TransformLike>
194void inplace_transform(ML1 &&m_out,
const TransformLike &xform,
const ML2 &m) {
195 const E::Index ri = m.rows(), ci = m.cols();
196 const E::Index ro = m_out.rows(), co = m_out.cols();
197 ABSL_ASSUME(ri == ro && ci == co);
199 for (E::Index i = 0; i < m.cols(); ++i)
200 m_out.col(i) = xform * m.col(i);
204 template <
bool Allowed>
205 class AllowEigenMallocScoped {
207 AllowEigenMallocScoped(
const AllowEigenMallocScoped &) =
delete;
208 AllowEigenMallocScoped(AllowEigenMallocScoped &&) =
delete;
209 AllowEigenMallocScoped &operator=(
const AllowEigenMallocScoped &) =
delete;
210 AllowEigenMallocScoped &operator=(AllowEigenMallocScoped &&) =
delete;
212#ifdef EIGEN_RUNTIME_NO_MALLOC
213 AllowEigenMallocScoped(): state_(E::internal::is_malloc_allowed()) {
214 E::internal::set_is_malloc_allowed(Allowed);
217 ~AllowEigenMallocScoped() { E::internal::set_is_malloc_allowed(state_); }
222 AllowEigenMallocScoped() =
default;
223 ~AllowEigenMallocScoped() { }
constexpr CyclicIndex(int n, int offset)
Definition eigen_config.h:172
constexpr int operator[](int i) const
Definition eigen_config.h:179
constexpr int size() const
Definition eigen_config.h:177
constexpr int size() const
Definition eigen_config.h:157
constexpr CyclicIndex(int n)
Definition eigen_config.h:153
constexpr int operator[](int i) const
Definition eigen_config.h:159
Cyclic indexer for Eigen types with a given offset.
Definition eigen_config.h:134
static constexpr int size()
Definition eigen_config.h:138
constexpr int operator[](int i) const
Definition eigen_config.h:140