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 if (
this == &other)
return *
this;
139 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
140 m_rows = other.m_rows;
143 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other) {
144 swap_plain_array(m_data, other.m_data, size(), other.size());
145 numext::swap(m_rows, other.m_rows);
147 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index rows, Index ) { m_rows = rows; }
148 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index rows, Index ) { m_rows = rows; }
149 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return m_rows; }
150 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return Cols; }
151 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return m_rows * Cols; }
152 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data.array; }
153 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data.array; }
155template <
typename T,
int Size,
int Rows,
int Options>
156class DenseStorage_impl<T, Size, Rows, Dynamic, Options> {
157 plain_array<T, Size, Options> m_data;
161 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
162 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
163 : m_cols(other.m_cols) {
164 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = other.size())
165 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
167 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(Index size, Index , Index cols)
169 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
170 EIGEN_UNUSED_VARIABLE(size);
172 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
173 if (
this == &other)
return *
this;
174 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
175 m_cols = other.m_cols;
178 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other) {
179 swap_plain_array(m_data, other.m_data, size(), other.size());
180 numext::swap(m_cols, other.m_cols);
182 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index , Index cols) { m_cols = cols; }
183 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index , Index cols) { m_cols = cols; }
184 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return Rows; }
185 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return m_cols; }
186 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return Rows * m_cols; }
187 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data.array; }
188 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data.array; }
190template <
typename T,
int Size,
int Options>
191class DenseStorage_impl<T, Size, Dynamic, Dynamic, Options> {
192 plain_array<T, Size, Options> m_data;
197 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
198 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
199 : m_rows(other.m_rows), m_cols(other.m_cols) {
200 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = other.size())
201 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
203 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(Index size, Index rows, Index cols)
204 : m_rows(rows), m_cols(cols) {
205 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
206 EIGEN_UNUSED_VARIABLE(size);
208 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
209 if (
this == &other)
return *
this;
210 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
211 m_rows = other.m_rows;
212 m_cols = other.m_cols;
215 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other) {
216 swap_plain_array(m_data, other.m_data, size(), other.size());
217 numext::swap(m_rows, other.m_rows);
218 numext::swap(m_cols, other.m_cols);
220 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index rows, Index cols) {
224 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index rows, Index cols) {
228 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return m_rows; }
229 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return m_cols; }
230 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return m_rows * m_cols; }
231 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data.array; }
232 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data.array; }
235template <
typename T,
int Rows,
int Cols,
int Options>
236class DenseStorage_impl<T, 0, Rows, Cols, Options> {
238 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
239 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
240 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(Index , Index , Index ) {}
241 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
242 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage_impl&) {}
243 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index , Index ) {}
244 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index , Index ) {}
245 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return Rows; }
246 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return Cols; }
247 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return Rows * Cols; }
248 EIGEN_DEVICE_FUNC
constexpr T* data() {
return nullptr; }
249 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return nullptr; }
251template <
typename T,
int Cols,
int Options>
252class DenseStorage_impl<T, 0, Dynamic, Cols, Options> {
256 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
257 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
258 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(Index , Index rows, Index ) : m_rows(rows) {}
259 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
260 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage_impl& other)
noexcept { numext::swap(m_rows, other.m_rows); }
261 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index rows, Index ) { m_rows = rows; }
262 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index rows, Index ) { m_rows = rows; }
263 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return m_rows; }
264 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return Cols; }
265 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return m_rows * Cols; }
266 EIGEN_DEVICE_FUNC
constexpr T* data() {
return nullptr; }
267 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return nullptr; }
269template <
typename T,
int Rows,
int Options>
270class DenseStorage_impl<T, 0, Rows, Dynamic, Options> {
274 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
275 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
276 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(Index , Index , Index cols) : m_cols(cols) {}
277 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
278 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage_impl& other)
noexcept { numext::swap(m_cols, other.m_cols); }
279 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index , Index cols) { m_cols = cols; }
280 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index , Index cols) { m_cols = cols; }
281 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return Rows; }
282 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return m_cols; }
283 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return Rows * m_cols; }
284 EIGEN_DEVICE_FUNC
constexpr T* data() {
return nullptr; }
285 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return nullptr; }
287template <
typename T,
int Options>
288class DenseStorage_impl<T, 0, Dynamic, Dynamic, Options> {
293 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
294 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
295 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(Index , Index rows, Index cols) : m_rows(rows), m_cols(cols) {}
296 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
297 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage_impl& other)
noexcept {
298 numext::swap(m_rows, other.m_rows);
299 numext::swap(m_cols, other.m_cols);
301 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index rows, Index cols) {
305 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index rows, Index cols) {
309 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return m_rows; }
310 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return m_cols; }
311 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return m_rows * m_cols; }
312 EIGEN_DEVICE_FUNC
constexpr T* data() {
return nullptr; }
313 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return nullptr; }
316template <
typename T,
int Rows,
int Cols,
int Options>
317class DenseStorage_impl<T, Dynamic, Rows, Cols, Options> {};
319template <
typename T,
int Cols,
int Options>
320class DenseStorage_impl<T, Dynamic, Dynamic, Cols, Options> {
321 static constexpr bool Align = (Options &
DontAlign) == 0;
326 static constexpr int Size = Dynamic;
327 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
328 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
329 : m_data(conditional_aligned_new_auto<T, Align>(other.size())), m_rows(other.m_rows) {
330 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = other.size())
331 smart_copy(other.m_data, other.m_data + other.size(), m_data);
333 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(Index size, Index rows, Index )
334 : m_data(conditional_aligned_new_auto<T, Align>(size)), m_rows(rows) {
335 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
337 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(DenseStorage_impl&& other) noexcept
338 : m_data(other.m_data), m_rows(other.m_rows) {
339 other.m_data =
nullptr;
342 EIGEN_DEVICE_FUNC ~DenseStorage_impl() { conditional_aligned_delete_auto<T, Align>(m_data, size()); }
343 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
344 if (
this == &other)
return *
this;
345 resize(other.size(), other.rows(), other.cols());
346 smart_copy(other.m_data, other.m_data + other.size(), m_data);
349 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(DenseStorage_impl&& other)
noexcept {
353 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage_impl& other)
noexcept {
354 numext::swap(m_data, other.m_data);
355 numext::swap(m_rows, other.m_rows);
357 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(Index size, Index rows, Index ) {
358 m_data = conditional_aligned_realloc_new_auto<T, Align>(m_data, size, this->size());
361 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(Index size, Index rows, Index ) {
362 Index oldSize = this->size();
363 if (oldSize != size) {
364 conditional_aligned_delete_auto<T, Align>(m_data, oldSize);
368 m_data = conditional_aligned_new_auto<T, Align>(size);
369 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
373 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return m_rows; }
374 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return Cols; }
375 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return m_rows * Cols; }
376 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data; }
377 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data; }
379template <
typename T,
int Rows,
int Options>
380class DenseStorage_impl<T, Dynamic, Rows, Dynamic, Options> {
381 static constexpr bool Align = (Options &
DontAlign) == 0;
386 static constexpr int Size = Dynamic;
387 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
388 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
389 : m_data(conditional_aligned_new_auto<T, Align>(other.size())), m_cols(other.m_cols) {
390 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = other.size())
391 smart_copy(other.m_data, other.m_data + other.size(), m_data);
393 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(Index size, Index , Index cols)
394 : m_data(conditional_aligned_new_auto<T, Align>(size)), m_cols(cols) {
395 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
397 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(DenseStorage_impl&& other) noexcept
398 : m_data(other.m_data), m_cols(other.m_cols) {
399 other.m_data =
nullptr;
402 EIGEN_DEVICE_FUNC ~DenseStorage_impl() { conditional_aligned_delete_auto<T, Align>(m_data, size()); }
403 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
404 if (
this == &other)
return *
this;
405 resize(other.size(), other.rows(), other.cols());
406 smart_copy(other.m_data, other.m_data + other.size(), m_data);
409 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(DenseStorage_impl&& other)
noexcept {
413 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage_impl& other)
noexcept {
414 numext::swap(m_data, other.m_data);
415 numext::swap(m_cols, other.m_cols);
417 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(Index size, Index , Index cols) {
418 m_data = conditional_aligned_realloc_new_auto<T, Align>(m_data, size, this->size());
421 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(Index size, Index , Index cols) {
422 Index oldSize = this->size();
423 if (oldSize != size) {
424 conditional_aligned_delete_auto<T, Align>(m_data, oldSize);
428 m_data = conditional_aligned_new_auto<T, Align>(size);
429 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
433 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return Rows; }
434 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return m_cols; }
435 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return Rows * m_cols; }
436 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data; }
437 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data; }
439template <
typename T,
int Options>
440class DenseStorage_impl<T, Dynamic, Dynamic, Dynamic, Options> {
441 static constexpr bool Align = (Options &
DontAlign) == 0;
447 static constexpr int Size = Dynamic;
448 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
449 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
450 : m_data(conditional_aligned_new_auto<T, Align>(other.size())), m_rows(other.m_rows), m_cols(other.m_cols) {
451 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = other.size())
452 smart_copy(other.m_data, other.m_data + other.size(), m_data);
454 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(Index size, Index rows, Index cols)
455 : m_data(conditional_aligned_new_auto<T, Align>(size)), m_rows(rows), m_cols(cols) {
456 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
458 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(DenseStorage_impl&& other) noexcept
459 : m_data(other.m_data), m_rows(other.m_rows), m_cols(other.m_cols) {
460 other.m_data =
nullptr;
464 EIGEN_DEVICE_FUNC ~DenseStorage_impl() { conditional_aligned_delete_auto<T, Align>(m_data, size()); }
465 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
466 if (
this == &other)
return *
this;
467 resize(other.size(), other.rows(), other.cols());
468 smart_copy(other.m_data, other.m_data + other.size(), m_data);
471 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(DenseStorage_impl&& other)
noexcept {
475 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage_impl& other)
noexcept {
476 numext::swap(m_data, other.m_data);
477 numext::swap(m_rows, other.m_rows);
478 numext::swap(m_cols, other.m_cols);
480 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(Index size, Index rows, Index cols) {
481 m_data = conditional_aligned_realloc_new_auto<T, Align>(m_data, size, this->size());
485 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(Index size, Index rows, Index cols) {
486 Index oldSize = this->size();
487 if (oldSize != size) {
488 conditional_aligned_delete_auto<T, Align>(m_data, oldSize);
493 m_data = conditional_aligned_new_auto<T, Align>(size);
494 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
499 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return m_rows; }
500 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return m_cols; }
501 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return m_rows * m_cols; }
502 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data; }
503 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data; }
505template <
typename T,
int Size,
int Rows,
int Cols>
506struct use_default_move {
507 static constexpr bool DynamicObject = Size == Dynamic;
508 static constexpr bool TrivialObject =
509 (!NumTraits<T>::RequireInitialization) && (Rows >= 0) && (Cols >= 0) && (Size == Rows * Cols);
510 static constexpr bool value = DynamicObject || TrivialObject;
526template <
typename T,
int Size,
int Rows,
int Cols,
int Options,
527 bool Trivial = internal::use_default_move<T, Size, Rows, Cols>::value>
528class DenseStorage :
public internal::DenseStorage_impl<T, Size, Rows, Cols, Options> {
529 using Base = internal::DenseStorage_impl<T, Size, Rows, Cols, Options>;
532 EIGEN_DEVICE_FUNC
constexpr DenseStorage() =
default;
533 EIGEN_DEVICE_FUNC
constexpr DenseStorage(
const DenseStorage&) =
default;
534 EIGEN_DEVICE_FUNC
constexpr DenseStorage(Index size, Index rows, Index cols) : Base(size, rows, cols) {}
535 EIGEN_DEVICE_FUNC
constexpr DenseStorage& operator=(
const DenseStorage&) =
default;
538 EIGEN_DEVICE_FUNC
constexpr DenseStorage(DenseStorage&&) =
default;
539 EIGEN_DEVICE_FUNC
constexpr DenseStorage& operator=(DenseStorage&&) =
default;
541template <
typename T,
int Size,
int Rows,
int Cols,
int Options>
542class DenseStorage<T, Size, Rows, Cols, Options, false>
543 :
public internal::DenseStorage_impl<T, Size, Rows, Cols, Options> {
544 using Base = internal::DenseStorage_impl<T, Size, Rows, Cols, Options>;
547 EIGEN_DEVICE_FUNC
constexpr DenseStorage() =
default;
548 EIGEN_DEVICE_FUNC
constexpr DenseStorage(
const DenseStorage&) =
default;
549 EIGEN_DEVICE_FUNC
constexpr DenseStorage(Index size, Index rows, Index cols) : Base(size, rows, cols) {}
550 EIGEN_DEVICE_FUNC
constexpr DenseStorage& operator=(
const DenseStorage&) =
default;
553 EIGEN_DEVICE_FUNC
constexpr DenseStorage(DenseStorage&& other)
554 : DenseStorage(static_cast<const DenseStorage&>(other)) {}
555 EIGEN_DEVICE_FUNC
constexpr DenseStorage& operator=(DenseStorage&& other) {
@ DontAlign
Definition Constants.h:325