File indexing completed on 2025-01-18 09:56:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef EIGEN_MATRIXSTORAGE_H
0013 #define EIGEN_MATRIXSTORAGE_H
0014
0015 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
0016 #define EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(X) X; EIGEN_DENSE_STORAGE_CTOR_PLUGIN;
0017 #else
0018 #define EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(X)
0019 #endif
0020
0021 namespace Eigen {
0022
0023 namespace internal {
0024
0025 struct constructor_without_unaligned_array_assert {};
0026
0027 template<typename T, int Size>
0028 EIGEN_DEVICE_FUNC
0029 void check_static_allocation_size()
0030 {
0031
0032 #if EIGEN_STACK_ALLOCATION_LIMIT
0033 EIGEN_STATIC_ASSERT(Size * sizeof(T) <= EIGEN_STACK_ALLOCATION_LIMIT, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG);
0034 #endif
0035 }
0036
0037
0038
0039
0040
0041 template <typename T, int Size, int MatrixOrArrayOptions,
0042 int Alignment = (MatrixOrArrayOptions&DontAlign) ? 0
0043 : compute_default_alignment<T,Size>::value >
0044 struct plain_array
0045 {
0046 T array[Size];
0047
0048 EIGEN_DEVICE_FUNC
0049 plain_array()
0050 {
0051 check_static_allocation_size<T,Size>();
0052 }
0053
0054 EIGEN_DEVICE_FUNC
0055 plain_array(constructor_without_unaligned_array_assert)
0056 {
0057 check_static_allocation_size<T,Size>();
0058 }
0059 };
0060
0061 #if defined(EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT)
0062 #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask)
0063 #elif EIGEN_GNUC_AT_LEAST(4,7)
0064
0065
0066
0067 template<typename PtrType>
0068 EIGEN_ALWAYS_INLINE PtrType eigen_unaligned_array_assert_workaround_gcc47(PtrType array) { return array; }
0069 #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) \
0070 eigen_assert((internal::UIntPtr(eigen_unaligned_array_assert_workaround_gcc47(array)) & (sizemask)) == 0 \
0071 && "this assertion is explained here: " \
0072 "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" \
0073 " **** READ THIS WEB PAGE !!! ****");
0074 #else
0075 #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) \
0076 eigen_assert((internal::UIntPtr(array) & (sizemask)) == 0 \
0077 && "this assertion is explained here: " \
0078 "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" \
0079 " **** READ THIS WEB PAGE !!! ****");
0080 #endif
0081
0082 template <typename T, int Size, int MatrixOrArrayOptions>
0083 struct plain_array<T, Size, MatrixOrArrayOptions, 8>
0084 {
0085 EIGEN_ALIGN_TO_BOUNDARY(8) T array[Size];
0086
0087 EIGEN_DEVICE_FUNC
0088 plain_array()
0089 {
0090 EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(7);
0091 check_static_allocation_size<T,Size>();
0092 }
0093
0094 EIGEN_DEVICE_FUNC
0095 plain_array(constructor_without_unaligned_array_assert)
0096 {
0097 check_static_allocation_size<T,Size>();
0098 }
0099 };
0100
0101 template <typename T, int Size, int MatrixOrArrayOptions>
0102 struct plain_array<T, Size, MatrixOrArrayOptions, 16>
0103 {
0104 EIGEN_ALIGN_TO_BOUNDARY(16) T array[Size];
0105
0106 EIGEN_DEVICE_FUNC
0107 plain_array()
0108 {
0109 EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(15);
0110 check_static_allocation_size<T,Size>();
0111 }
0112
0113 EIGEN_DEVICE_FUNC
0114 plain_array(constructor_without_unaligned_array_assert)
0115 {
0116 check_static_allocation_size<T,Size>();
0117 }
0118 };
0119
0120 template <typename T, int Size, int MatrixOrArrayOptions>
0121 struct plain_array<T, Size, MatrixOrArrayOptions, 32>
0122 {
0123 EIGEN_ALIGN_TO_BOUNDARY(32) T array[Size];
0124
0125 EIGEN_DEVICE_FUNC
0126 plain_array()
0127 {
0128 EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(31);
0129 check_static_allocation_size<T,Size>();
0130 }
0131
0132 EIGEN_DEVICE_FUNC
0133 plain_array(constructor_without_unaligned_array_assert)
0134 {
0135 check_static_allocation_size<T,Size>();
0136 }
0137 };
0138
0139 template <typename T, int Size, int MatrixOrArrayOptions>
0140 struct plain_array<T, Size, MatrixOrArrayOptions, 64>
0141 {
0142 EIGEN_ALIGN_TO_BOUNDARY(64) T array[Size];
0143
0144 EIGEN_DEVICE_FUNC
0145 plain_array()
0146 {
0147 EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(63);
0148 check_static_allocation_size<T,Size>();
0149 }
0150
0151 EIGEN_DEVICE_FUNC
0152 plain_array(constructor_without_unaligned_array_assert)
0153 {
0154 check_static_allocation_size<T,Size>();
0155 }
0156 };
0157
0158 template <typename T, int MatrixOrArrayOptions, int Alignment>
0159 struct plain_array<T, 0, MatrixOrArrayOptions, Alignment>
0160 {
0161 T array[1];
0162 EIGEN_DEVICE_FUNC plain_array() {}
0163 EIGEN_DEVICE_FUNC plain_array(constructor_without_unaligned_array_assert) {}
0164 };
0165
0166 struct plain_array_helper {
0167 template<typename T, int Size, int MatrixOrArrayOptions, int Alignment>
0168 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0169 static void copy(const plain_array<T, Size, MatrixOrArrayOptions, Alignment>& src, const Eigen::Index size,
0170 plain_array<T, Size, MatrixOrArrayOptions, Alignment>& dst) {
0171 smart_copy(src.array, src.array + size, dst.array);
0172 }
0173
0174 template<typename T, int Size, int MatrixOrArrayOptions, int Alignment>
0175 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0176 static void swap(plain_array<T, Size, MatrixOrArrayOptions, Alignment>& a, const Eigen::Index a_size,
0177 plain_array<T, Size, MatrixOrArrayOptions, Alignment>& b, const Eigen::Index b_size) {
0178 if (a_size < b_size) {
0179 std::swap_ranges(b.array, b.array + a_size, a.array);
0180 smart_move(b.array + a_size, b.array + b_size, a.array + a_size);
0181 } else if (a_size > b_size) {
0182 std::swap_ranges(a.array, a.array + b_size, b.array);
0183 smart_move(a.array + b_size, a.array + a_size, b.array + b_size);
0184 } else {
0185 std::swap_ranges(a.array, a.array + a_size, b.array);
0186 }
0187 }
0188 };
0189
0190 }
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204 template<typename T, int Size, int _Rows, int _Cols, int _Options> class DenseStorage;
0205
0206
0207 template<typename T, int Size, int _Rows, int _Cols, int _Options> class DenseStorage
0208 {
0209 internal::plain_array<T,Size,_Options> m_data;
0210 public:
0211 EIGEN_DEVICE_FUNC DenseStorage() {
0212 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = Size)
0213 }
0214 EIGEN_DEVICE_FUNC
0215 explicit DenseStorage(internal::constructor_without_unaligned_array_assert)
0216 : m_data(internal::constructor_without_unaligned_array_assert()) {}
0217 #if !EIGEN_HAS_CXX11 || defined(EIGEN_DENSE_STORAGE_CTOR_PLUGIN)
0218 EIGEN_DEVICE_FUNC
0219 DenseStorage(const DenseStorage& other) : m_data(other.m_data) {
0220 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = Size)
0221 }
0222 #else
0223 EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage&) = default;
0224 #endif
0225 #if !EIGEN_HAS_CXX11
0226 EIGEN_DEVICE_FUNC
0227 DenseStorage& operator=(const DenseStorage& other)
0228 {
0229 if (this != &other) m_data = other.m_data;
0230 return *this;
0231 }
0232 #else
0233 EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage&) = default;
0234 #endif
0235 #if EIGEN_HAS_RVALUE_REFERENCES
0236 #if !EIGEN_HAS_CXX11
0237 EIGEN_DEVICE_FUNC DenseStorage(DenseStorage&& other) EIGEN_NOEXCEPT
0238 : m_data(std::move(other.m_data))
0239 {
0240 }
0241 EIGEN_DEVICE_FUNC DenseStorage& operator=(DenseStorage&& other) EIGEN_NOEXCEPT
0242 {
0243 if (this != &other)
0244 m_data = std::move(other.m_data);
0245 return *this;
0246 }
0247 #else
0248 EIGEN_DEVICE_FUNC DenseStorage(DenseStorage&&) = default;
0249 EIGEN_DEVICE_FUNC DenseStorage& operator=(DenseStorage&&) = default;
0250 #endif
0251 #endif
0252 EIGEN_DEVICE_FUNC DenseStorage(Index size, Index rows, Index cols) {
0253 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
0254 eigen_internal_assert(size==rows*cols && rows==_Rows && cols==_Cols);
0255 EIGEN_UNUSED_VARIABLE(size);
0256 EIGEN_UNUSED_VARIABLE(rows);
0257 EIGEN_UNUSED_VARIABLE(cols);
0258 }
0259 EIGEN_DEVICE_FUNC void swap(DenseStorage& other) {
0260 numext::swap(m_data, other.m_data);
0261 }
0262 EIGEN_DEVICE_FUNC static EIGEN_CONSTEXPR Index rows(void) EIGEN_NOEXCEPT {return _Rows;}
0263 EIGEN_DEVICE_FUNC static EIGEN_CONSTEXPR Index cols(void) EIGEN_NOEXCEPT {return _Cols;}
0264 EIGEN_DEVICE_FUNC void conservativeResize(Index,Index,Index) {}
0265 EIGEN_DEVICE_FUNC void resize(Index,Index,Index) {}
0266 EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; }
0267 EIGEN_DEVICE_FUNC T *data() { return m_data.array; }
0268 };
0269
0270
0271 template<typename T, int _Rows, int _Cols, int _Options> class DenseStorage<T, 0, _Rows, _Cols, _Options>
0272 {
0273 public:
0274 EIGEN_DEVICE_FUNC DenseStorage() {}
0275 EIGEN_DEVICE_FUNC explicit DenseStorage(internal::constructor_without_unaligned_array_assert) {}
0276 EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage&) {}
0277 EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage&) { return *this; }
0278 EIGEN_DEVICE_FUNC DenseStorage(Index,Index,Index) {}
0279 EIGEN_DEVICE_FUNC void swap(DenseStorage& ) {}
0280 EIGEN_DEVICE_FUNC static EIGEN_CONSTEXPR Index rows(void) EIGEN_NOEXCEPT {return _Rows;}
0281 EIGEN_DEVICE_FUNC static EIGEN_CONSTEXPR Index cols(void) EIGEN_NOEXCEPT {return _Cols;}
0282 EIGEN_DEVICE_FUNC void conservativeResize(Index,Index,Index) {}
0283 EIGEN_DEVICE_FUNC void resize(Index,Index,Index) {}
0284 EIGEN_DEVICE_FUNC const T *data() const { return 0; }
0285 EIGEN_DEVICE_FUNC T *data() { return 0; }
0286 };
0287
0288
0289 template<typename T, int _Options> class DenseStorage<T, 0, Dynamic, Dynamic, _Options>
0290 : public DenseStorage<T, 0, 0, 0, _Options> { };
0291
0292 template<typename T, int _Rows, int _Options> class DenseStorage<T, 0, _Rows, Dynamic, _Options>
0293 : public DenseStorage<T, 0, 0, 0, _Options> { };
0294
0295 template<typename T, int _Cols, int _Options> class DenseStorage<T, 0, Dynamic, _Cols, _Options>
0296 : public DenseStorage<T, 0, 0, 0, _Options> { };
0297
0298
0299 template<typename T, int Size, int _Options> class DenseStorage<T, Size, Dynamic, Dynamic, _Options>
0300 {
0301 internal::plain_array<T,Size,_Options> m_data;
0302 Index m_rows;
0303 Index m_cols;
0304 public:
0305 EIGEN_DEVICE_FUNC DenseStorage() : m_rows(0), m_cols(0) {}
0306 EIGEN_DEVICE_FUNC explicit DenseStorage(internal::constructor_without_unaligned_array_assert)
0307 : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0), m_cols(0) {}
0308 EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other)
0309 : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(other.m_rows), m_cols(other.m_cols)
0310 {
0311 internal::plain_array_helper::copy(other.m_data, m_rows * m_cols, m_data);
0312 }
0313 EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other)
0314 {
0315 if (this != &other)
0316 {
0317 m_rows = other.m_rows;
0318 m_cols = other.m_cols;
0319 internal::plain_array_helper::copy(other.m_data, m_rows * m_cols, m_data);
0320 }
0321 return *this;
0322 }
0323 EIGEN_DEVICE_FUNC DenseStorage(Index, Index rows, Index cols) : m_rows(rows), m_cols(cols) {}
0324 EIGEN_DEVICE_FUNC void swap(DenseStorage& other)
0325 {
0326 internal::plain_array_helper::swap(m_data, m_rows * m_cols, other.m_data, other.m_rows * other.m_cols);
0327 numext::swap(m_rows,other.m_rows);
0328 numext::swap(m_cols,other.m_cols);
0329 }
0330 EIGEN_DEVICE_FUNC Index rows() const {return m_rows;}
0331 EIGEN_DEVICE_FUNC Index cols() const {return m_cols;}
0332 EIGEN_DEVICE_FUNC void conservativeResize(Index, Index rows, Index cols) { m_rows = rows; m_cols = cols; }
0333 EIGEN_DEVICE_FUNC void resize(Index, Index rows, Index cols) { m_rows = rows; m_cols = cols; }
0334 EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; }
0335 EIGEN_DEVICE_FUNC T *data() { return m_data.array; }
0336 };
0337
0338
0339 template<typename T, int Size, int _Cols, int _Options> class DenseStorage<T, Size, Dynamic, _Cols, _Options>
0340 {
0341 internal::plain_array<T,Size,_Options> m_data;
0342 Index m_rows;
0343 public:
0344 EIGEN_DEVICE_FUNC DenseStorage() : m_rows(0) {}
0345 EIGEN_DEVICE_FUNC explicit DenseStorage(internal::constructor_without_unaligned_array_assert)
0346 : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0) {}
0347 EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other)
0348 : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(other.m_rows)
0349 {
0350 internal::plain_array_helper::copy(other.m_data, m_rows * _Cols, m_data);
0351 }
0352
0353 EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other)
0354 {
0355 if (this != &other)
0356 {
0357 m_rows = other.m_rows;
0358 internal::plain_array_helper::copy(other.m_data, m_rows * _Cols, m_data);
0359 }
0360 return *this;
0361 }
0362 EIGEN_DEVICE_FUNC DenseStorage(Index, Index rows, Index) : m_rows(rows) {}
0363 EIGEN_DEVICE_FUNC void swap(DenseStorage& other)
0364 {
0365 internal::plain_array_helper::swap(m_data, m_rows * _Cols, other.m_data, other.m_rows * _Cols);
0366 numext::swap(m_rows, other.m_rows);
0367 }
0368 EIGEN_DEVICE_FUNC Index rows(void) const EIGEN_NOEXCEPT {return m_rows;}
0369 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols(void) const EIGEN_NOEXCEPT {return _Cols;}
0370 EIGEN_DEVICE_FUNC void conservativeResize(Index, Index rows, Index) { m_rows = rows; }
0371 EIGEN_DEVICE_FUNC void resize(Index, Index rows, Index) { m_rows = rows; }
0372 EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; }
0373 EIGEN_DEVICE_FUNC T *data() { return m_data.array; }
0374 };
0375
0376
0377 template<typename T, int Size, int _Rows, int _Options> class DenseStorage<T, Size, _Rows, Dynamic, _Options>
0378 {
0379 internal::plain_array<T,Size,_Options> m_data;
0380 Index m_cols;
0381 public:
0382 EIGEN_DEVICE_FUNC DenseStorage() : m_cols(0) {}
0383 EIGEN_DEVICE_FUNC explicit DenseStorage(internal::constructor_without_unaligned_array_assert)
0384 : m_data(internal::constructor_without_unaligned_array_assert()), m_cols(0) {}
0385 EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other)
0386 : m_data(internal::constructor_without_unaligned_array_assert()), m_cols(other.m_cols)
0387 {
0388 internal::plain_array_helper::copy(other.m_data, _Rows * m_cols, m_data);
0389 }
0390 EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other)
0391 {
0392 if (this != &other)
0393 {
0394 m_cols = other.m_cols;
0395 internal::plain_array_helper::copy(other.m_data, _Rows * m_cols, m_data);
0396 }
0397 return *this;
0398 }
0399 EIGEN_DEVICE_FUNC DenseStorage(Index, Index, Index cols) : m_cols(cols) {}
0400 EIGEN_DEVICE_FUNC void swap(DenseStorage& other) {
0401 internal::plain_array_helper::swap(m_data, _Rows * m_cols, other.m_data, _Rows * other.m_cols);
0402 numext::swap(m_cols, other.m_cols);
0403 }
0404 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows(void) const EIGEN_NOEXCEPT {return _Rows;}
0405 EIGEN_DEVICE_FUNC Index cols(void) const EIGEN_NOEXCEPT {return m_cols;}
0406 EIGEN_DEVICE_FUNC void conservativeResize(Index, Index, Index cols) { m_cols = cols; }
0407 EIGEN_DEVICE_FUNC void resize(Index, Index, Index cols) { m_cols = cols; }
0408 EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; }
0409 EIGEN_DEVICE_FUNC T *data() { return m_data.array; }
0410 };
0411
0412
0413 template<typename T, int _Options> class DenseStorage<T, Dynamic, Dynamic, Dynamic, _Options>
0414 {
0415 T *m_data;
0416 Index m_rows;
0417 Index m_cols;
0418 public:
0419 EIGEN_DEVICE_FUNC DenseStorage() : m_data(0), m_rows(0), m_cols(0) {}
0420 EIGEN_DEVICE_FUNC explicit DenseStorage(internal::constructor_without_unaligned_array_assert)
0421 : m_data(0), m_rows(0), m_cols(0) {}
0422 EIGEN_DEVICE_FUNC DenseStorage(Index size, Index rows, Index cols)
0423 : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size)), m_rows(rows), m_cols(cols)
0424 {
0425 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
0426 eigen_internal_assert(size==rows*cols && rows>=0 && cols >=0);
0427 }
0428 EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other)
0429 : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(other.m_rows*other.m_cols))
0430 , m_rows(other.m_rows)
0431 , m_cols(other.m_cols)
0432 {
0433 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = m_rows*m_cols)
0434 internal::smart_copy(other.m_data, other.m_data+other.m_rows*other.m_cols, m_data);
0435 }
0436 EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other)
0437 {
0438 if (this != &other)
0439 {
0440 DenseStorage tmp(other);
0441 this->swap(tmp);
0442 }
0443 return *this;
0444 }
0445 #if EIGEN_HAS_RVALUE_REFERENCES
0446 EIGEN_DEVICE_FUNC
0447 DenseStorage(DenseStorage&& other) EIGEN_NOEXCEPT
0448 : m_data(std::move(other.m_data))
0449 , m_rows(std::move(other.m_rows))
0450 , m_cols(std::move(other.m_cols))
0451 {
0452 other.m_data = nullptr;
0453 other.m_rows = 0;
0454 other.m_cols = 0;
0455 }
0456 EIGEN_DEVICE_FUNC
0457 DenseStorage& operator=(DenseStorage&& other) EIGEN_NOEXCEPT
0458 {
0459 numext::swap(m_data, other.m_data);
0460 numext::swap(m_rows, other.m_rows);
0461 numext::swap(m_cols, other.m_cols);
0462 return *this;
0463 }
0464 #endif
0465 EIGEN_DEVICE_FUNC ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols); }
0466 EIGEN_DEVICE_FUNC void swap(DenseStorage& other)
0467 {
0468 numext::swap(m_data,other.m_data);
0469 numext::swap(m_rows,other.m_rows);
0470 numext::swap(m_cols,other.m_cols);
0471 }
0472 EIGEN_DEVICE_FUNC Index rows(void) const EIGEN_NOEXCEPT {return m_rows;}
0473 EIGEN_DEVICE_FUNC Index cols(void) const EIGEN_NOEXCEPT {return m_cols;}
0474 void conservativeResize(Index size, Index rows, Index cols)
0475 {
0476 m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, m_rows*m_cols);
0477 m_rows = rows;
0478 m_cols = cols;
0479 }
0480 EIGEN_DEVICE_FUNC void resize(Index size, Index rows, Index cols)
0481 {
0482 if(size != m_rows*m_cols)
0483 {
0484 internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols);
0485 if (size>0)
0486 m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size);
0487 else
0488 m_data = 0;
0489 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
0490 }
0491 m_rows = rows;
0492 m_cols = cols;
0493 }
0494 EIGEN_DEVICE_FUNC const T *data() const { return m_data; }
0495 EIGEN_DEVICE_FUNC T *data() { return m_data; }
0496 };
0497
0498
0499 template<typename T, int _Rows, int _Options> class DenseStorage<T, Dynamic, _Rows, Dynamic, _Options>
0500 {
0501 T *m_data;
0502 Index m_cols;
0503 public:
0504 EIGEN_DEVICE_FUNC DenseStorage() : m_data(0), m_cols(0) {}
0505 explicit DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_cols(0) {}
0506 EIGEN_DEVICE_FUNC DenseStorage(Index size, Index rows, Index cols) : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size)), m_cols(cols)
0507 {
0508 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
0509 eigen_internal_assert(size==rows*cols && rows==_Rows && cols >=0);
0510 EIGEN_UNUSED_VARIABLE(rows);
0511 }
0512 EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other)
0513 : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(_Rows*other.m_cols))
0514 , m_cols(other.m_cols)
0515 {
0516 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = m_cols*_Rows)
0517 internal::smart_copy(other.m_data, other.m_data+_Rows*m_cols, m_data);
0518 }
0519 EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other)
0520 {
0521 if (this != &other)
0522 {
0523 DenseStorage tmp(other);
0524 this->swap(tmp);
0525 }
0526 return *this;
0527 }
0528 #if EIGEN_HAS_RVALUE_REFERENCES
0529 EIGEN_DEVICE_FUNC
0530 DenseStorage(DenseStorage&& other) EIGEN_NOEXCEPT
0531 : m_data(std::move(other.m_data))
0532 , m_cols(std::move(other.m_cols))
0533 {
0534 other.m_data = nullptr;
0535 other.m_cols = 0;
0536 }
0537 EIGEN_DEVICE_FUNC
0538 DenseStorage& operator=(DenseStorage&& other) EIGEN_NOEXCEPT
0539 {
0540 numext::swap(m_data, other.m_data);
0541 numext::swap(m_cols, other.m_cols);
0542 return *this;
0543 }
0544 #endif
0545 EIGEN_DEVICE_FUNC ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols); }
0546 EIGEN_DEVICE_FUNC void swap(DenseStorage& other) {
0547 numext::swap(m_data,other.m_data);
0548 numext::swap(m_cols,other.m_cols);
0549 }
0550 EIGEN_DEVICE_FUNC static EIGEN_CONSTEXPR Index rows(void) EIGEN_NOEXCEPT {return _Rows;}
0551 EIGEN_DEVICE_FUNC Index cols(void) const EIGEN_NOEXCEPT {return m_cols;}
0552 EIGEN_DEVICE_FUNC void conservativeResize(Index size, Index, Index cols)
0553 {
0554 m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, _Rows*m_cols);
0555 m_cols = cols;
0556 }
0557 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index size, Index, Index cols)
0558 {
0559 if(size != _Rows*m_cols)
0560 {
0561 internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols);
0562 if (size>0)
0563 m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size);
0564 else
0565 m_data = 0;
0566 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
0567 }
0568 m_cols = cols;
0569 }
0570 EIGEN_DEVICE_FUNC const T *data() const { return m_data; }
0571 EIGEN_DEVICE_FUNC T *data() { return m_data; }
0572 };
0573
0574
0575 template<typename T, int _Cols, int _Options> class DenseStorage<T, Dynamic, Dynamic, _Cols, _Options>
0576 {
0577 T *m_data;
0578 Index m_rows;
0579 public:
0580 EIGEN_DEVICE_FUNC DenseStorage() : m_data(0), m_rows(0) {}
0581 explicit DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_rows(0) {}
0582 EIGEN_DEVICE_FUNC DenseStorage(Index size, Index rows, Index cols) : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size)), m_rows(rows)
0583 {
0584 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
0585 eigen_internal_assert(size==rows*cols && rows>=0 && cols == _Cols);
0586 EIGEN_UNUSED_VARIABLE(cols);
0587 }
0588 EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other)
0589 : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(other.m_rows*_Cols))
0590 , m_rows(other.m_rows)
0591 {
0592 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = m_rows*_Cols)
0593 internal::smart_copy(other.m_data, other.m_data+other.m_rows*_Cols, m_data);
0594 }
0595 EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other)
0596 {
0597 if (this != &other)
0598 {
0599 DenseStorage tmp(other);
0600 this->swap(tmp);
0601 }
0602 return *this;
0603 }
0604 #if EIGEN_HAS_RVALUE_REFERENCES
0605 EIGEN_DEVICE_FUNC
0606 DenseStorage(DenseStorage&& other) EIGEN_NOEXCEPT
0607 : m_data(std::move(other.m_data))
0608 , m_rows(std::move(other.m_rows))
0609 {
0610 other.m_data = nullptr;
0611 other.m_rows = 0;
0612 }
0613 EIGEN_DEVICE_FUNC
0614 DenseStorage& operator=(DenseStorage&& other) EIGEN_NOEXCEPT
0615 {
0616 numext::swap(m_data, other.m_data);
0617 numext::swap(m_rows, other.m_rows);
0618 return *this;
0619 }
0620 #endif
0621 EIGEN_DEVICE_FUNC ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows); }
0622 EIGEN_DEVICE_FUNC void swap(DenseStorage& other) {
0623 numext::swap(m_data,other.m_data);
0624 numext::swap(m_rows,other.m_rows);
0625 }
0626 EIGEN_DEVICE_FUNC Index rows(void) const EIGEN_NOEXCEPT {return m_rows;}
0627 EIGEN_DEVICE_FUNC static EIGEN_CONSTEXPR Index cols(void) {return _Cols;}
0628 void conservativeResize(Index size, Index rows, Index)
0629 {
0630 m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, m_rows*_Cols);
0631 m_rows = rows;
0632 }
0633 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index size, Index rows, Index)
0634 {
0635 if(size != m_rows*_Cols)
0636 {
0637 internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows);
0638 if (size>0)
0639 m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size);
0640 else
0641 m_data = 0;
0642 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
0643 }
0644 m_rows = rows;
0645 }
0646 EIGEN_DEVICE_FUNC const T *data() const { return m_data; }
0647 EIGEN_DEVICE_FUNC T *data() { return m_data; }
0648 };
0649
0650 }
0651
0652 #endif