12#ifndef EIGEN_MATRIXSTORAGE_H
13#define EIGEN_MATRIXSTORAGE_H
15#ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
16#define EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(X) \
18 EIGEN_DENSE_STORAGE_CTOR_PLUGIN;
20#define EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(X)
24#include "./InternalHeaderCheck.h"
30#if defined(EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT)
31#define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(Alignment)
33#define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(Alignment) \
34 eigen_assert((is_constant_evaluated() || (std::uintptr_t(array) % Alignment == 0)) && \
35 "this assertion is explained here: " \
36 "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" \
37 " **** READ THIS WEB PAGE !!! ****");
40#if EIGEN_STACK_ALLOCATION_LIMIT
41#define EIGEN_MAKE_STACK_ALLOCATION_ASSERT(X) \
42 EIGEN_STATIC_ASSERT(X <= EIGEN_STACK_ALLOCATION_LIMIT, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG)
44#define EIGEN_MAKE_STACK_ALLOCATION_ASSERT(X)
52template <
typename T,
int Size,
int MatrixOrArrayOptions,
53 int Alignment = (MatrixOrArrayOptions &
DontAlign) ? 0 : compute_default_alignment<T, Size>::value>
55 EIGEN_ALIGN_TO_BOUNDARY(Alignment) T array[Size];
56#if defined(EIGEN_NO_DEBUG) || defined(EIGEN_TESTING_PLAINOBJECT_CTOR)
57 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr plain_array() =
default;
59 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr plain_array() {
60 EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(Alignment)
61 EIGEN_MAKE_STACK_ALLOCATION_ASSERT(Size *
sizeof(T))
66template <
typename T,
int Size,
int MatrixOrArrayOptions>
67struct plain_array<T, Size, MatrixOrArrayOptions, 0> {
69 EIGEN_ALIGN_TO_BOUNDARY(
alignof(T)) T array[Size];
70#if defined(EIGEN_NO_DEBUG) || defined(EIGEN_TESTING_PLAINOBJECT_CTOR)
71 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr plain_array() =
default;
73 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr plain_array() { EIGEN_MAKE_STACK_ALLOCATION_ASSERT(Size *
sizeof(T)) }
77template <
typename T,
int Size,
int Options,
int Alignment>
78EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap_plain_array(plain_array<T, Size, Options, Alignment>& a,
79 plain_array<T, Size, Options, Alignment>& b,
81 Index common_size = numext::mini(a_size, b_size);
82 std::swap_ranges(a.array, a.array + common_size, b.array);
84 smart_copy(a.array + common_size, a.array + a_size, b.array + common_size);
85 else if (b_size > a_size)
86 smart_copy(b.array + common_size, b.array + b_size, a.array + common_size);
89template <
typename T,
int Size,
int Rows,
int Cols,
int Options>
90class DenseStorage_impl {
91 plain_array<T, Size, Options> m_data;
94#ifndef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
95 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
96 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
98 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() {
99 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(
Index size = Size)
101 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other) {
102 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(
Index size = Size)
103 smart_copy(other.m_data.array, other.m_data.array + Size, m_data.array);
106 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
Index ,
Index ,
Index ) {}
107 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
108 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other) {
109 numext::swap(m_data, other.m_data);
111 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index ,
Index ,
113 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index ,
Index ,
Index ) {}
114 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return Rows; }
115 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return Cols; }
116 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return Rows * Cols; }
117 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return m_data.array; }
118 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return m_data.array; }
120template <
typename T,
int Size,
int Cols,
int Options>
121class DenseStorage_impl<T, Size, Dynamic, Cols, Options> {
122 plain_array<T, Size, Options> m_data;
126 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
127 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
128 : m_rows(other.m_rows) {
129 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(
Index size = other.size())
130 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
132 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(
Index size,
Index rows,
Index )
134 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
135 EIGEN_UNUSED_VARIABLE(size)
137 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
138 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
139 m_rows = other.m_rows;
142 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other) {
143 swap_plain_array(m_data, other.m_data, size(), other.size());
144 numext::swap(m_rows, other.m_rows);
146 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index ,
Index rows,
Index ) {
149 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index ,
Index rows,
Index ) {
152 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return m_rows; }
153 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return Cols; }
154 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return m_rows * Cols; }
155 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return m_data.array; }
156 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return m_data.array; }
158template <
typename T,
int Size,
int Rows,
int Options>
159class DenseStorage_impl<T, Size, Rows, Dynamic, Options> {
160 plain_array<T, Size, Options> m_data;
164 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
165 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
166 : m_cols(other.m_cols) {
167 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(
Index size = other.size())
168 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
170 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(
Index size,
Index ,
Index cols)
172 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
173 EIGEN_UNUSED_VARIABLE(size)
175 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
176 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
177 m_cols = other.m_cols;
180 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other) {
181 swap_plain_array(m_data, other.m_data, size(), other.size());
182 numext::swap(m_cols, other.m_cols);
184 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index ,
Index ,
Index cols) {
187 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index ,
Index ,
Index cols) {
190 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return Rows; }
191 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return m_cols; }
192 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return Rows * m_cols; }
193 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return m_data.array; }
194 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return m_data.array; }
196template <
typename T,
int Size,
int Options>
197class DenseStorage_impl<T, Size, Dynamic, Dynamic, Options> {
198 plain_array<T, Size, Options> m_data;
203 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
204 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
205 : m_rows(other.m_rows), m_cols(other.m_cols) {
206 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(
Index size = other.size())
207 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
209 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(
Index size,
Index rows,
Index cols)
210 : m_rows(rows), m_cols(cols) {
211 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
212 EIGEN_UNUSED_VARIABLE(size)
214 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
215 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
216 m_rows = other.m_rows;
217 m_cols = other.m_cols;
220 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other) {
221 swap_plain_array(m_data, other.m_data, size(), other.size());
222 numext::swap(m_rows, other.m_rows);
223 numext::swap(m_cols, other.m_cols);
225 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index ,
Index rows,
Index cols) {
229 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index ,
Index rows,
Index cols) {
233 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return m_rows; }
234 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return m_cols; }
235 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return m_rows * m_cols; }
236 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return m_data.array; }
237 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return m_data.array; }
240template <
typename T,
int Rows,
int Cols,
int Options>
241class DenseStorage_impl<T, 0, Rows, Cols, Options> {
243 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
244 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
245 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
Index ,
Index ,
Index ) {}
246 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
247 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl&) {}
248 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index ,
Index ,
250 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index ,
Index ,
Index ) {}
251 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return Rows; }
252 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return Cols; }
253 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return Rows * Cols; }
254 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return nullptr; }
255 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return nullptr; }
257template <
typename T,
int Cols,
int Options>
258class DenseStorage_impl<T, 0, Dynamic, Cols, Options> {
262 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
263 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
264 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
Index ,
Index rows,
Index )
266 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
267 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other)
noexcept {
268 numext::swap(m_rows, other.m_rows);
270 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index ,
Index rows,
Index ) {
273 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index ,
Index rows,
Index ) {
276 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return m_rows; }
277 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return Cols; }
278 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return m_rows * Cols; }
279 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return nullptr; }
280 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return nullptr; }
282template <
typename T,
int Rows,
int Options>
283class DenseStorage_impl<T, 0, Rows, Dynamic, Options> {
287 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
288 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
289 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
Index ,
Index ,
Index cols)
291 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
292 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other)
noexcept {
293 numext::swap(m_cols, other.m_cols);
295 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index ,
Index ,
Index cols) {
298 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index ,
Index ,
Index cols) {
301 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return Rows; }
302 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return m_cols; }
303 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return Rows * m_cols; }
304 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return nullptr; }
305 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return nullptr; }
307template <
typename T,
int Options>
308class DenseStorage_impl<T, 0, Dynamic, Dynamic, Options> {
313 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
314 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
315 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
Index ,
Index rows,
Index cols)
316 : m_rows(rows), m_cols(cols) {}
317 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
318 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other)
noexcept {
319 numext::swap(m_rows, other.m_rows);
320 numext::swap(m_cols, other.m_cols);
322 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index ,
Index rows,
Index cols) {
326 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index ,
Index rows,
Index cols) {
330 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return m_rows; }
331 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return m_cols; }
332 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return m_rows * m_cols; }
333 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return nullptr; }
334 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return nullptr; }
337template <
typename T,
int Rows,
int Cols,
int Options>
338class DenseStorage_impl<T, Dynamic, Rows, Cols, Options> {};
340template <
typename T,
int Cols,
int Options>
341class DenseStorage_impl<T, Dynamic, Dynamic, Cols, Options> {
342 static constexpr bool Align = (Options &
DontAlign) == 0;
347 static constexpr int Size =
Dynamic;
348 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
349 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
350 : m_data(conditional_aligned_new_auto<T, Align>(other.size())), m_rows(other.m_rows) {
351 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(
Index size = other.size())
352 smart_copy(other.m_data, other.m_data + other.size(), m_data);
354 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(
Index size,
Index rows,
Index )
355 : m_data(conditional_aligned_new_auto<T, Align>(size)), m_rows(rows) {
356 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
358 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(DenseStorage_impl&& other) noexcept
359 : m_data(other.m_data), m_rows(other.m_rows) {
360 other.m_data =
nullptr;
363 EIGEN_DEVICE_FUNC ~DenseStorage_impl() { conditional_aligned_delete_auto<T, Align>(m_data, size()); }
364 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
365 resize(other.size(), other.rows(), other.cols());
366 smart_copy(other.m_data, other.m_data + other.size(), m_data);
369 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(DenseStorage_impl&& other)
noexcept {
373 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other)
noexcept {
374 numext::swap(m_data, other.m_data);
375 numext::swap(m_rows, other.m_rows);
377 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index size,
Index rows,
Index ) {
378 m_data = conditional_aligned_realloc_new_auto<T, Align>(m_data, size, this->size());
381 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index size,
Index rows,
Index ) {
382 Index oldSize = this->size();
383 if (oldSize != size) {
384 conditional_aligned_delete_auto<T, Align>(m_data, oldSize);
385 m_data = conditional_aligned_new_auto<T, Align>(size);
386 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
390 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return m_rows; }
391 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return Cols; }
392 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return m_rows * Cols; }
393 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return m_data; }
394 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return m_data; }
396template <
typename T,
int Rows,
int Options>
397class DenseStorage_impl<T, Dynamic, Rows, Dynamic, Options> {
398 static constexpr bool Align = (Options &
DontAlign) == 0;
403 static constexpr int Size =
Dynamic;
404 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
405 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
406 : m_data(conditional_aligned_new_auto<T, Align>(other.size())), m_cols(other.m_cols) {
407 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(
Index size = other.size())
408 smart_copy(other.m_data, other.m_data + other.size(), m_data);
410 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(
Index size,
Index ,
Index cols)
411 : m_data(conditional_aligned_new_auto<T, Align>(size)), m_cols(cols) {
412 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
414 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(DenseStorage_impl&& other) noexcept
415 : m_data(other.m_data), m_cols(other.m_cols) {
416 other.m_data =
nullptr;
419 EIGEN_DEVICE_FUNC ~DenseStorage_impl() { conditional_aligned_delete_auto<T, Align>(m_data, size()); }
420 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
421 resize(other.size(), other.rows(), other.cols());
422 smart_copy(other.m_data, other.m_data + other.size(), m_data);
425 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(DenseStorage_impl&& other)
noexcept {
429 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other)
noexcept {
430 numext::swap(m_data, other.m_data);
431 numext::swap(m_cols, other.m_cols);
433 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index size,
Index ,
Index cols) {
434 m_data = conditional_aligned_realloc_new_auto<T, Align>(m_data, size, this->size());
437 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index size,
Index ,
Index cols) {
438 Index oldSize = this->size();
439 if (oldSize != size) {
440 conditional_aligned_delete_auto<T, Align>(m_data, oldSize);
441 m_data = conditional_aligned_new_auto<T, Align>(size);
442 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
446 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return Rows; }
447 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return m_cols; }
448 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return Rows * m_cols; }
449 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return m_data; }
450 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return m_data; }
452template <
typename T,
int Options>
453class DenseStorage_impl<T, Dynamic, Dynamic, Dynamic, Options> {
454 static constexpr bool Align = (Options &
DontAlign) == 0;
460 static constexpr int Size =
Dynamic;
461 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
462 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
463 : m_data(conditional_aligned_new_auto<T, Align>(other.size())), m_rows(other.m_rows), m_cols(other.m_cols) {
464 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(
Index size = other.size())
465 smart_copy(other.m_data, other.m_data + other.size(), m_data);
467 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(
Index size,
Index rows,
Index cols)
468 : m_data(conditional_aligned_new_auto<T, Align>(size)), m_rows(rows), m_cols(cols) {
469 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
471 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(DenseStorage_impl&& other) noexcept
472 : m_data(other.m_data), m_rows(other.m_rows), m_cols(other.m_cols) {
473 other.m_data =
nullptr;
477 EIGEN_DEVICE_FUNC ~DenseStorage_impl() { conditional_aligned_delete_auto<T, Align>(m_data, size()); }
478 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
479 resize(other.size(), other.rows(), other.cols());
480 smart_copy(other.m_data, other.m_data + other.size(), m_data);
483 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(DenseStorage_impl&& other)
noexcept {
487 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other)
noexcept {
488 numext::swap(m_data, other.m_data);
489 numext::swap(m_rows, other.m_rows);
490 numext::swap(m_cols, other.m_cols);
492 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index size,
Index rows,
Index cols) {
493 m_data = conditional_aligned_realloc_new_auto<T, Align>(m_data, size, this->size());
497 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index size,
Index rows,
Index cols) {
498 Index oldSize = this->size();
499 if (oldSize != size) {
500 conditional_aligned_delete_auto<T, Align>(m_data, oldSize);
501 m_data = conditional_aligned_new_auto<T, Align>(size);
502 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
507 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return m_rows; }
508 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return m_cols; }
509 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return m_rows * m_cols; }
510 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return m_data; }
511 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return m_data; }
513template <
typename T,
int Size,
int Rows,
int Cols>
514struct use_default_move {
515 static constexpr bool DynamicObject = Size ==
Dynamic;
516 static constexpr bool TrivialObject =
517 (!NumTraits<T>::RequireInitialization) && (Rows >= 0) && (Cols >= 0) && (Size == Rows * Cols);
518 static constexpr bool value = DynamicObject || TrivialObject;
534template <
typename T,
int Size,
int Rows,
int Cols,
int Options,
535 bool Trivial = internal::use_default_move<T, Size, Rows, Cols>::value>
536class DenseStorage :
public internal::DenseStorage_impl<T, Size, Rows, Cols, Options> {
537 using Base = internal::DenseStorage_impl<T, Size, Rows, Cols, Options>;
540 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage() =
default;
541 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage(
const DenseStorage&) =
default;
542 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage(
Index size,
Index rows,
Index cols)
543 : Base(size, rows, cols) {}
544 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage& operator=(
const DenseStorage&) =
default;
547 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage(DenseStorage&&) =
default;
548 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage& operator=(DenseStorage&&) =
default;
550template <
typename T,
int Size,
int Rows,
int Cols,
int Options>
551class DenseStorage<T, Size, Rows, Cols, Options, false>
552 :
public internal::DenseStorage_impl<T, Size, Rows, Cols, Options> {
553 using Base = internal::DenseStorage_impl<T, Size, Rows, Cols, Options>;
556 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage() =
default;
557 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage(
const DenseStorage&) =
default;
558 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage(
Index size,
Index rows,
Index cols)
559 : Base(size, rows, cols) {}
560 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage& operator=(
const DenseStorage&) =
default;
563 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage(DenseStorage&& other)
564 : DenseStorage(static_cast<const DenseStorage&>(other)) {}
565 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage& operator=(DenseStorage&& other) {
@ DontAlign
Definition Constants.h:324
Namespace containing all symbols from the Eigen library.
Definition B01_Experimental.dox:1
std::enable_if_t< std::is_base_of< DenseBase< std::decay_t< DerivedA > >, std::decay_t< DerivedA > >::value &&std::is_base_of< DenseBase< std::decay_t< DerivedB > >, std::decay_t< DerivedB > >::value, void > swap(DerivedA &&a, DerivedB &&b)
Definition DenseBase.h:667
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:82
const int Dynamic
Definition Constants.h:25