13#ifndef EIGEN_MATRIXSTORAGE_H
14#define EIGEN_MATRIXSTORAGE_H
16#ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
17#define EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(X) \
19 EIGEN_DENSE_STORAGE_CTOR_PLUGIN;
21#define EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(X)
25#include "./InternalHeaderCheck.h"
31#if defined(EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT)
32#define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(Alignment)
34#define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(Alignment) \
35 eigen_assert((is_constant_evaluated() || (std::uintptr_t(array) % Alignment == 0)) && \
36 "this assertion is explained here: " \
37 "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" \
38 " **** READ THIS WEB PAGE !!! ****");
41#if EIGEN_STACK_ALLOCATION_LIMIT
42#define EIGEN_MAKE_STACK_ALLOCATION_ASSERT(X) \
43 EIGEN_STATIC_ASSERT(X <= EIGEN_STACK_ALLOCATION_LIMIT, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG)
45#define EIGEN_MAKE_STACK_ALLOCATION_ASSERT(X)
53template <
typename T,
int Size,
int MatrixOrArrayOptions,
54 int Alignment = (MatrixOrArrayOptions &
DontAlign) ? 0 : compute_default_alignment<T, Size>::value>
56 EIGEN_ALIGN_TO_BOUNDARY(Alignment) T array[Size];
57#if defined(EIGEN_NO_DEBUG) || defined(EIGEN_TESTING_PLAINOBJECT_CTOR)
58 EIGEN_DEVICE_FUNC
constexpr plain_array() =
default;
60 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr plain_array() {
61 EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(Alignment)
62 EIGEN_MAKE_STACK_ALLOCATION_ASSERT(Size *
sizeof(T))
67template <
typename T,
int Size,
int MatrixOrArrayOptions>
68struct plain_array<T, Size, MatrixOrArrayOptions, 0> {
70 EIGEN_ALIGN_TO_BOUNDARY(
alignof(T)) T array[Size];
71#if defined(EIGEN_NO_DEBUG) || defined(EIGEN_TESTING_PLAINOBJECT_CTOR)
72 EIGEN_DEVICE_FUNC
constexpr plain_array() =
default;
74 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr plain_array() { EIGEN_MAKE_STACK_ALLOCATION_ASSERT(Size *
sizeof(T)) }
78template <
typename T,
int Size,
int Options,
int Alignment>
79EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap_plain_array(plain_array<T, Size, Options, Alignment>& a,
80 plain_array<T, Size, Options, Alignment>& b,
81 Index a_size, Index b_size) {
82 Index common_size = numext::mini(a_size, b_size);
83 std::swap_ranges(a.array, a.array + common_size, b.array);
85 smart_copy(a.array + common_size, a.array + a_size, b.array + common_size);
86 else if (b_size > a_size)
87 smart_copy(b.array + common_size, b.array + b_size, a.array + common_size);
90template <
typename T,
int Size,
int Rows,
int Cols,
int Options>
91class DenseStorage_impl {
92 plain_array<T, Size, Options> m_data;
95#ifndef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
96 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
97 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
99 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() {
100 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = Size)
102 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other) {
103 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = Size)
104 smart_copy(other.m_data.array, other.m_data.array + Size, m_data.array);
107 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(Index , Index , Index ) {}
108 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
109 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other) {
110 numext::swap(m_data, other.m_data);
112 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index , Index ) {}
113 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index , Index ) {}
114 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return Rows; }
115 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return Cols; }
116 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return Rows * Cols; }
117 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data.array; }
118 EIGEN_DEVICE_FUNC
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
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
constexpr void conservativeResize(Index , Index rows, Index ) { m_rows = rows; }
147 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index rows, Index ) { m_rows = rows; }
148 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return m_rows; }
149 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return Cols; }
150 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return m_rows * Cols; }
151 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data.array; }
152 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data.array; }
154template <
typename T,
int Size,
int Rows,
int Options>
155class DenseStorage_impl<T, Size, Rows, Dynamic, Options> {
156 plain_array<T, Size, Options> m_data;
160 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
161 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
162 : m_cols(other.m_cols) {
163 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = other.size())
164 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
166 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(Index size, Index , Index cols)
168 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
169 EIGEN_UNUSED_VARIABLE(size);
171 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
172 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
173 m_cols = other.m_cols;
176 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other) {
177 swap_plain_array(m_data, other.m_data, size(), other.size());
178 numext::swap(m_cols, other.m_cols);
180 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index , Index cols) { m_cols = cols; }
181 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index , Index cols) { m_cols = cols; }
182 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return Rows; }
183 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return m_cols; }
184 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return Rows * m_cols; }
185 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data.array; }
186 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data.array; }
188template <
typename T,
int Size,
int Options>
189class DenseStorage_impl<T, Size, Dynamic, Dynamic, Options> {
190 plain_array<T, Size, Options> m_data;
195 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
196 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
197 : m_rows(other.m_rows), m_cols(other.m_cols) {
198 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = other.size())
199 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
201 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(Index size, Index rows, Index cols)
202 : m_rows(rows), m_cols(cols) {
203 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
204 EIGEN_UNUSED_VARIABLE(size);
206 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
207 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
208 m_rows = other.m_rows;
209 m_cols = other.m_cols;
212 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other) {
213 swap_plain_array(m_data, other.m_data, size(), other.size());
214 numext::swap(m_rows, other.m_rows);
215 numext::swap(m_cols, other.m_cols);
217 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index rows, Index cols) {
221 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index rows, Index cols) {
225 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return m_rows; }
226 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return m_cols; }
227 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return m_rows * m_cols; }
228 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data.array; }
229 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data.array; }
232template <
typename T,
int Rows,
int Cols,
int Options>
233class DenseStorage_impl<T, 0, Rows, Cols, Options> {
235 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
236 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
237 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(Index , Index , Index ) {}
238 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
239 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage_impl&) {}
240 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index , Index ) {}
241 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index , Index ) {}
242 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return Rows; }
243 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return Cols; }
244 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return Rows * Cols; }
245 EIGEN_DEVICE_FUNC
constexpr T* data() {
return nullptr; }
246 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return nullptr; }
248template <
typename T,
int Cols,
int Options>
249class DenseStorage_impl<T, 0, Dynamic, Cols, Options> {
253 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
254 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
255 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(Index , Index rows, Index ) : m_rows(rows) {}
256 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
257 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage_impl& other)
noexcept { numext::swap(m_rows, other.m_rows); }
258 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index rows, Index ) { m_rows = rows; }
259 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index rows, Index ) { m_rows = rows; }
260 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return m_rows; }
261 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return Cols; }
262 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return m_rows * Cols; }
263 EIGEN_DEVICE_FUNC
constexpr T* data() {
return nullptr; }
264 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return nullptr; }
266template <
typename T,
int Rows,
int Options>
267class DenseStorage_impl<T, 0, Rows, Dynamic, Options> {
271 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
272 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
273 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(Index , Index , Index cols) : m_cols(cols) {}
274 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
275 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage_impl& other)
noexcept { numext::swap(m_cols, other.m_cols); }
276 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index , Index cols) { m_cols = cols; }
277 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index , Index cols) { m_cols = cols; }
278 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return Rows; }
279 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return m_cols; }
280 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return Rows * m_cols; }
281 EIGEN_DEVICE_FUNC
constexpr T* data() {
return nullptr; }
282 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return nullptr; }
284template <
typename T,
int Options>
285class DenseStorage_impl<T, 0, Dynamic, Dynamic, Options> {
290 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
291 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
292 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(Index , Index rows, Index cols) : m_rows(rows), m_cols(cols) {}
293 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
294 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage_impl& other)
noexcept {
295 numext::swap(m_rows, other.m_rows);
296 numext::swap(m_cols, other.m_cols);
298 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index rows, Index cols) {
302 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index rows, Index cols) {
306 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return m_rows; }
307 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return m_cols; }
308 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return m_rows * m_cols; }
309 EIGEN_DEVICE_FUNC
constexpr T* data() {
return nullptr; }
310 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return nullptr; }
313template <
typename T,
int Rows,
int Cols,
int Options>
314class DenseStorage_impl<T, Dynamic, Rows, Cols, Options> {};
316template <
typename T,
int Cols,
int Options>
317class DenseStorage_impl<T, Dynamic, Dynamic, Cols, Options> {
318 static constexpr bool Align = (Options &
DontAlign) == 0;
323 static constexpr int Size = Dynamic;
324 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
325 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
326 : m_data(conditional_aligned_new_auto<T, Align>(other.size())), m_rows(other.m_rows) {
327 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = other.size())
328 smart_copy(other.m_data, other.m_data + other.size(), m_data);
330 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(Index size, Index rows, Index )
331 : m_data(conditional_aligned_new_auto<T, Align>(size)), m_rows(rows) {
332 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
334 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(DenseStorage_impl&& other) noexcept
335 : m_data(other.m_data), m_rows(other.m_rows) {
336 other.m_data =
nullptr;
339 EIGEN_DEVICE_FUNC ~DenseStorage_impl() { conditional_aligned_delete_auto<T, Align>(m_data, size()); }
340 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
341 resize(other.size(), other.rows(), other.cols());
342 smart_copy(other.m_data, other.m_data + other.size(), m_data);
345 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(DenseStorage_impl&& other)
noexcept {
349 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage_impl& other)
noexcept {
350 numext::swap(m_data, other.m_data);
351 numext::swap(m_rows, other.m_rows);
353 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(Index size, Index rows, Index ) {
354 m_data = conditional_aligned_realloc_new_auto<T, Align>(m_data, size, this->size());
357 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(Index size, Index rows, Index ) {
358 Index oldSize = this->size();
359 if (oldSize != size) {
360 conditional_aligned_delete_auto<T, Align>(m_data, oldSize);
361 m_data = conditional_aligned_new_auto<T, Align>(size);
362 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
366 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return m_rows; }
367 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return Cols; }
368 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return m_rows * Cols; }
369 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data; }
370 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data; }
372template <
typename T,
int Rows,
int Options>
373class DenseStorage_impl<T, Dynamic, Rows, Dynamic, Options> {
374 static constexpr bool Align = (Options &
DontAlign) == 0;
379 static constexpr int Size = Dynamic;
380 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
381 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
382 : m_data(conditional_aligned_new_auto<T, Align>(other.size())), m_cols(other.m_cols) {
383 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = other.size())
384 smart_copy(other.m_data, other.m_data + other.size(), m_data);
386 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(Index size, Index , Index cols)
387 : m_data(conditional_aligned_new_auto<T, Align>(size)), m_cols(cols) {
388 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
390 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(DenseStorage_impl&& other) noexcept
391 : m_data(other.m_data), m_cols(other.m_cols) {
392 other.m_data =
nullptr;
395 EIGEN_DEVICE_FUNC ~DenseStorage_impl() { conditional_aligned_delete_auto<T, Align>(m_data, size()); }
396 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
397 resize(other.size(), other.rows(), other.cols());
398 smart_copy(other.m_data, other.m_data + other.size(), m_data);
401 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(DenseStorage_impl&& other)
noexcept {
405 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage_impl& other)
noexcept {
406 numext::swap(m_data, other.m_data);
407 numext::swap(m_cols, other.m_cols);
409 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(Index size, Index , Index cols) {
410 m_data = conditional_aligned_realloc_new_auto<T, Align>(m_data, size, this->size());
413 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(Index size, Index , Index cols) {
414 Index oldSize = this->size();
415 if (oldSize != size) {
416 conditional_aligned_delete_auto<T, Align>(m_data, oldSize);
417 m_data = conditional_aligned_new_auto<T, Align>(size);
418 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
422 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return Rows; }
423 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return m_cols; }
424 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return Rows * m_cols; }
425 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data; }
426 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data; }
428template <
typename T,
int Options>
429class DenseStorage_impl<T, Dynamic, Dynamic, Dynamic, Options> {
430 static constexpr bool Align = (Options &
DontAlign) == 0;
436 static constexpr int Size = Dynamic;
437 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
438 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
439 : m_data(conditional_aligned_new_auto<T, Align>(other.size())), m_rows(other.m_rows), m_cols(other.m_cols) {
440 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = other.size())
441 smart_copy(other.m_data, other.m_data + other.size(), m_data);
443 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(Index size, Index rows, Index cols)
444 : m_data(conditional_aligned_new_auto<T, Align>(size)), m_rows(rows), m_cols(cols) {
445 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
447 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(DenseStorage_impl&& other) noexcept
448 : m_data(other.m_data), m_rows(other.m_rows), m_cols(other.m_cols) {
449 other.m_data =
nullptr;
453 EIGEN_DEVICE_FUNC ~DenseStorage_impl() { conditional_aligned_delete_auto<T, Align>(m_data, size()); }
454 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
455 resize(other.size(), other.rows(), other.cols());
456 smart_copy(other.m_data, other.m_data + other.size(), m_data);
459 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(DenseStorage_impl&& other)
noexcept {
463 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage_impl& other)
noexcept {
464 numext::swap(m_data, other.m_data);
465 numext::swap(m_rows, other.m_rows);
466 numext::swap(m_cols, other.m_cols);
468 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(Index size, Index rows, Index cols) {
469 m_data = conditional_aligned_realloc_new_auto<T, Align>(m_data, size, this->size());
473 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(Index size, Index rows, Index cols) {
474 Index oldSize = this->size();
475 if (oldSize != size) {
476 conditional_aligned_delete_auto<T, Align>(m_data, oldSize);
477 m_data = conditional_aligned_new_auto<T, Align>(size);
478 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
483 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return m_rows; }
484 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return m_cols; }
485 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return m_rows * m_cols; }
486 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data; }
487 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data; }
489template <
typename T,
int Size,
int Rows,
int Cols>
490struct use_default_move {
491 static constexpr bool DynamicObject = Size == Dynamic;
492 static constexpr bool TrivialObject =
493 (!NumTraits<T>::RequireInitialization) && (Rows >= 0) && (Cols >= 0) && (Size == Rows * Cols);
494 static constexpr bool value = DynamicObject || TrivialObject;
510template <
typename T,
int Size,
int Rows,
int Cols,
int Options,
511 bool Trivial = internal::use_default_move<T, Size, Rows, Cols>::value>
512class DenseStorage :
public internal::DenseStorage_impl<T, Size, Rows, Cols, Options> {
513 using Base = internal::DenseStorage_impl<T, Size, Rows, Cols, Options>;
516 EIGEN_DEVICE_FUNC
constexpr DenseStorage() =
default;
517 EIGEN_DEVICE_FUNC
constexpr DenseStorage(
const DenseStorage&) =
default;
518 EIGEN_DEVICE_FUNC
constexpr DenseStorage(Index size, Index rows, Index cols) : Base(size, rows, cols) {}
519 EIGEN_DEVICE_FUNC
constexpr DenseStorage& operator=(
const DenseStorage&) =
default;
522 EIGEN_DEVICE_FUNC
constexpr DenseStorage(DenseStorage&&) =
default;
523 EIGEN_DEVICE_FUNC
constexpr DenseStorage& operator=(DenseStorage&&) =
default;
525template <
typename T,
int Size,
int Rows,
int Cols,
int Options>
526class DenseStorage<T, Size, Rows, Cols, Options, false>
527 :
public internal::DenseStorage_impl<T, Size, Rows, Cols, Options> {
528 using Base = internal::DenseStorage_impl<T, Size, Rows, Cols, Options>;
531 EIGEN_DEVICE_FUNC
constexpr DenseStorage() =
default;
532 EIGEN_DEVICE_FUNC
constexpr DenseStorage(
const DenseStorage&) =
default;
533 EIGEN_DEVICE_FUNC
constexpr DenseStorage(Index size, Index rows, Index cols) : Base(size, rows, cols) {}
534 EIGEN_DEVICE_FUNC
constexpr DenseStorage& operator=(
const DenseStorage&) =
default;
537 EIGEN_DEVICE_FUNC
constexpr DenseStorage(DenseStorage&& other)
538 : DenseStorage(static_cast<const DenseStorage&>(other)) {}
539 EIGEN_DEVICE_FUNC
constexpr DenseStorage& operator=(DenseStorage&& other) {
@ DontAlign
Definition Constants.h:325