12#ifndef EIGEN_MATRIXSTORAGE_H
13#define EIGEN_MATRIXSTORAGE_H
15#ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
16#define EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(X) \
18 EIGEN_DENSE_STORAGE_CTOR_PLUGIN;
20#define EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(X)
24#include "./InternalHeaderCheck.h"
30#if defined(EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT)
31#define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(Alignment)
33#define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(Alignment) \
34 eigen_assert((is_constant_evaluated() || (std::uintptr_t(array) % Alignment == 0)) && \
35 "this assertion is explained here: " \
36 "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" \
37 " **** READ THIS WEB PAGE !!! ****");
40#if EIGEN_STACK_ALLOCATION_LIMIT
41#define EIGEN_MAKE_STACK_ALLOCATION_ASSERT(X) \
42 EIGEN_STATIC_ASSERT(X <= EIGEN_STACK_ALLOCATION_LIMIT, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG)
44#define EIGEN_MAKE_STACK_ALLOCATION_ASSERT(X)
52template <
typename T,
int Size,
int MatrixOrArrayOptions,
53 int Alignment = (MatrixOrArrayOptions &
DontAlign) ? 0 : compute_default_alignment<T, Size>::value>
55 EIGEN_ALIGN_TO_BOUNDARY(Alignment) T array[Size];
56#if defined(EIGEN_NO_DEBUG) || defined(EIGEN_TESTING_PLAINOBJECT_CTOR)
57 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr plain_array() =
default;
59 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr plain_array() {
60 EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(Alignment)
61 EIGEN_MAKE_STACK_ALLOCATION_ASSERT(Size *
sizeof(T))
66template <
typename T,
int Size,
int MatrixOrArrayOptions>
67struct plain_array<T, Size, MatrixOrArrayOptions, 0> {
69#if defined(EIGEN_NO_DEBUG) || defined(EIGEN_TESTING_PLAINOBJECT_CTOR)
70 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr plain_array() =
default;
72 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr plain_array() { EIGEN_MAKE_STACK_ALLOCATION_ASSERT(Size *
sizeof(T)) }
76template <
typename T,
int MatrixOrArrayOptions,
int Alignment>
77struct plain_array<T, 0, MatrixOrArrayOptions, Alignment> {
79 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr plain_array() =
default;
82template <
typename T,
int Size,
int Options,
int Alignment>
83EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap_plain_array(plain_array<T, Size, Options, Alignment>& a,
84 plain_array<T, Size, Options, Alignment>& b,
86 Index common_size = numext::mini(a_size, b_size);
87 std::swap_ranges(a.array, a.array + common_size, b.array);
89 smart_copy(a.array + common_size, a.array + a_size, b.array + common_size);
90 else if (b_size > a_size)
91 smart_copy(b.array + common_size, b.array + b_size, a.array + common_size);
94template <
typename T,
int Size,
int Rows,
int Cols,
int Options>
95class DenseStorage_impl {
96 plain_array<T, Size, Options> m_data;
99#ifndef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
100 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
101 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
103 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() {
104 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(
Index size = Size)
106 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other) {
107 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(
Index size = Size)
108 smart_copy(other.m_data.array, other.m_data.array + Size, m_data.array);
111 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
Index ,
Index ,
Index ) {}
112 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
113 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other) {
114 numext::swap(m_data, other.m_data);
116 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index ,
Index ,
118 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index ,
Index ,
Index ) {}
119 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return Rows; }
120 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return Cols; }
121 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return Rows * Cols; }
122 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return m_data.array; }
123 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return m_data.array; }
125template <
typename T,
int Size,
int Cols,
int Options>
126class DenseStorage_impl<T, Size, Dynamic, Cols, Options> {
127 plain_array<T, Size, Options> m_data;
131 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
132 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
133 : m_rows(other.m_rows) {
134 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(
Index size = other.size())
135 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
137 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(
Index size,
Index rows,
Index )
139 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
140 EIGEN_UNUSED_VARIABLE(size)
142 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
143 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
144 m_rows = other.m_rows;
147 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other) {
148 swap_plain_array(m_data, other.m_data, size(), other.size());
149 numext::swap(m_rows, other.m_rows);
151 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index ,
Index rows,
Index ) {
154 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index ,
Index rows,
Index ) {
157 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return m_rows; }
158 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return Cols; }
159 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return m_rows * Cols; }
160 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return m_data.array; }
161 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return m_data.array; }
163template <
typename T,
int Size,
int Rows,
int Options>
164class DenseStorage_impl<T, Size, Rows, Dynamic, Options> {
165 plain_array<T, Size, Options> m_data;
169 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
170 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
171 : m_cols(other.m_cols) {
172 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(
Index size = other.size())
173 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
175 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(
Index size,
Index ,
Index cols)
177 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
178 EIGEN_UNUSED_VARIABLE(size)
180 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
181 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
182 m_cols = other.m_cols;
185 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other) {
186 swap_plain_array(m_data, other.m_data, size(), other.size());
187 numext::swap(m_cols, other.m_cols);
189 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index ,
Index ,
Index cols) {
192 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index ,
Index ,
Index cols) {
195 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return Rows; }
196 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return m_cols; }
197 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return Rows * m_cols; }
198 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return m_data.array; }
199 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return m_data.array; }
201template <
typename T,
int Size,
int Options>
202class DenseStorage_impl<T, Size, Dynamic, Dynamic, Options> {
203 plain_array<T, Size, Options> m_data;
208 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
209 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
210 : m_rows(other.m_rows), m_cols(other.m_cols) {
211 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(
Index size = other.size())
212 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
214 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(
Index size,
Index rows,
Index cols)
215 : m_rows(rows), m_cols(cols) {
216 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
217 EIGEN_UNUSED_VARIABLE(size)
219 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
220 smart_copy(other.m_data.array, other.m_data.array + other.size(), m_data.array);
221 m_rows = other.m_rows;
222 m_cols = other.m_cols;
225 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other) {
226 swap_plain_array(m_data, other.m_data, size(), other.size());
227 numext::swap(m_rows, other.m_rows);
228 numext::swap(m_cols, other.m_cols);
230 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index ,
Index rows,
Index cols) {
234 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index ,
Index rows,
Index cols) {
238 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return m_rows; }
239 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return m_cols; }
240 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return m_rows * m_cols; }
241 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return m_data.array; }
242 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return m_data.array; }
245template <
typename T,
int Rows,
int Cols,
int Options>
246class DenseStorage_impl<T, 0, Rows, Cols, Options> {
248 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
249 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
250 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
Index ,
Index ,
Index ) {}
251 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
252 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl&) {}
253 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index ,
Index ,
255 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index ,
Index ,
Index ) {}
256 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return Rows; }
257 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return Cols; }
258 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return Rows * Cols; }
259 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return nullptr; }
260 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return nullptr; }
262template <
typename T,
int Cols,
int Options>
263class DenseStorage_impl<T, 0, Dynamic, Cols, Options> {
267 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
268 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
269 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
Index ,
Index rows,
Index )
271 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
272 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other)
noexcept {
273 numext::swap(m_rows, other.m_rows);
275 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index ,
Index rows,
Index ) {
278 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index ,
Index rows,
Index ) {
281 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return m_rows; }
282 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return Cols; }
283 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return m_rows * Cols; }
284 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return nullptr; }
285 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return nullptr; }
287template <
typename T,
int Rows,
int Options>
288class DenseStorage_impl<T, 0, Rows, Dynamic, Options> {
292 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
293 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
294 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
Index ,
Index ,
Index cols)
296 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
297 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other)
noexcept {
298 numext::swap(m_cols, other.m_cols);
300 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index ,
Index ,
Index cols) {
303 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index ,
Index ,
Index cols) {
306 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return Rows; }
307 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return m_cols; }
308 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return Rows * m_cols; }
309 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return nullptr; }
310 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return nullptr; }
312template <
typename T,
int Options>
313class DenseStorage_impl<T, 0, Dynamic, Dynamic, Options> {
318 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
319 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl&) =
default;
320 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
Index ,
Index rows,
Index cols)
321 : m_rows(rows), m_cols(cols) {}
322 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl&) =
default;
323 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other)
noexcept {
324 numext::swap(m_rows, other.m_rows);
325 numext::swap(m_cols, other.m_cols);
327 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index ,
Index rows,
Index cols) {
331 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index ,
Index rows,
Index cols) {
335 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return m_rows; }
336 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return m_cols; }
337 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return m_rows * m_cols; }
338 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return nullptr; }
339 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return nullptr; }
342template <
typename T,
int Rows,
int Cols,
int Options>
343class DenseStorage_impl<T, Dynamic, Rows, Cols, Options> {};
345template <
typename T,
int Cols,
int Options>
346class DenseStorage_impl<T, Dynamic, Dynamic, Cols, Options> {
347 static constexpr bool Align = (Options &
DontAlign) == 0;
352 static constexpr int Size =
Dynamic;
353 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
354 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
355 : m_data(conditional_aligned_new_auto<T, Align>(other.size())), m_rows(other.m_rows) {
356 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(
Index size = other.size())
357 smart_copy(other.m_data, other.m_data + other.size(), m_data);
359 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(
Index size,
Index rows,
Index )
360 : m_data(conditional_aligned_new_auto<T, Align>(size)), m_rows(rows) {
361 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
363 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(DenseStorage_impl&& other) noexcept
364 : m_data(other.m_data), m_rows(other.m_rows) {
365 other.m_data =
nullptr;
368 EIGEN_DEVICE_FUNC ~DenseStorage_impl() { conditional_aligned_delete_auto<T, Align>(m_data, size()); }
369 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
370 resize(other.size(), other.rows(), other.cols());
371 smart_copy(other.m_data, other.m_data + other.size(), m_data);
374 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(DenseStorage_impl&& other)
noexcept {
378 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other)
noexcept {
379 numext::swap(m_data, other.m_data);
380 numext::swap(m_rows, other.m_rows);
382 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index size,
Index rows,
Index ) {
383 m_data = conditional_aligned_realloc_new_auto<T, Align>(m_data, size, this->size());
386 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index size,
Index rows,
Index ) {
387 Index oldSize = this->size();
388 if (oldSize != size) {
389 conditional_aligned_delete_auto<T, Align>(m_data, oldSize);
390 m_data = conditional_aligned_new_auto<T, Align>(size);
391 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
395 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return m_rows; }
396 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return Cols; }
397 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return m_rows * Cols; }
398 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return m_data; }
399 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return m_data; }
401template <
typename T,
int Rows,
int Options>
402class DenseStorage_impl<T, Dynamic, Rows, Dynamic, Options> {
403 static constexpr bool Align = (Options &
DontAlign) == 0;
408 static constexpr int Size =
Dynamic;
409 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
410 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
411 : m_data(conditional_aligned_new_auto<T, Align>(other.size())), m_cols(other.m_cols) {
412 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(
Index size = other.size())
413 smart_copy(other.m_data, other.m_data + other.size(), m_data);
415 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(
Index size,
Index ,
Index cols)
416 : m_data(conditional_aligned_new_auto<T, Align>(size)), m_cols(cols) {
417 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
419 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(DenseStorage_impl&& other) noexcept
420 : m_data(other.m_data), m_cols(other.m_cols) {
421 other.m_data =
nullptr;
424 EIGEN_DEVICE_FUNC ~DenseStorage_impl() { conditional_aligned_delete_auto<T, Align>(m_data, size()); }
425 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
426 resize(other.size(), other.rows(), other.cols());
427 smart_copy(other.m_data, other.m_data + other.size(), m_data);
430 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(DenseStorage_impl&& other)
noexcept {
434 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other)
noexcept {
435 numext::swap(m_data, other.m_data);
436 numext::swap(m_cols, other.m_cols);
438 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index size,
Index ,
Index cols) {
439 m_data = conditional_aligned_realloc_new_auto<T, Align>(m_data, size, this->size());
442 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index size,
Index ,
Index cols) {
443 Index oldSize = this->size();
444 if (oldSize != size) {
445 conditional_aligned_delete_auto<T, Align>(m_data, oldSize);
446 m_data = conditional_aligned_new_auto<T, Align>(size);
447 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
451 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return Rows; }
452 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return m_cols; }
453 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return Rows * m_cols; }
454 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return m_data; }
455 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return m_data; }
457template <
typename T,
int Options>
458class DenseStorage_impl<T, Dynamic, Dynamic, Dynamic, Options> {
459 static constexpr bool Align = (Options &
DontAlign) == 0;
465 static constexpr int Size =
Dynamic;
466 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl() =
default;
467 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(
const DenseStorage_impl& other)
468 : m_data(conditional_aligned_new_auto<T, Align>(other.size())), m_rows(other.m_rows), m_cols(other.m_cols) {
469 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(
Index size = other.size())
470 smart_copy(other.m_data, other.m_data + other.size(), m_data);
472 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr DenseStorage_impl(
Index size,
Index rows,
Index cols)
473 : m_data(conditional_aligned_new_auto<T, Align>(size)), m_rows(rows), m_cols(cols) {
474 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
476 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl(DenseStorage_impl&& other) noexcept
477 : m_data(other.m_data), m_rows(other.m_rows), m_cols(other.m_cols) {
478 other.m_data =
nullptr;
482 EIGEN_DEVICE_FUNC ~DenseStorage_impl() { conditional_aligned_delete_auto<T, Align>(m_data, size()); }
483 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(
const DenseStorage_impl& other) {
484 resize(other.size(), other.rows(), other.cols());
485 smart_copy(other.m_data, other.m_data + other.size(), m_data);
488 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage_impl& operator=(DenseStorage_impl&& other)
noexcept {
492 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void swap(DenseStorage_impl& other)
noexcept {
493 numext::swap(m_data, other.m_data);
494 numext::swap(m_rows, other.m_rows);
495 numext::swap(m_cols, other.m_cols);
497 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void conservativeResize(
Index size,
Index rows,
Index cols) {
498 m_data = conditional_aligned_realloc_new_auto<T, Align>(m_data, size, this->size());
502 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr void resize(
Index size,
Index rows,
Index cols) {
503 Index oldSize = this->size();
504 if (oldSize != size) {
505 conditional_aligned_delete_auto<T, Align>(m_data, oldSize);
506 m_data = conditional_aligned_new_auto<T, Align>(size);
507 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
512 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index rows()
const {
return m_rows; }
513 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index cols()
const {
return m_cols; }
514 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr Index size()
const {
return m_rows * m_cols; }
515 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr T* data() {
return m_data; }
516 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr const T* data()
const {
return m_data; }
518template <
typename T,
int Size,
int Rows,
int Cols>
519struct use_default_move {
520 static constexpr bool DynamicObject = Size ==
Dynamic;
521 static constexpr bool TrivialObject =
522 (!NumTraits<T>::RequireInitialization) && (Rows >= 0) && (Cols >= 0) && (Size == Rows * Cols);
523 static constexpr bool value = DynamicObject || TrivialObject;
539template <
typename T,
int Size,
int Rows,
int Cols,
int Options,
540 bool Trivial = internal::use_default_move<T, Size, Rows, Cols>::value>
541class DenseStorage :
public internal::DenseStorage_impl<T, Size, Rows, Cols, Options> {
542 using Base = internal::DenseStorage_impl<T, Size, Rows, Cols, Options>;
545 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage() =
default;
546 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage(
const DenseStorage&) =
default;
547 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage(
Index size,
Index rows,
Index cols)
548 : Base(size, rows, cols) {}
549 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage& operator=(
const DenseStorage&) =
default;
552 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage(DenseStorage&&) =
default;
553 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage& operator=(DenseStorage&&) =
default;
555template <
typename T,
int Size,
int Rows,
int Cols,
int Options>
556class DenseStorage<T, Size, Rows, Cols, Options, false>
557 :
public internal::DenseStorage_impl<T, Size, Rows, Cols, Options> {
558 using Base = internal::DenseStorage_impl<T, Size, Rows, Cols, Options>;
561 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage() =
default;
562 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage(
const DenseStorage&) =
default;
563 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage(
Index size,
Index rows,
Index cols)
564 : Base(size, rows, cols) {}
565 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage& operator=(
const DenseStorage&) =
default;
568 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage(DenseStorage&& other)
569 : DenseStorage(static_cast<const DenseStorage&>(other)) {}
570 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
constexpr DenseStorage& operator=(DenseStorage&& other) {
@ DontAlign
Definition Constants.h:324
Namespace containing all symbols from the Eigen library.
Definition B01_Experimental.dox:1
std::enable_if_t< std::is_base_of< DenseBase< std::decay_t< DerivedA > >, std::decay_t< DerivedA > >::value &&std::is_base_of< DenseBase< std::decay_t< DerivedB > >, std::decay_t< DerivedB > >::value, void > swap(DerivedA &&a, DerivedB &&b)
Definition DenseBase.h:667
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:82
const int Dynamic
Definition Constants.h:25