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"
30struct constructor_without_unaligned_array_assert {};
32template <
typename T,
int Size>
33EIGEN_DEVICE_FUNC
constexpr void check_static_allocation_size() {
35#if EIGEN_STACK_ALLOCATION_LIMIT
36 EIGEN_STATIC_ASSERT(Size *
sizeof(T) <= EIGEN_STACK_ALLOCATION_LIMIT, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG);
44template <
typename T,
int Size,
int MatrixOrArrayOptions,
45 int Alignment = (MatrixOrArrayOptions &
DontAlign) ? 0 : compute_default_alignment<T, Size>::value>
49 EIGEN_DEVICE_FUNC
constexpr plain_array() { check_static_allocation_size<T, Size>(); }
51 EIGEN_DEVICE_FUNC
constexpr plain_array(constructor_without_unaligned_array_assert) {
52 check_static_allocation_size<T, Size>();
56#if defined(EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT)
57#define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask)
59#define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) \
60 eigen_assert((internal::is_constant_evaluated() || (std::uintptr_t(array) & (sizemask)) == 0) && \
61 "this assertion is explained here: " \
62 "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" \
63 " **** READ THIS WEB PAGE !!! ****");
66template <
typename T,
int Size,
int MatrixOrArrayOptions>
67struct plain_array<T, Size, MatrixOrArrayOptions, 8> {
68 EIGEN_ALIGN_TO_BOUNDARY(8) T array[Size];
70 EIGEN_DEVICE_FUNC constexpr plain_array() {
71 EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(7);
72 check_static_allocation_size<T, Size>();
75 EIGEN_DEVICE_FUNC
constexpr plain_array(constructor_without_unaligned_array_assert) {
76 check_static_allocation_size<T, Size>();
80template <
typename T,
int Size,
int MatrixOrArrayOptions>
81struct plain_array<T, Size, MatrixOrArrayOptions, 16> {
82 EIGEN_ALIGN_TO_BOUNDARY(16) T array[Size];
84 EIGEN_DEVICE_FUNC constexpr plain_array() {
85 EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(15);
86 check_static_allocation_size<T, Size>();
89 EIGEN_DEVICE_FUNC
constexpr plain_array(constructor_without_unaligned_array_assert) {
90 check_static_allocation_size<T, Size>();
94template <
typename T,
int Size,
int MatrixOrArrayOptions>
95struct plain_array<T, Size, MatrixOrArrayOptions, 32> {
96 EIGEN_ALIGN_TO_BOUNDARY(32) T array[Size];
98 EIGEN_DEVICE_FUNC constexpr plain_array() {
99 EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(31);
100 check_static_allocation_size<T, Size>();
103 EIGEN_DEVICE_FUNC
constexpr plain_array(constructor_without_unaligned_array_assert) {
104 check_static_allocation_size<T, Size>();
108template <
typename T,
int Size,
int MatrixOrArrayOptions>
109struct plain_array<T, Size, MatrixOrArrayOptions, 64> {
110 EIGEN_ALIGN_TO_BOUNDARY(64) T array[Size];
112 EIGEN_DEVICE_FUNC constexpr plain_array() {
113 EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(63);
114 check_static_allocation_size<T, Size>();
117 EIGEN_DEVICE_FUNC
constexpr plain_array(constructor_without_unaligned_array_assert) {
118 check_static_allocation_size<T, Size>();
122template <
typename T,
int MatrixOrArrayOptions,
int Alignment>
123struct plain_array<T, 0, MatrixOrArrayOptions, Alignment> {
125 EIGEN_DEVICE_FUNC
constexpr plain_array() {}
126 EIGEN_DEVICE_FUNC
constexpr plain_array(constructor_without_unaligned_array_assert) {}
129struct plain_array_helper {
130 template <
typename T,
int Size,
int MatrixOrArrayOptions,
int Alignment>
131 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
static void copy(
132 const plain_array<T, Size, MatrixOrArrayOptions, Alignment>& src,
const Eigen::Index size,
133 plain_array<T, Size, MatrixOrArrayOptions, Alignment>& dst) {
134 smart_copy(src.array, src.array + size, dst.array);
137 template <
typename T,
int Size,
int MatrixOrArrayOptions,
int Alignment>
138 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
static void swap(plain_array<T, Size, MatrixOrArrayOptions, Alignment>& a,
140 plain_array<T, Size, MatrixOrArrayOptions, Alignment>& b,
142 if (a_size < b_size) {
143 std::swap_ranges(b.array, b.array + a_size, a.array);
144 smart_move(b.array + a_size, b.array + b_size, a.array + a_size);
145 }
else if (a_size > b_size) {
146 std::swap_ranges(a.array, a.array + b_size, b.array);
147 smart_move(a.array + b_size, a.array + a_size, b.array + b_size);
149 std::swap_ranges(a.array, a.array + a_size, b.array);
168template <
typename T,
int Size,
int Rows_,
int Cols_,
int Options_>
172template <
typename T,
int Size,
int Rows_,
int Cols_,
int Options_>
174 internal::plain_array<T, Size, Options_> m_data;
177 constexpr EIGEN_DEVICE_FUNC DenseStorage(){EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(
179 Size)} EIGEN_DEVICE_FUNC
explicit constexpr DenseStorage(internal::constructor_without_unaligned_array_assert)
180 : m_data(internal::constructor_without_unaligned_array_assert()) {}
181#if defined(EIGEN_DENSE_STORAGE_CTOR_PLUGIN)
182 EIGEN_DEVICE_FUNC
constexpr DenseStorage(
const DenseStorage& other)
183 : m_data(other.m_data){EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = Size)}
185 EIGEN_DEVICE_FUNC
constexpr DenseStorage(
const DenseStorage&) =
default;
187 EIGEN_DEVICE_FUNC
constexpr DenseStorage
189 operator=(
const DenseStorage&) =
default;
190 EIGEN_DEVICE_FUNC
constexpr DenseStorage(DenseStorage&&) =
default;
191 EIGEN_DEVICE_FUNC
constexpr DenseStorage& operator=(DenseStorage&&) =
default;
192 EIGEN_DEVICE_FUNC
constexpr DenseStorage(Index size, Index rows, Index cols) {
193 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
194 eigen_internal_assert(size == rows * cols && rows == Rows_ && cols == Cols_);
195 EIGEN_UNUSED_VARIABLE(size);
196 EIGEN_UNUSED_VARIABLE(rows);
197 EIGEN_UNUSED_VARIABLE(cols);
199 EIGEN_DEVICE_FUNC
void swap(DenseStorage& other) { numext::swap(m_data, other.m_data); }
200 EIGEN_DEVICE_FUNC
static constexpr Index rows(
void) EIGEN_NOEXCEPT {
return Rows_; }
201 EIGEN_DEVICE_FUNC
static constexpr Index cols(
void) EIGEN_NOEXCEPT {
return Cols_; }
202 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index, Index, Index) {}
203 EIGEN_DEVICE_FUNC
constexpr void resize(Index, Index, Index) {}
204 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data.array; }
205 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data.array; }
209template <
typename T,
int Rows_,
int Cols_,
int Options_>
210class DenseStorage<T, 0, Rows_, Cols_, Options_> {
212 static_assert(Rows_ * Cols_ == 0,
"The fixed number of rows times columns must equal the storage size.");
213 EIGEN_DEVICE_FUNC
constexpr DenseStorage() {}
214 EIGEN_DEVICE_FUNC
explicit constexpr DenseStorage(internal::constructor_without_unaligned_array_assert) {}
215 EIGEN_DEVICE_FUNC
constexpr DenseStorage(
const DenseStorage&) {}
216 EIGEN_DEVICE_FUNC
constexpr DenseStorage& operator=(
const DenseStorage&) {
return *
this; }
217 EIGEN_DEVICE_FUNC
constexpr DenseStorage(Index, Index, Index) {}
218 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage&) {}
219 EIGEN_DEVICE_FUNC
static constexpr Index rows(
void) EIGEN_NOEXCEPT {
return Rows_; }
220 EIGEN_DEVICE_FUNC
static constexpr Index cols(
void) EIGEN_NOEXCEPT {
return Cols_; }
221 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index, Index, Index) {}
222 EIGEN_DEVICE_FUNC
constexpr void resize(Index, Index, Index) {}
223 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return 0; }
224 EIGEN_DEVICE_FUNC
constexpr T* data() {
return 0; }
228template <
typename T,
int Options_>
229class DenseStorage<T, 0, Dynamic, Dynamic, Options_> {
234 EIGEN_DEVICE_FUNC DenseStorage() : m_rows(0), m_cols(0) {}
235 EIGEN_DEVICE_FUNC
explicit DenseStorage(internal::constructor_without_unaligned_array_assert) : DenseStorage() {}
236 EIGEN_DEVICE_FUNC DenseStorage(
const DenseStorage& other) : m_rows(other.m_rows), m_cols(other.m_cols) {}
237 EIGEN_DEVICE_FUNC DenseStorage& operator=(
const DenseStorage& other) {
238 m_rows = other.m_rows;
239 m_cols = other.m_cols;
242 EIGEN_DEVICE_FUNC DenseStorage(Index, Index rows, Index cols) : m_rows(rows), m_cols(cols) {
243 eigen_assert(m_rows * m_cols == 0 &&
"The number of rows times columns must equal the storage size.");
245 EIGEN_DEVICE_FUNC
void swap(DenseStorage& other) {
246 numext::swap(m_rows, other.m_rows);
247 numext::swap(m_cols, other.m_cols);
249 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT {
return m_rows; }
250 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT {
return m_cols; }
251 EIGEN_DEVICE_FUNC
void conservativeResize(Index, Index rows, Index cols) {
254 eigen_assert(m_rows * m_cols == 0 &&
"The number of rows times columns must equal the storage size.");
256 EIGEN_DEVICE_FUNC
void resize(Index, Index rows, Index cols) {
259 eigen_assert(m_rows * m_cols == 0 &&
"The number of rows times columns must equal the storage size.");
261 EIGEN_DEVICE_FUNC
const T* data()
const {
return nullptr; }
262 EIGEN_DEVICE_FUNC T* data() {
return nullptr; }
265template <
typename T,
int Rows_,
int Options_>
266class DenseStorage<T, 0, Rows_, Dynamic, Options_> {
270 EIGEN_DEVICE_FUNC DenseStorage() : m_cols(0) {}
271 EIGEN_DEVICE_FUNC
explicit DenseStorage(internal::constructor_without_unaligned_array_assert) : DenseStorage() {}
272 EIGEN_DEVICE_FUNC DenseStorage(
const DenseStorage& other) : m_cols(other.m_cols) {}
273 EIGEN_DEVICE_FUNC DenseStorage& operator=(
const DenseStorage& other) {
274 m_cols = other.m_cols;
277 EIGEN_DEVICE_FUNC DenseStorage(Index, Index, Index cols) : m_cols(cols) {
278 eigen_assert(Rows_ * m_cols == 0 &&
"The number of rows times columns must equal the storage size.");
280 EIGEN_DEVICE_FUNC
void swap(DenseStorage& other) { numext::swap(m_cols, other.m_cols); }
281 EIGEN_DEVICE_FUNC
static EIGEN_CONSTEXPR Index rows(
void) EIGEN_NOEXCEPT {
return Rows_; }
282 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols(
void)
const EIGEN_NOEXCEPT {
return m_cols; }
283 EIGEN_DEVICE_FUNC
void conservativeResize(Index, Index, Index cols) {
285 eigen_assert(Rows_ * m_cols == 0 &&
"The number of rows times columns must equal the storage size.");
287 EIGEN_DEVICE_FUNC
void resize(Index, Index, Index cols) {
289 eigen_assert(Rows_ * m_cols == 0 &&
"The number of rows times columns must equal the storage size.");
291 EIGEN_DEVICE_FUNC
const T* data()
const {
return nullptr; }
292 EIGEN_DEVICE_FUNC T* data() {
return nullptr; }
295template <
typename T,
int Cols_,
int Options_>
296class DenseStorage<T, 0, Dynamic, Cols_, Options_> {
300 EIGEN_DEVICE_FUNC DenseStorage() : m_rows(0) {}
301 EIGEN_DEVICE_FUNC
explicit DenseStorage(internal::constructor_without_unaligned_array_assert) : DenseStorage() {}
302 EIGEN_DEVICE_FUNC DenseStorage(
const DenseStorage& other) : m_rows(other.m_rows) {}
303 EIGEN_DEVICE_FUNC DenseStorage& operator=(
const DenseStorage& other) {
304 m_rows = other.m_rows;
307 EIGEN_DEVICE_FUNC DenseStorage(Index, Index rows, Index) : m_rows(rows) {
308 eigen_assert(m_rows * Cols_ == 0 &&
"The number of rows times columns must equal the storage size.");
310 EIGEN_DEVICE_FUNC
void swap(DenseStorage& other) { numext::swap(m_rows, other.m_rows); }
311 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows(
void)
const EIGEN_NOEXCEPT {
return m_rows; }
312 EIGEN_DEVICE_FUNC
static EIGEN_CONSTEXPR Index cols(
void) EIGEN_NOEXCEPT {
return Cols_; }
313 EIGEN_DEVICE_FUNC
void conservativeResize(Index, Index rows, Index) {
315 eigen_assert(m_rows * Cols_ == 0 &&
"The number of rows times columns must equal the storage size.");
317 EIGEN_DEVICE_FUNC
void resize(Index, Index rows, Index) {
319 eigen_assert(m_rows * Cols_ == 0 &&
"The number of rows times columns must equal the storage size.");
321 EIGEN_DEVICE_FUNC
const T* data()
const {
return nullptr; }
322 EIGEN_DEVICE_FUNC T* data() {
return nullptr; }
326template <
typename T,
int Size,
int Options_>
327class DenseStorage<T, Size, Dynamic, Dynamic, Options_> {
328 internal::plain_array<T, Size, Options_> m_data;
333 EIGEN_DEVICE_FUNC
constexpr DenseStorage() : m_data(), m_rows(0), m_cols(0) {}
334 EIGEN_DEVICE_FUNC
explicit constexpr DenseStorage(internal::constructor_without_unaligned_array_assert)
335 : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0), m_cols(0) {}
336 EIGEN_DEVICE_FUNC
constexpr DenseStorage(
const DenseStorage& other)
337 : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(other.m_rows), m_cols(other.m_cols) {
338 internal::plain_array_helper::copy(other.m_data, m_rows * m_cols, m_data);
340 EIGEN_DEVICE_FUNC DenseStorage& operator=(
const DenseStorage& other) {
341 if (
this != &other) {
342 m_rows = other.m_rows;
343 m_cols = other.m_cols;
344 internal::plain_array_helper::copy(other.m_data, m_rows * m_cols, m_data);
348 EIGEN_DEVICE_FUNC
constexpr DenseStorage(Index, Index rows, Index cols) : m_rows(rows), m_cols(cols) {}
349 EIGEN_DEVICE_FUNC
void swap(DenseStorage& other) {
350 internal::plain_array_helper::swap(m_data, m_rows * m_cols, other.m_data, other.m_rows * other.m_cols);
351 numext::swap(m_rows, other.m_rows);
352 numext::swap(m_cols, other.m_cols);
354 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return m_rows; }
355 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return m_cols; }
356 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index, Index rows, Index cols) {
360 EIGEN_DEVICE_FUNC
constexpr void resize(Index, Index rows, Index cols) {
364 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data.array; }
365 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data.array; }
369template <
typename T,
int Size,
int Cols_,
int Options_>
370class DenseStorage<T, Size, Dynamic, Cols_, Options_> {
371 internal::plain_array<T, Size, Options_> m_data;
375 EIGEN_DEVICE_FUNC
constexpr DenseStorage() : m_rows(0) {}
376 EIGEN_DEVICE_FUNC
explicit constexpr DenseStorage(internal::constructor_without_unaligned_array_assert)
377 : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0) {}
378 EIGEN_DEVICE_FUNC
constexpr DenseStorage(
const DenseStorage& other)
379 : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(other.m_rows) {
380 internal::plain_array_helper::copy(other.m_data, m_rows * Cols_, m_data);
383 EIGEN_DEVICE_FUNC DenseStorage& operator=(
const DenseStorage& other) {
384 if (
this != &other) {
385 m_rows = other.m_rows;
386 internal::plain_array_helper::copy(other.m_data, m_rows * Cols_, m_data);
390 EIGEN_DEVICE_FUNC
constexpr DenseStorage(Index, Index rows, Index) : m_rows(rows) {}
391 EIGEN_DEVICE_FUNC
void swap(DenseStorage& other) {
392 internal::plain_array_helper::swap(m_data, m_rows * Cols_, other.m_data, other.m_rows * Cols_);
393 numext::swap(m_rows, other.m_rows);
395 EIGEN_DEVICE_FUNC
constexpr Index rows(
void)
const EIGEN_NOEXCEPT {
return m_rows; }
396 EIGEN_DEVICE_FUNC
constexpr Index cols(
void)
const EIGEN_NOEXCEPT {
return Cols_; }
397 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index, Index rows, Index) { m_rows = rows; }
398 EIGEN_DEVICE_FUNC
constexpr void resize(Index, Index rows, Index) { m_rows = rows; }
399 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data.array; }
400 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data.array; }
404template <
typename T,
int Size,
int Rows_,
int Options_>
405class DenseStorage<T, Size, Rows_, Dynamic, Options_> {
406 internal::plain_array<T, Size, Options_> m_data;
410 EIGEN_DEVICE_FUNC
constexpr DenseStorage() : m_cols(0) {}
411 EIGEN_DEVICE_FUNC
explicit constexpr DenseStorage(internal::constructor_without_unaligned_array_assert)
412 : m_data(internal::constructor_without_unaligned_array_assert()), m_cols(0) {}
413 EIGEN_DEVICE_FUNC
constexpr DenseStorage(
const DenseStorage& other)
414 : m_data(internal::constructor_without_unaligned_array_assert()), m_cols(other.m_cols) {
415 internal::plain_array_helper::copy(other.m_data, Rows_ * m_cols, m_data);
417 EIGEN_DEVICE_FUNC DenseStorage& operator=(
const DenseStorage& other) {
418 if (
this != &other) {
419 m_cols = other.m_cols;
420 internal::plain_array_helper::copy(other.m_data, Rows_ * m_cols, m_data);
424 EIGEN_DEVICE_FUNC DenseStorage(Index, Index, Index cols) : m_cols(cols) {}
425 EIGEN_DEVICE_FUNC
void swap(DenseStorage& other) {
426 internal::plain_array_helper::swap(m_data, Rows_ * m_cols, other.m_data, Rows_ * other.m_cols);
427 numext::swap(m_cols, other.m_cols);
429 EIGEN_DEVICE_FUNC
constexpr Index rows(
void)
const EIGEN_NOEXCEPT {
return Rows_; }
430 EIGEN_DEVICE_FUNC
constexpr Index cols(
void)
const EIGEN_NOEXCEPT {
return m_cols; }
431 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index, Index, Index cols) { m_cols = cols; }
432 EIGEN_DEVICE_FUNC
constexpr void resize(Index, Index, Index cols) { m_cols = cols; }
433 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data.array; }
434 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data.array; }
438template <
typename T,
int Options_>
439class DenseStorage<T, Dynamic, Dynamic, Dynamic, Options_> {
445 EIGEN_DEVICE_FUNC
constexpr DenseStorage() : m_data(0), m_rows(0), m_cols(0) {}
446 EIGEN_DEVICE_FUNC
explicit constexpr DenseStorage(internal::constructor_without_unaligned_array_assert)
447 : m_data(0), m_rows(0), m_cols(0) {}
448 EIGEN_DEVICE_FUNC DenseStorage(Index size, Index rows, Index cols)
449 : m_data(internal::conditional_aligned_new_auto<T, (Options_ &
DontAlign) == 0>(size)),
452 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
453 eigen_internal_assert(size == rows * cols && rows >= 0 && cols >= 0);
455 EIGEN_DEVICE_FUNC DenseStorage(
const DenseStorage& other)
456 : m_data(internal::conditional_aligned_new_auto<T, (Options_ &
DontAlign) == 0>(other.m_rows * other.m_cols)),
457 m_rows(other.m_rows),
458 m_cols(other.m_cols) {
459 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = m_rows * m_cols)
460 internal::smart_copy(other.m_data, other.m_data + other.m_rows * other.m_cols, m_data);
462 EIGEN_DEVICE_FUNC DenseStorage& operator=(
const DenseStorage& other) {
463 if (
this != &other) {
464 DenseStorage tmp(other);
469 EIGEN_DEVICE_FUNC DenseStorage(DenseStorage&& other) EIGEN_NOEXCEPT : m_data(std::move(other.m_data)),
470 m_rows(std::move(other.m_rows)),
471 m_cols(std::move(other.m_cols)) {
472 other.m_data =
nullptr;
476 EIGEN_DEVICE_FUNC DenseStorage& operator=(DenseStorage&& other) EIGEN_NOEXCEPT {
477 numext::swap(m_data, other.m_data);
478 numext::swap(m_rows, other.m_rows);
479 numext::swap(m_cols, other.m_cols);
482 EIGEN_DEVICE_FUNC ~DenseStorage() {
483 internal::conditional_aligned_delete_auto<T, (Options_ & DontAlign) == 0>(m_data, m_rows * m_cols);
485 EIGEN_DEVICE_FUNC
void swap(DenseStorage& other) {
486 numext::swap(m_data, other.m_data);
487 numext::swap(m_rows, other.m_rows);
488 numext::swap(m_cols, other.m_cols);
490 EIGEN_DEVICE_FUNC Index rows(
void)
const EIGEN_NOEXCEPT {
return m_rows; }
491 EIGEN_DEVICE_FUNC Index cols(
void)
const EIGEN_NOEXCEPT {
return m_cols; }
492 void conservativeResize(Index size, Index rows, Index cols) {
494 internal::conditional_aligned_realloc_new_auto<T, (Options_ & DontAlign) == 0>(m_data, size, m_rows * m_cols);
498 EIGEN_DEVICE_FUNC
void resize(Index size, Index rows, Index cols) {
499 if (size != m_rows * m_cols) {
500 internal::conditional_aligned_delete_auto<T, (Options_ & DontAlign) == 0>(m_data, m_rows * m_cols);
502 m_data = internal::conditional_aligned_new_auto<T, (Options_ & DontAlign) == 0>(size);
505 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
510 EIGEN_DEVICE_FUNC
const T* data()
const {
return m_data; }
511 EIGEN_DEVICE_FUNC T* data() {
return m_data; }
515template <
typename T,
int Rows_,
int Options_>
516class DenseStorage<T, Dynamic, Rows_, Dynamic, Options_> {
521 EIGEN_DEVICE_FUNC
constexpr DenseStorage() : m_data(0), m_cols(0) {}
522 explicit constexpr DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_cols(0) {}
523 EIGEN_DEVICE_FUNC DenseStorage(Index size, Index rows, Index cols)
524 : m_data(internal::conditional_aligned_new_auto<T, (Options_ &
DontAlign) == 0>(size)), m_cols(cols) {
525 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
526 eigen_internal_assert(size == rows * cols && rows == Rows_ && cols >= 0);
527 EIGEN_UNUSED_VARIABLE(rows);
529 EIGEN_DEVICE_FUNC DenseStorage(
const DenseStorage& other)
530 : m_data(internal::conditional_aligned_new_auto<T, (Options_ &
DontAlign) == 0>(Rows_ * other.m_cols)),
531 m_cols(other.m_cols) {
532 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = m_cols * Rows_)
533 internal::smart_copy(other.m_data, other.m_data + Rows_ * m_cols, m_data);
535 EIGEN_DEVICE_FUNC DenseStorage& operator=(
const DenseStorage& other) {
536 if (
this != &other) {
537 DenseStorage tmp(other);
542 EIGEN_DEVICE_FUNC DenseStorage(DenseStorage&& other) EIGEN_NOEXCEPT : m_data(std::move(other.m_data)),
543 m_cols(std::move(other.m_cols)) {
544 other.m_data =
nullptr;
547 EIGEN_DEVICE_FUNC DenseStorage& operator=(DenseStorage&& other) EIGEN_NOEXCEPT {
548 numext::swap(m_data, other.m_data);
549 numext::swap(m_cols, other.m_cols);
552 EIGEN_DEVICE_FUNC ~DenseStorage() {
553 internal::conditional_aligned_delete_auto<T, (Options_ & DontAlign) == 0>(m_data, Rows_ * m_cols);
555 EIGEN_DEVICE_FUNC
void swap(DenseStorage& other) {
556 numext::swap(m_data, other.m_data);
557 numext::swap(m_cols, other.m_cols);
559 EIGEN_DEVICE_FUNC
static constexpr Index rows(
void) EIGEN_NOEXCEPT {
return Rows_; }
560 EIGEN_DEVICE_FUNC Index cols(
void)
const EIGEN_NOEXCEPT {
return m_cols; }
561 EIGEN_DEVICE_FUNC
void conservativeResize(Index size, Index, Index cols) {
563 internal::conditional_aligned_realloc_new_auto<T, (Options_ & DontAlign) == 0>(m_data, size, Rows_ * m_cols);
566 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void resize(Index size, Index, Index cols) {
567 if (size != Rows_ * m_cols) {
568 internal::conditional_aligned_delete_auto<T, (Options_ & DontAlign) == 0>(m_data, Rows_ * m_cols);
570 m_data = internal::conditional_aligned_new_auto<T, (Options_ & DontAlign) == 0>(size);
573 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
577 EIGEN_DEVICE_FUNC
const T* data()
const {
return m_data; }
578 EIGEN_DEVICE_FUNC T* data() {
return m_data; }
582template <
typename T,
int Cols_,
int Options_>
583class DenseStorage<T, Dynamic, Dynamic, Cols_, Options_> {
588 EIGEN_DEVICE_FUNC
constexpr DenseStorage() : m_data(0), m_rows(0) {}
589 explicit constexpr DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_rows(0) {}
590 EIGEN_DEVICE_FUNC
constexpr DenseStorage(Index size, Index rows, Index cols)
591 : m_data(internal::conditional_aligned_new_auto<T, (Options_ &
DontAlign) == 0>(size)), m_rows(rows) {
592 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
593 eigen_internal_assert(size == rows * cols && rows >= 0 && cols == Cols_);
594 EIGEN_UNUSED_VARIABLE(cols);
596 EIGEN_DEVICE_FUNC DenseStorage(
const DenseStorage& other)
597 : m_data(internal::conditional_aligned_new_auto<T, (Options_ &
DontAlign) == 0>(other.m_rows * Cols_)),
598 m_rows(other.m_rows) {
599 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = m_rows * Cols_)
600 internal::smart_copy(other.m_data, other.m_data + other.m_rows * Cols_, m_data);
602 EIGEN_DEVICE_FUNC DenseStorage& operator=(
const DenseStorage& other) {
603 if (
this != &other) {
604 DenseStorage tmp(other);
609 EIGEN_DEVICE_FUNC DenseStorage(DenseStorage&& other) EIGEN_NOEXCEPT : m_data(std::move(other.m_data)),
610 m_rows(std::move(other.m_rows)) {
611 other.m_data =
nullptr;
614 EIGEN_DEVICE_FUNC DenseStorage& operator=(DenseStorage&& other) EIGEN_NOEXCEPT {
615 numext::swap(m_data, other.m_data);
616 numext::swap(m_rows, other.m_rows);
619 EIGEN_DEVICE_FUNC ~DenseStorage() {
620 internal::conditional_aligned_delete_auto<T, (Options_ & DontAlign) == 0>(m_data, Cols_ * m_rows);
622 EIGEN_DEVICE_FUNC
void swap(DenseStorage& other) {
623 numext::swap(m_data, other.m_data);
624 numext::swap(m_rows, other.m_rows);
626 EIGEN_DEVICE_FUNC Index rows(
void)
const EIGEN_NOEXCEPT {
return m_rows; }
627 EIGEN_DEVICE_FUNC
static constexpr Index cols(
void) {
return Cols_; }
628 void conservativeResize(Index size, Index rows, Index) {
630 internal::conditional_aligned_realloc_new_auto<T, (Options_ & DontAlign) == 0>(m_data, size, m_rows * Cols_);
633 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void resize(Index size, Index rows, Index) {
634 if (size != m_rows * Cols_) {
635 internal::conditional_aligned_delete_auto<T, (Options_ & DontAlign) == 0>(m_data, Cols_ * m_rows);
637 m_data = internal::conditional_aligned_new_auto<T, (Options_ & DontAlign) == 0>(size);
640 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
644 EIGEN_DEVICE_FUNC
const T* data()
const {
return m_data; }
645 EIGEN_DEVICE_FUNC T* data() {
return m_data; }
@ DontAlign
Definition Constants.h:324
Namespace containing all symbols from the Eigen library.
Definition Core:137
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:83