Path Tracer
DenseStorage.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2006-2009 Benoit Jacob <jacob.benoit.1@gmail.com>
6 // Copyright (C) 2010-2013 Hauke Heibel <hauke.heibel@gmail.com>
7 //
8 // This Source Code Form is subject to the terms of the Mozilla
9 // Public License v. 2.0. If a copy of the MPL was not distributed
10 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 
12 #ifndef EIGEN_MATRIXSTORAGE_H
13 #define EIGEN_MATRIXSTORAGE_H
14 
15 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
16  #define EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(X) X; EIGEN_DENSE_STORAGE_CTOR_PLUGIN;
17 #else
18  #define EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(X)
19 #endif
20 
21 namespace Eigen {
22 
23 namespace internal {
24 
26 
27 template<typename T, int Size>
28 EIGEN_DEVICE_FUNC
29 void check_static_allocation_size()
30 {
31  // if EIGEN_STACK_ALLOCATION_LIMIT is defined to 0, then no limit
32  #if EIGEN_STACK_ALLOCATION_LIMIT
33  EIGEN_STATIC_ASSERT(Size * sizeof(T) <= EIGEN_STACK_ALLOCATION_LIMIT, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG);
34  #endif
35 }
36 
41 template <typename T, int Size, int MatrixOrArrayOptions,
42  int Alignment = (MatrixOrArrayOptions&DontAlign) ? 0
43  : compute_default_alignment<T,Size>::value >
45 {
46  T array[Size];
47 
48  EIGEN_DEVICE_FUNC
49  plain_array()
50  {
51  check_static_allocation_size<T,Size>();
52  }
53 
54  EIGEN_DEVICE_FUNC
56  {
57  check_static_allocation_size<T,Size>();
58  }
59 };
60 
61 #if defined(EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT)
62  #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask)
63 #elif EIGEN_GNUC_AT_LEAST(4,7)
64  // GCC 4.7 is too aggressive in its optimizations and remove the alignment test based on the fact the array is declared to be aligned.
65  // See this bug report: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53900
66  // Hiding the origin of the array pointer behind a function argument seems to do the trick even if the function is inlined:
67  template<typename PtrType>
68  EIGEN_ALWAYS_INLINE PtrType eigen_unaligned_array_assert_workaround_gcc47(PtrType array) { return array; }
69  #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) \
70  eigen_assert((internal::UIntPtr(eigen_unaligned_array_assert_workaround_gcc47(array)) & (sizemask)) == 0 \
71  && "this assertion is explained here: " \
72  "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" \
73  " **** READ THIS WEB PAGE !!! ****");
74 #else
75  #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) \
76  eigen_assert((internal::UIntPtr(array) & (sizemask)) == 0 \
77  && "this assertion is explained here: " \
78  "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" \
79  " **** READ THIS WEB PAGE !!! ****");
80 #endif
81 
82 template <typename T, int Size, int MatrixOrArrayOptions>
84 {
85  EIGEN_ALIGN_TO_BOUNDARY(8) T array[Size];
86 
87  EIGEN_DEVICE_FUNC
88  plain_array()
89  {
90  EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(7);
91  check_static_allocation_size<T,Size>();
92  }
93 
94  EIGEN_DEVICE_FUNC
96  {
97  check_static_allocation_size<T,Size>();
98  }
99 };
100 
101 template <typename T, int Size, int MatrixOrArrayOptions>
103 {
104  EIGEN_ALIGN_TO_BOUNDARY(16) T array[Size];
105 
106  EIGEN_DEVICE_FUNC
107  plain_array()
108  {
109  EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(15);
110  check_static_allocation_size<T,Size>();
111  }
112 
113  EIGEN_DEVICE_FUNC
115  {
116  check_static_allocation_size<T,Size>();
117  }
118 };
119 
120 template <typename T, int Size, int MatrixOrArrayOptions>
122 {
123  EIGEN_ALIGN_TO_BOUNDARY(32) T array[Size];
124 
125  EIGEN_DEVICE_FUNC
126  plain_array()
127  {
128  EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(31);
129  check_static_allocation_size<T,Size>();
130  }
131 
132  EIGEN_DEVICE_FUNC
134  {
135  check_static_allocation_size<T,Size>();
136  }
137 };
138 
139 template <typename T, int Size, int MatrixOrArrayOptions>
141 {
142  EIGEN_ALIGN_TO_BOUNDARY(64) T array[Size];
143 
144  EIGEN_DEVICE_FUNC
145  plain_array()
146  {
147  EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(63);
148  check_static_allocation_size<T,Size>();
149  }
150 
151  EIGEN_DEVICE_FUNC
153  {
154  check_static_allocation_size<T,Size>();
155  }
156 };
157 
158 template <typename T, int MatrixOrArrayOptions, int Alignment>
160 {
161  T array[1];
162  EIGEN_DEVICE_FUNC plain_array() {}
164 };
165 
166 } // end namespace internal
167 
180 template<typename T, int Size, int _Rows, int _Cols, int _Options> class DenseStorage;
181 
182 // purely fixed-size matrix
183 template<typename T, int Size, int _Rows, int _Cols, int _Options> class DenseStorage
184 {
186  public:
187  EIGEN_DEVICE_FUNC DenseStorage() {
188  EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = Size)
189  }
190  EIGEN_DEVICE_FUNC
193  EIGEN_DEVICE_FUNC
194  DenseStorage(const DenseStorage& other) : m_data(other.m_data) {
195  EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = Size)
196  }
197  EIGEN_DEVICE_FUNC
198  DenseStorage& operator=(const DenseStorage& other)
199  {
200  if (this != &other) m_data = other.m_data;
201  return *this;
202  }
203 #if EIGEN_HAS_RVALUE_REFERENCES
204  EIGEN_DEVICE_FUNC DenseStorage(DenseStorage&& other) EIGEN_NOEXCEPT
205  : m_data(std::move(other.m_data))
206  {
207  }
208  EIGEN_DEVICE_FUNC DenseStorage& operator=(DenseStorage&& other) EIGEN_NOEXCEPT
209  {
210  if (this != &other)
211  m_data = std::move(other.m_data);
212  return *this;
213  }
214 #endif
215  EIGEN_DEVICE_FUNC DenseStorage(Index size, Index rows, Index cols) {
216  EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
217  eigen_internal_assert(size==rows*cols && rows==_Rows && cols==_Cols);
218  EIGEN_UNUSED_VARIABLE(size);
219  EIGEN_UNUSED_VARIABLE(rows);
220  EIGEN_UNUSED_VARIABLE(cols);
221  }
222  EIGEN_DEVICE_FUNC void swap(DenseStorage& other) {
223  numext::swap(m_data, other.m_data);
224  }
225  EIGEN_DEVICE_FUNC static Index rows(void) {return _Rows;}
226  EIGEN_DEVICE_FUNC static Index cols(void) {return _Cols;}
227  EIGEN_DEVICE_FUNC void conservativeResize(Index,Index,Index) {}
228  EIGEN_DEVICE_FUNC void resize(Index,Index,Index) {}
229  EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; }
230  EIGEN_DEVICE_FUNC T *data() { return m_data.array; }
231 };
232 
233 // null matrix
234 template<typename T, int _Rows, int _Cols, int _Options> class DenseStorage<T, 0, _Rows, _Cols, _Options>
235 {
236  public:
237  EIGEN_DEVICE_FUNC DenseStorage() {}
239  EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage&) {}
240  EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage&) { return *this; }
241  EIGEN_DEVICE_FUNC DenseStorage(Index,Index,Index) {}
242  EIGEN_DEVICE_FUNC void swap(DenseStorage& ) {}
243  EIGEN_DEVICE_FUNC static Index rows(void) {return _Rows;}
244  EIGEN_DEVICE_FUNC static Index cols(void) {return _Cols;}
245  EIGEN_DEVICE_FUNC void conservativeResize(Index,Index,Index) {}
246  EIGEN_DEVICE_FUNC void resize(Index,Index,Index) {}
247  EIGEN_DEVICE_FUNC const T *data() const { return 0; }
248  EIGEN_DEVICE_FUNC T *data() { return 0; }
249 };
250 
251 // more specializations for null matrices; these are necessary to resolve ambiguities
252 template<typename T, int _Options> class DenseStorage<T, 0, Dynamic, Dynamic, _Options>
254 
255 template<typename T, int _Rows, int _Options> class DenseStorage<T, 0, _Rows, Dynamic, _Options>
257 
258 template<typename T, int _Cols, int _Options> class DenseStorage<T, 0, Dynamic, _Cols, _Options>
260 
261 // dynamic-size matrix with fixed-size storage
262 template<typename T, int Size, int _Options> class DenseStorage<T, Size, Dynamic, Dynamic, _Options>
263 {
265  Index m_rows;
266  Index m_cols;
267  public:
268  EIGEN_DEVICE_FUNC DenseStorage() : m_rows(0), m_cols(0) {}
270  : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0), m_cols(0) {}
271  EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_rows(other.m_rows), m_cols(other.m_cols) {}
272  EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other)
273  {
274  if (this != &other)
275  {
276  m_data = other.m_data;
277  m_rows = other.m_rows;
278  m_cols = other.m_cols;
279  }
280  return *this;
281  }
282  EIGEN_DEVICE_FUNC DenseStorage(Index, Index rows, Index cols) : m_rows(rows), m_cols(cols) {}
283  EIGEN_DEVICE_FUNC void swap(DenseStorage& other)
284  {
285  numext::swap(m_data,other.m_data);
286  numext::swap(m_rows,other.m_rows);
287  numext::swap(m_cols,other.m_cols);
288  }
289  EIGEN_DEVICE_FUNC Index rows() const {return m_rows;}
290  EIGEN_DEVICE_FUNC Index cols() const {return m_cols;}
291  EIGEN_DEVICE_FUNC void conservativeResize(Index, Index rows, Index cols) { m_rows = rows; m_cols = cols; }
292  EIGEN_DEVICE_FUNC void resize(Index, Index rows, Index cols) { m_rows = rows; m_cols = cols; }
293  EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; }
294  EIGEN_DEVICE_FUNC T *data() { return m_data.array; }
295 };
296 
297 // dynamic-size matrix with fixed-size storage and fixed width
298 template<typename T, int Size, int _Cols, int _Options> class DenseStorage<T, Size, Dynamic, _Cols, _Options>
299 {
301  Index m_rows;
302  public:
303  EIGEN_DEVICE_FUNC DenseStorage() : m_rows(0) {}
306  EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_rows(other.m_rows) {}
307  EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other)
308  {
309  if (this != &other)
310  {
311  m_data = other.m_data;
312  m_rows = other.m_rows;
313  }
314  return *this;
315  }
316  EIGEN_DEVICE_FUNC DenseStorage(Index, Index rows, Index) : m_rows(rows) {}
317  EIGEN_DEVICE_FUNC void swap(DenseStorage& other)
318  {
319  numext::swap(m_data,other.m_data);
320  numext::swap(m_rows,other.m_rows);
321  }
322  EIGEN_DEVICE_FUNC Index rows(void) const {return m_rows;}
323  EIGEN_DEVICE_FUNC Index cols(void) const {return _Cols;}
324  EIGEN_DEVICE_FUNC void conservativeResize(Index, Index rows, Index) { m_rows = rows; }
325  EIGEN_DEVICE_FUNC void resize(Index, Index rows, Index) { m_rows = rows; }
326  EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; }
327  EIGEN_DEVICE_FUNC T *data() { return m_data.array; }
328 };
329 
330 // dynamic-size matrix with fixed-size storage and fixed height
331 template<typename T, int Size, int _Rows, int _Options> class DenseStorage<T, Size, _Rows, Dynamic, _Options>
332 {
334  Index m_cols;
335  public:
336  EIGEN_DEVICE_FUNC DenseStorage() : m_cols(0) {}
339  EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_cols(other.m_cols) {}
340  EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other)
341  {
342  if (this != &other)
343  {
344  m_data = other.m_data;
345  m_cols = other.m_cols;
346  }
347  return *this;
348  }
349  EIGEN_DEVICE_FUNC DenseStorage(Index, Index, Index cols) : m_cols(cols) {}
350  EIGEN_DEVICE_FUNC void swap(DenseStorage& other) {
351  numext::swap(m_data,other.m_data);
352  numext::swap(m_cols,other.m_cols);
353  }
354  EIGEN_DEVICE_FUNC Index rows(void) const {return _Rows;}
355  EIGEN_DEVICE_FUNC Index cols(void) const {return m_cols;}
356  EIGEN_DEVICE_FUNC void conservativeResize(Index, Index, Index cols) { m_cols = cols; }
357  EIGEN_DEVICE_FUNC void resize(Index, Index, Index cols) { m_cols = cols; }
358  EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; }
359  EIGEN_DEVICE_FUNC T *data() { return m_data.array; }
360 };
361 
362 // purely dynamic matrix.
363 template<typename T, int _Options> class DenseStorage<T, Dynamic, Dynamic, Dynamic, _Options>
364 {
365  T *m_data;
366  Index m_rows;
367  Index m_cols;
368  public:
369  EIGEN_DEVICE_FUNC DenseStorage() : m_data(0), m_rows(0), m_cols(0) {}
371  : m_data(0), m_rows(0), m_cols(0) {}
372  EIGEN_DEVICE_FUNC DenseStorage(Index size, Index rows, Index cols)
373  : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size)), m_rows(rows), m_cols(cols)
374  {
375  EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
376  eigen_internal_assert(size==rows*cols && rows>=0 && cols >=0);
377  }
378  EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other)
379  : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(other.m_rows*other.m_cols))
380  , m_rows(other.m_rows)
381  , m_cols(other.m_cols)
382  {
383  EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = m_rows*m_cols)
384  internal::smart_copy(other.m_data, other.m_data+other.m_rows*other.m_cols, m_data);
385  }
386  EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other)
387  {
388  if (this != &other)
389  {
390  DenseStorage tmp(other);
391  this->swap(tmp);
392  }
393  return *this;
394  }
395 #if EIGEN_HAS_RVALUE_REFERENCES
396  EIGEN_DEVICE_FUNC
397  DenseStorage(DenseStorage&& other) EIGEN_NOEXCEPT
398  : m_data(std::move(other.m_data))
399  , m_rows(std::move(other.m_rows))
400  , m_cols(std::move(other.m_cols))
401  {
402  other.m_data = nullptr;
403  other.m_rows = 0;
404  other.m_cols = 0;
405  }
406  EIGEN_DEVICE_FUNC
407  DenseStorage& operator=(DenseStorage&& other) EIGEN_NOEXCEPT
408  {
409  numext::swap(m_data, other.m_data);
410  numext::swap(m_rows, other.m_rows);
411  numext::swap(m_cols, other.m_cols);
412  return *this;
413  }
414 #endif
415  EIGEN_DEVICE_FUNC ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols); }
416  EIGEN_DEVICE_FUNC void swap(DenseStorage& other)
417  {
418  numext::swap(m_data,other.m_data);
419  numext::swap(m_rows,other.m_rows);
420  numext::swap(m_cols,other.m_cols);
421  }
422  EIGEN_DEVICE_FUNC Index rows(void) const {return m_rows;}
423  EIGEN_DEVICE_FUNC Index cols(void) const {return m_cols;}
424  void conservativeResize(Index size, Index rows, Index cols)
425  {
426  m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, m_rows*m_cols);
427  m_rows = rows;
428  m_cols = cols;
429  }
430  EIGEN_DEVICE_FUNC void resize(Index size, Index rows, Index cols)
431  {
432  if(size != m_rows*m_cols)
433  {
434  internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols);
435  if (size>0) // >0 and not simply !=0 to let the compiler knows that size cannot be negative
436  m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size);
437  else
438  m_data = 0;
439  EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
440  }
441  m_rows = rows;
442  m_cols = cols;
443  }
444  EIGEN_DEVICE_FUNC const T *data() const { return m_data; }
445  EIGEN_DEVICE_FUNC T *data() { return m_data; }
446 };
447 
448 // matrix with dynamic width and fixed height (so that matrix has dynamic size).
449 template<typename T, int _Rows, int _Options> class DenseStorage<T, Dynamic, _Rows, Dynamic, _Options>
450 {
451  T *m_data;
452  Index m_cols;
453  public:
454  EIGEN_DEVICE_FUNC DenseStorage() : m_data(0), m_cols(0) {}
455  explicit DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_cols(0) {}
456  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)
457  {
458  EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
459  eigen_internal_assert(size==rows*cols && rows==_Rows && cols >=0);
460  EIGEN_UNUSED_VARIABLE(rows);
461  }
462  EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other)
463  : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(_Rows*other.m_cols))
464  , m_cols(other.m_cols)
465  {
466  EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = m_cols*_Rows)
467  internal::smart_copy(other.m_data, other.m_data+_Rows*m_cols, m_data);
468  }
469  EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other)
470  {
471  if (this != &other)
472  {
473  DenseStorage tmp(other);
474  this->swap(tmp);
475  }
476  return *this;
477  }
478 #if EIGEN_HAS_RVALUE_REFERENCES
479  EIGEN_DEVICE_FUNC
480  DenseStorage(DenseStorage&& other) EIGEN_NOEXCEPT
481  : m_data(std::move(other.m_data))
482  , m_cols(std::move(other.m_cols))
483  {
484  other.m_data = nullptr;
485  other.m_cols = 0;
486  }
487  EIGEN_DEVICE_FUNC
488  DenseStorage& operator=(DenseStorage&& other) EIGEN_NOEXCEPT
489  {
490  numext::swap(m_data, other.m_data);
491  numext::swap(m_cols, other.m_cols);
492  return *this;
493  }
494 #endif
495  EIGEN_DEVICE_FUNC ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols); }
496  EIGEN_DEVICE_FUNC void swap(DenseStorage& other) {
497  numext::swap(m_data,other.m_data);
498  numext::swap(m_cols,other.m_cols);
499  }
500  EIGEN_DEVICE_FUNC static Index rows(void) {return _Rows;}
501  EIGEN_DEVICE_FUNC Index cols(void) const {return m_cols;}
502  EIGEN_DEVICE_FUNC void conservativeResize(Index size, Index, Index cols)
503  {
504  m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, _Rows*m_cols);
505  m_cols = cols;
506  }
507  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index size, Index, Index cols)
508  {
509  if(size != _Rows*m_cols)
510  {
511  internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols);
512  if (size>0) // >0 and not simply !=0 to let the compiler knows that size cannot be negative
513  m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size);
514  else
515  m_data = 0;
516  EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
517  }
518  m_cols = cols;
519  }
520  EIGEN_DEVICE_FUNC const T *data() const { return m_data; }
521  EIGEN_DEVICE_FUNC T *data() { return m_data; }
522 };
523 
524 // matrix with dynamic height and fixed width (so that matrix has dynamic size).
525 template<typename T, int _Cols, int _Options> class DenseStorage<T, Dynamic, Dynamic, _Cols, _Options>
526 {
527  T *m_data;
528  Index m_rows;
529  public:
530  EIGEN_DEVICE_FUNC DenseStorage() : m_data(0), m_rows(0) {}
531  explicit DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_rows(0) {}
532  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)
533  {
534  EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
535  eigen_internal_assert(size==rows*cols && rows>=0 && cols == _Cols);
536  EIGEN_UNUSED_VARIABLE(cols);
537  }
538  EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other)
539  : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(other.m_rows*_Cols))
540  , m_rows(other.m_rows)
541  {
542  EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = m_rows*_Cols)
543  internal::smart_copy(other.m_data, other.m_data+other.m_rows*_Cols, m_data);
544  }
545  EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other)
546  {
547  if (this != &other)
548  {
549  DenseStorage tmp(other);
550  this->swap(tmp);
551  }
552  return *this;
553  }
554 #if EIGEN_HAS_RVALUE_REFERENCES
555  EIGEN_DEVICE_FUNC
556  DenseStorage(DenseStorage&& other) EIGEN_NOEXCEPT
557  : m_data(std::move(other.m_data))
558  , m_rows(std::move(other.m_rows))
559  {
560  other.m_data = nullptr;
561  other.m_rows = 0;
562  }
563  EIGEN_DEVICE_FUNC
564  DenseStorage& operator=(DenseStorage&& other) EIGEN_NOEXCEPT
565  {
566  numext::swap(m_data, other.m_data);
567  numext::swap(m_rows, other.m_rows);
568  return *this;
569  }
570 #endif
571  EIGEN_DEVICE_FUNC ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows); }
572  EIGEN_DEVICE_FUNC void swap(DenseStorage& other) {
573  numext::swap(m_data,other.m_data);
574  numext::swap(m_rows,other.m_rows);
575  }
576  EIGEN_DEVICE_FUNC Index rows(void) const {return m_rows;}
577  EIGEN_DEVICE_FUNC static Index cols(void) {return _Cols;}
578  void conservativeResize(Index size, Index rows, Index)
579  {
580  m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, m_rows*_Cols);
581  m_rows = rows;
582  }
583  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index size, Index rows, Index)
584  {
585  if(size != m_rows*_Cols)
586  {
587  internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows);
588  if (size>0) // >0 and not simply !=0 to let the compiler knows that size cannot be negative
589  m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size);
590  else
591  m_data = 0;
592  EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({})
593  }
594  m_rows = rows;
595  }
596  EIGEN_DEVICE_FUNC const T *data() const { return m_data; }
597  EIGEN_DEVICE_FUNC T *data() { return m_data; }
598 };
599 
600 } // end namespace Eigen
601 
602 #endif // EIGEN_MATRIX_H
Eigen
Namespace containing all symbols from the Eigen library.
Definition: LDLT.h:16
Eigen::internal::plain_array< T, Size, MatrixOrArrayOptions, 16 >
Definition: DenseStorage.h:103
Eigen::internal::constructor_without_unaligned_array_assert
Definition: DenseStorage.h:25
Eigen::DenseStorage
Definition: DenseStorage.h:184
Eigen::DontAlign
@ DontAlign
Definition: Constants.h:324
Eigen::internal::plain_array< T, Size, MatrixOrArrayOptions, 32 >
Definition: DenseStorage.h:122
Eigen::DenseStorage< T, 0, _Rows, _Cols, _Options >
Definition: DenseStorage.h:235
Eigen::DenseStorage< T, Size, Dynamic, _Cols, _Options >
Definition: DenseStorage.h:299
Eigen::internal::plain_array< T, Size, MatrixOrArrayOptions, 8 >
Definition: DenseStorage.h:84
Eigen::DenseStorage< T, Dynamic, Dynamic, _Cols, _Options >
Definition: DenseStorage.h:526
Eigen::DenseStorage< T, Size, Dynamic, Dynamic, _Options >
Definition: DenseStorage.h:263
Eigen::DenseStorage< T, 0, Dynamic, Dynamic, _Options >
Definition: DenseStorage.h:253
Eigen::DenseStorage< T, Dynamic, Dynamic, Dynamic, _Options >
Definition: DenseStorage.h:364
Eigen::DenseStorage< T, Size, _Rows, Dynamic, _Options >
Definition: DenseStorage.h:332
Eigen::DenseStorage< T, 0, _Rows, Dynamic, _Options >
Definition: DenseStorage.h:256
Eigen::internal::plain_array
Definition: DenseStorage.h:45
Eigen::internal::plain_array< T, 0, MatrixOrArrayOptions, Alignment >
Definition: DenseStorage.h:160
Eigen::DenseStorage< T, Dynamic, _Rows, Dynamic, _Options >
Definition: DenseStorage.h:450
Eigen::internal::plain_array< T, Size, MatrixOrArrayOptions, 64 >
Definition: DenseStorage.h:141
Eigen::DenseStorage< T, 0, Dynamic, _Cols, _Options >
Definition: DenseStorage.h:259
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:42