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);
93template <
typename T,
bool Align>
94EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void copy_to_new_buffer(
const T* src, Index size, T* dst) {
95 EIGEN_IF_CONSTEXPR (!std::is_nothrow_copy_assignable<T>::value) {
96 EIGEN_TRY { smart_copy(src, src + size, dst); }
98 conditional_aligned_delete_auto<T, Align>(dst, size);
102 smart_copy(src, src + size, dst);
106template <
typename T,
int Size,
int Rows,
int Cols,
int Options>
107class DenseStorage_impl {
108 plain_array<T, Size, Options> m_data;
111#ifndef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
112 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
113 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
115 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() {
116 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = Size)
118 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other) {
119 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = Size)
120 smart_copy(other.m_data.array, other.m_data.array + Size, m_data.array);
123 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(Index , Index , Index ) {}
124 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
125 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other) {
126 numext::swap(m_data, other.m_data);
128 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index , Index ) {}
129 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index , Index ) {}
130 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return Rows; }
131 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return Cols; }
132 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return Rows * Cols; }
133 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data.array; }
134 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data.array; }
136template <
typename T,
int Size,
int Cols,
int Options>
137class DenseStorage_impl<T, Size, Dynamic, Cols, Options> {
138 plain_array<T, Size, Options> m_data;
142 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
143 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
144 : m_rows(other.m_rows) {
145 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = other.size())
146 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
148 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(Index size, Index rows, Index )
150 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
151 EIGEN_UNUSED_VARIABLE(size);
153 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
154 if (
this == &other)
return *
this;
155 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
156 m_rows = other.m_rows;
159 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other) {
160 swap_plain_array(m_data, other.m_data, size(), other.size());
161 numext::swap(m_rows, other.m_rows);
163 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index rows, Index ) { m_rows = rows; }
164 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index rows, Index ) { m_rows = rows; }
165 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return m_rows; }
166 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return Cols; }
167 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return m_rows * Cols; }
168 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data.array; }
169 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data.array; }
171template <
typename T,
int Size,
int Rows,
int Options>
172class DenseStorage_impl<T, Size, Rows, Dynamic, Options> {
173 plain_array<T, Size, Options> m_data;
177 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
178 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
179 : m_cols(other.m_cols) {
180 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = other.size())
181 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
183 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(Index size, Index , Index cols)
185 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
186 EIGEN_UNUSED_VARIABLE(size);
188 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
189 if (
this == &other)
return *
this;
190 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
191 m_cols = other.m_cols;
194 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other) {
195 swap_plain_array(m_data, other.m_data, size(), other.size());
196 numext::swap(m_cols, other.m_cols);
198 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index , Index cols) { m_cols = cols; }
199 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index , Index cols) { m_cols = cols; }
200 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return Rows; }
201 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return m_cols; }
202 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return Rows * m_cols; }
203 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data.array; }
204 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data.array; }
206template <
typename T,
int Size,
int Options>
207class DenseStorage_impl<T, Size, Dynamic, Dynamic, Options> {
208 plain_array<T, Size, Options> m_data;
213 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
214 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
215 : m_rows(other.m_rows), m_cols(other.m_cols) {
216 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = other.size())
217 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
219 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(Index size, Index rows, Index cols)
220 : m_rows(rows), m_cols(cols) {
221 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
222 EIGEN_UNUSED_VARIABLE(size);
224 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
225 if (
this == &other)
return *
this;
226 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
227 m_rows = other.m_rows;
228 m_cols = other.m_cols;
231 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other) {
232 swap_plain_array(m_data, other.m_data, size(), other.size());
233 numext::swap(m_rows, other.m_rows);
234 numext::swap(m_cols, other.m_cols);
236 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index rows, Index cols) {
240 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index rows, Index cols) {
244 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return m_rows; }
245 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return m_cols; }
246 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return m_rows * m_cols; }
247 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data.array; }
248 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data.array; }
251template <
typename T,
int Rows,
int Cols,
int Options>
252class DenseStorage_impl<T, 0, Rows, Cols, Options> {
254 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
255 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
256 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(Index , Index , Index ) {}
257 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
258 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage_impl&) {}
259 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index , Index ) {}
260 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index , Index ) {}
261 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return Rows; }
262 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return Cols; }
263 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return Rows * Cols; }
264 EIGEN_DEVICE_FUNC
constexpr T* data() {
return nullptr; }
265 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return nullptr; }
267template <
typename T,
int Cols,
int Options>
268class DenseStorage_impl<T, 0, Dynamic, Cols, Options> {
272 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
273 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
274 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(Index , Index rows, Index ) : m_rows(rows) {}
275 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
276 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage_impl& other)
noexcept { numext::swap(m_rows, other.m_rows); }
277 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index rows, Index ) { m_rows = rows; }
278 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index rows, Index ) { m_rows = rows; }
279 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return m_rows; }
280 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return Cols; }
281 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return m_rows * Cols; }
282 EIGEN_DEVICE_FUNC
constexpr T* data() {
return nullptr; }
283 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return nullptr; }
285template <
typename T,
int Rows,
int Options>
286class DenseStorage_impl<T, 0, Rows, 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 , Index cols) : 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 { numext::swap(m_cols, other.m_cols); }
295 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index , Index cols) { m_cols = cols; }
296 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index , Index cols) { m_cols = cols; }
297 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return Rows; }
298 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return m_cols; }
299 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return Rows * m_cols; }
300 EIGEN_DEVICE_FUNC
constexpr T* data() {
return nullptr; }
301 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return nullptr; }
303template <
typename T,
int Options>
304class DenseStorage_impl<T, 0, Dynamic, Dynamic, Options> {
309 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
310 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
311 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(Index , Index rows, Index cols) : m_rows(rows), m_cols(cols) {}
312 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
313 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage_impl& other)
noexcept {
314 numext::swap(m_rows, other.m_rows);
315 numext::swap(m_cols, other.m_cols);
317 EIGEN_DEVICE_FUNC
constexpr void conservativeResize(Index , Index rows, Index cols) {
321 EIGEN_DEVICE_FUNC
constexpr void resize(Index , Index rows, Index cols) {
325 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return m_rows; }
326 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return m_cols; }
327 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return m_rows * m_cols; }
328 EIGEN_DEVICE_FUNC
constexpr T* data() {
return nullptr; }
329 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return nullptr; }
332template <
typename T,
int Rows,
int Cols,
int Options>
333class DenseStorage_impl<T, Dynamic, Rows, Cols, Options> {};
335template <
typename T,
int Cols,
int Options>
336class DenseStorage_impl<T, Dynamic, Dynamic, Cols, Options> {
337 static constexpr bool Align = (Options &
DontAlign) == 0;
342 static constexpr int Size = Dynamic;
343 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
344 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
345 : m_data(conditional_aligned_new_auto<T, Align>(other.size())), m_rows(other.m_rows) {
346 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = other.size())
347 copy_to_new_buffer<T, Align>(other.m_data, other.size(), m_data);
349 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(Index size, Index rows, Index )
350 : m_data(conditional_aligned_new_auto<T, Align>(size)), m_rows(rows) {
351 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
353 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(DenseStorage_impl&& other) noexcept
354 : m_data(other.m_data), m_rows(other.m_rows) {
355 other.m_data =
nullptr;
358 EIGEN_DEVICE_FUNC ~DenseStorage_impl() { conditional_aligned_delete_auto<T, Align>(m_data, size()); }
359 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
360 if (
this == &other)
return *
this;
361 resize(other.size(), other.rows(), other.cols());
362 smart_copy(other.m_data, other.m_data + other.size(), m_data);
365 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(DenseStorage_impl&& other)
noexcept {
369 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage_impl& other)
noexcept {
370 numext::swap(m_data, other.m_data);
371 numext::swap(m_rows, other.m_rows);
373 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(Index size, Index rows, Index ) {
374 m_data = conditional_aligned_realloc_new_auto<T, Align>(m_data, size, this->size());
377 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(Index size, Index rows, Index ) {
378 Index oldSize = this->size();
379 if (oldSize != size) {
380 conditional_aligned_delete_auto<T, Align>(m_data, oldSize);
384 m_data = conditional_aligned_new_auto<T, Align>(size);
385 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
389 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return m_rows; }
390 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return Cols; }
391 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return m_rows * Cols; }
392 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data; }
393 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data; }
395template <
typename T,
int Rows,
int Options>
396class DenseStorage_impl<T, Dynamic, Rows, Dynamic, Options> {
397 static constexpr bool Align = (Options &
DontAlign) == 0;
402 static constexpr int Size = Dynamic;
403 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
404 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
405 : m_data(conditional_aligned_new_auto<T, Align>(other.size())), m_cols(other.m_cols) {
406 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = other.size())
407 copy_to_new_buffer<T, Align>(other.m_data, other.size(), m_data);
409 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(Index size, Index , Index cols)
410 : m_data(conditional_aligned_new_auto<T, Align>(size)), m_cols(cols) {
411 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
413 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(DenseStorage_impl&& other) noexcept
414 : m_data(other.m_data), m_cols(other.m_cols) {
415 other.m_data =
nullptr;
418 EIGEN_DEVICE_FUNC ~DenseStorage_impl() { conditional_aligned_delete_auto<T, Align>(m_data, size()); }
419 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
420 if (
this == &other)
return *
this;
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
constexpr DenseStorage_impl& operator=(DenseStorage_impl&& other)
noexcept {
429 EIGEN_DEVICE_FUNC
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);
444 m_data = conditional_aligned_new_auto<T, Align>(size);
445 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
449 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return Rows; }
450 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return m_cols; }
451 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return Rows * m_cols; }
452 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data; }
453 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data; }
455template <
typename T,
int Options>
456class DenseStorage_impl<T, Dynamic, Dynamic, Dynamic, Options> {
457 static constexpr bool Align = (Options &
DontAlign) == 0;
463 static constexpr int Size = Dynamic;
464 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl() =
default;
465 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
466 : m_data(conditional_aligned_new_auto<T, Align>(other.size())), m_rows(other.m_rows), m_cols(other.m_cols) {
467 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = other.size())
468 copy_to_new_buffer<T, Align>(other.m_data, other.size(), m_data);
470 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(Index size, Index rows, Index cols)
471 : m_data(conditional_aligned_new_auto<T, Align>(size)), m_rows(rows), m_cols(cols) {
472 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
474 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl(DenseStorage_impl&& other) noexcept
475 : m_data(other.m_data), m_rows(other.m_rows), m_cols(other.m_cols) {
476 other.m_data =
nullptr;
480 EIGEN_DEVICE_FUNC ~DenseStorage_impl() { conditional_aligned_delete_auto<T, Align>(m_data, size()); }
481 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
482 if (
this == &other)
return *
this;
483 resize(other.size(), other.rows(), other.cols());
484 smart_copy(other.m_data, other.m_data + other.size(), m_data);
487 EIGEN_DEVICE_FUNC
constexpr DenseStorage_impl& operator=(DenseStorage_impl&& other)
noexcept {
491 EIGEN_DEVICE_FUNC
constexpr void swap(DenseStorage_impl& other)
noexcept {
492 numext::swap(m_data, other.m_data);
493 numext::swap(m_rows, other.m_rows);
494 numext::swap(m_cols, other.m_cols);
496 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(Index size, Index rows, Index cols) {
497 m_data = conditional_aligned_realloc_new_auto<T, Align>(m_data, size, this->size());
501 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(Index size, Index rows, Index cols) {
502 Index oldSize = this->size();
503 if (oldSize != size) {
504 conditional_aligned_delete_auto<T, Align>(m_data, oldSize);
509 m_data = conditional_aligned_new_auto<T, Align>(size);
510 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
515 EIGEN_DEVICE_FUNC
constexpr Index rows()
const {
return m_rows; }
516 EIGEN_DEVICE_FUNC
constexpr Index cols()
const {
return m_cols; }
517 EIGEN_DEVICE_FUNC
constexpr Index size()
const {
return m_rows * m_cols; }
518 EIGEN_DEVICE_FUNC
constexpr T* data() {
return m_data; }
519 EIGEN_DEVICE_FUNC
constexpr const T* data()
const {
return m_data; }
521template <
typename T,
int Size,
int Rows,
int Cols>
522struct use_default_move {
523 static constexpr bool DynamicObject = Size == Dynamic;
524 static constexpr bool TrivialObject =
525 (!NumTraits<T>::RequireInitialization) && (Rows >= 0) && (Cols >= 0) && (Size == Rows * Cols);
526 static constexpr bool value = DynamicObject || TrivialObject;
542template <
typename T,
int Size,
int Rows,
int Cols,
int Options,
543 bool Trivial = internal::use_default_move<T, Size, Rows, Cols>::value>
544class DenseStorage :
public internal::DenseStorage_impl<T, Size, Rows, Cols, Options> {
545 using Base = internal::DenseStorage_impl<T, Size, Rows, Cols, Options>;
548 EIGEN_DEVICE_FUNC
constexpr DenseStorage() =
default;
549 EIGEN_DEVICE_FUNC
constexpr DenseStorage(
const DenseStorage&) =
default;
550 EIGEN_DEVICE_FUNC
constexpr DenseStorage(Index size, Index rows, Index cols) : Base(size, rows, cols) {}
551 EIGEN_DEVICE_FUNC
constexpr DenseStorage& operator=(
const DenseStorage&) =
default;
554 EIGEN_DEVICE_FUNC
constexpr DenseStorage(DenseStorage&&) =
default;
555 EIGEN_DEVICE_FUNC
constexpr DenseStorage& operator=(DenseStorage&&) =
default;
557template <
typename T,
int Size,
int Rows,
int Cols,
int Options>
558class DenseStorage<T, Size, Rows, Cols, Options, false>
559 :
public internal::DenseStorage_impl<T, Size, Rows, Cols, Options> {
560 using Base = internal::DenseStorage_impl<T, Size, Rows, Cols, Options>;
563 EIGEN_DEVICE_FUNC
constexpr DenseStorage() =
default;
564 EIGEN_DEVICE_FUNC
constexpr DenseStorage(
const DenseStorage&) =
default;
565 EIGEN_DEVICE_FUNC
constexpr DenseStorage(Index size, Index rows, Index cols) : Base(size, rows, cols) {}
566 EIGEN_DEVICE_FUNC
constexpr DenseStorage& operator=(
const DenseStorage&) =
default;
569 EIGEN_DEVICE_FUNC
constexpr DenseStorage(DenseStorage&& other)
570 : DenseStorage(static_cast<const DenseStorage&>(other)) {}
571 EIGEN_DEVICE_FUNC
constexpr DenseStorage& operator=(DenseStorage&& other) {
@ DontAlign
Definition Constants.h:325