MOAB
4.9.3pre
|
00001 // This file is part of Eigen, a lightweight C++ template library 00002 // for linear algebra. 00003 // 00004 // Copyright (C) 2008 Gael Guennebaud <[email protected]> 00005 // Copyright (C) 2006-2009 Benoit Jacob <[email protected]> 00006 // Copyright (C) 2010-2013 Hauke Heibel <[email protected]> 00007 // 00008 // This Source Code Form is subject to the terms of the Mozilla 00009 // Public License v. 2.0. If a copy of the MPL was not distributed 00010 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 00011 00012 #ifndef EIGEN_MATRIXSTORAGE_H 00013 #define EIGEN_MATRIXSTORAGE_H 00014 00015 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN 00016 #define EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN EIGEN_DENSE_STORAGE_CTOR_PLUGIN; 00017 #else 00018 #define EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN 00019 #endif 00020 00021 namespace Eigen { 00022 00023 namespace internal { 00024 00025 struct constructor_without_unaligned_array_assert {}; 00026 00027 template<typename T, int Size> 00028 EIGEN_DEVICE_FUNC 00029 void check_static_allocation_size() 00030 { 00031 // if EIGEN_STACK_ALLOCATION_LIMIT is defined to 0, then no limit 00032 #if EIGEN_STACK_ALLOCATION_LIMIT 00033 EIGEN_STATIC_ASSERT(Size * sizeof(T) <= EIGEN_STACK_ALLOCATION_LIMIT, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG); 00034 #endif 00035 } 00036 00041 template <typename T, int Size, int MatrixOrArrayOptions, 00042 int Alignment = (MatrixOrArrayOptions&DontAlign) ? 0 00043 : compute_default_alignment<T,Size>::value > 00044 struct plain_array 00045 { 00046 T array[Size]; 00047 00048 EIGEN_DEVICE_FUNC 00049 plain_array() 00050 { 00051 check_static_allocation_size<T,Size>(); 00052 } 00053 00054 EIGEN_DEVICE_FUNC 00055 plain_array(constructor_without_unaligned_array_assert) 00056 { 00057 check_static_allocation_size<T,Size>(); 00058 } 00059 }; 00060 00061 #if defined(EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT) 00062 #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) 00063 #elif EIGEN_GNUC_AT_LEAST(4,7) 00064 // GCC 4.7 is too aggressive in its optimizations and remove the alignement test based on the fact the array is declared to be aligned. 00065 // See this bug report: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53900 00066 // Hiding the origin of the array pointer behind a function argument seems to do the trick even if the function is inlined: 00067 template<typename PtrType> 00068 EIGEN_ALWAYS_INLINE PtrType eigen_unaligned_array_assert_workaround_gcc47(PtrType array) { return array; } 00069 #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) \ 00070 eigen_assert((reinterpret_cast<size_t>(eigen_unaligned_array_assert_workaround_gcc47(array)) & (sizemask)) == 0 \ 00071 && "this assertion is explained here: " \ 00072 "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" \ 00073 " **** READ THIS WEB PAGE !!! ****"); 00074 #else 00075 #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) \ 00076 eigen_assert((reinterpret_cast<size_t>(array) & (sizemask)) == 0 \ 00077 && "this assertion is explained here: " \ 00078 "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" \ 00079 " **** READ THIS WEB PAGE !!! ****"); 00080 #endif 00081 00082 template <typename T, int Size, int MatrixOrArrayOptions> 00083 struct plain_array<T, Size, MatrixOrArrayOptions, 8> 00084 { 00085 EIGEN_ALIGN_TO_BOUNDARY(8) T array[Size]; 00086 00087 EIGEN_DEVICE_FUNC 00088 plain_array() 00089 { 00090 EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(7); 00091 check_static_allocation_size<T,Size>(); 00092 } 00093 00094 EIGEN_DEVICE_FUNC 00095 plain_array(constructor_without_unaligned_array_assert) 00096 { 00097 check_static_allocation_size<T,Size>(); 00098 } 00099 }; 00100 00101 template <typename T, int Size, int MatrixOrArrayOptions> 00102 struct plain_array<T, Size, MatrixOrArrayOptions, 16> 00103 { 00104 EIGEN_ALIGN_TO_BOUNDARY(16) T array[Size]; 00105 00106 EIGEN_DEVICE_FUNC 00107 plain_array() 00108 { 00109 EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(15); 00110 check_static_allocation_size<T,Size>(); 00111 } 00112 00113 EIGEN_DEVICE_FUNC 00114 plain_array(constructor_without_unaligned_array_assert) 00115 { 00116 check_static_allocation_size<T,Size>(); 00117 } 00118 }; 00119 00120 template <typename T, int Size, int MatrixOrArrayOptions> 00121 struct plain_array<T, Size, MatrixOrArrayOptions, 32> 00122 { 00123 EIGEN_ALIGN_TO_BOUNDARY(32) T array[Size]; 00124 00125 EIGEN_DEVICE_FUNC 00126 plain_array() 00127 { 00128 EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(31); 00129 check_static_allocation_size<T,Size>(); 00130 } 00131 00132 EIGEN_DEVICE_FUNC 00133 plain_array(constructor_without_unaligned_array_assert) 00134 { 00135 check_static_allocation_size<T,Size>(); 00136 } 00137 }; 00138 00139 template <typename T, int Size, int MatrixOrArrayOptions> 00140 struct plain_array<T, Size, MatrixOrArrayOptions, 64> 00141 { 00142 EIGEN_ALIGN_TO_BOUNDARY(64) T array[Size]; 00143 00144 EIGEN_DEVICE_FUNC 00145 plain_array() 00146 { 00147 EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(63); 00148 check_static_allocation_size<T,Size>(); 00149 } 00150 00151 EIGEN_DEVICE_FUNC 00152 plain_array(constructor_without_unaligned_array_assert) 00153 { 00154 check_static_allocation_size<T,Size>(); 00155 } 00156 }; 00157 00158 template <typename T, int MatrixOrArrayOptions, int Alignment> 00159 struct plain_array<T, 0, MatrixOrArrayOptions, Alignment> 00160 { 00161 T array[1]; 00162 EIGEN_DEVICE_FUNC plain_array() {} 00163 EIGEN_DEVICE_FUNC plain_array(constructor_without_unaligned_array_assert) {} 00164 }; 00165 00166 } // end namespace internal 00167 00180 template<typename T, int Size, int _Rows, int _Cols, int _Options> class DenseStorage; 00181 00182 // purely fixed-size matrix 00183 template<typename T, int Size, int _Rows, int _Cols, int _Options> class DenseStorage 00184 { 00185 internal::plain_array<T,Size,_Options> m_data; 00186 public: 00187 EIGEN_DEVICE_FUNC DenseStorage() {} 00188 EIGEN_DEVICE_FUNC 00189 explicit DenseStorage(internal::constructor_without_unaligned_array_assert) 00190 : m_data(internal::constructor_without_unaligned_array_assert()) {} 00191 EIGEN_DEVICE_FUNC 00192 DenseStorage(const DenseStorage& other) : m_data(other.m_data) {} 00193 EIGEN_DEVICE_FUNC 00194 DenseStorage& operator=(const DenseStorage& other) 00195 { 00196 if (this != &other) m_data = other.m_data; 00197 return *this; 00198 } 00199 EIGEN_DEVICE_FUNC DenseStorage(Index size, Index rows, Index cols) { 00200 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN 00201 eigen_internal_assert(size==rows*cols && rows==_Rows && cols==_Cols); 00202 EIGEN_UNUSED_VARIABLE(size); 00203 EIGEN_UNUSED_VARIABLE(rows); 00204 EIGEN_UNUSED_VARIABLE(cols); 00205 } 00206 EIGEN_DEVICE_FUNC void swap(DenseStorage& other) { std::swap(m_data,other.m_data); } 00207 EIGEN_DEVICE_FUNC static Index rows(void) {return _Rows;} 00208 EIGEN_DEVICE_FUNC static Index cols(void) {return _Cols;} 00209 EIGEN_DEVICE_FUNC void conservativeResize(Index,Index,Index) {} 00210 EIGEN_DEVICE_FUNC void resize(Index,Index,Index) {} 00211 EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; } 00212 EIGEN_DEVICE_FUNC T *data() { return m_data.array; } 00213 }; 00214 00215 // null matrix 00216 template<typename T, int _Rows, int _Cols, int _Options> class DenseStorage<T, 0, _Rows, _Cols, _Options> 00217 { 00218 public: 00219 EIGEN_DEVICE_FUNC DenseStorage() {} 00220 EIGEN_DEVICE_FUNC explicit DenseStorage(internal::constructor_without_unaligned_array_assert) {} 00221 EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage&) {} 00222 EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage&) { return *this; } 00223 EIGEN_DEVICE_FUNC DenseStorage(Index,Index,Index) {} 00224 EIGEN_DEVICE_FUNC void swap(DenseStorage& ) {} 00225 EIGEN_DEVICE_FUNC static Index rows(void) {return _Rows;} 00226 EIGEN_DEVICE_FUNC static Index cols(void) {return _Cols;} 00227 EIGEN_DEVICE_FUNC void conservativeResize(Index,Index,Index) {} 00228 EIGEN_DEVICE_FUNC void resize(Index,Index,Index) {} 00229 EIGEN_DEVICE_FUNC const T *data() const { return 0; } 00230 EIGEN_DEVICE_FUNC T *data() { return 0; } 00231 }; 00232 00233 // more specializations for null matrices; these are necessary to resolve ambiguities 00234 template<typename T, int _Options> class DenseStorage<T, 0, Dynamic, Dynamic, _Options> 00235 : public DenseStorage<T, 0, 0, 0, _Options> { }; 00236 00237 template<typename T, int _Rows, int _Options> class DenseStorage<T, 0, _Rows, Dynamic, _Options> 00238 : public DenseStorage<T, 0, 0, 0, _Options> { }; 00239 00240 template<typename T, int _Cols, int _Options> class DenseStorage<T, 0, Dynamic, _Cols, _Options> 00241 : public DenseStorage<T, 0, 0, 0, _Options> { }; 00242 00243 // dynamic-size matrix with fixed-size storage 00244 template<typename T, int Size, int _Options> class DenseStorage<T, Size, Dynamic, Dynamic, _Options> 00245 { 00246 internal::plain_array<T,Size,_Options> m_data; 00247 Index m_rows; 00248 Index m_cols; 00249 public: 00250 EIGEN_DEVICE_FUNC DenseStorage() : m_rows(0), m_cols(0) {} 00251 EIGEN_DEVICE_FUNC explicit DenseStorage(internal::constructor_without_unaligned_array_assert) 00252 : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0), m_cols(0) {} 00253 EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_rows(other.m_rows), m_cols(other.m_cols) {} 00254 EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other) 00255 { 00256 if (this != &other) 00257 { 00258 m_data = other.m_data; 00259 m_rows = other.m_rows; 00260 m_cols = other.m_cols; 00261 } 00262 return *this; 00263 } 00264 EIGEN_DEVICE_FUNC DenseStorage(Index, Index rows, Index cols) : m_rows(rows), m_cols(cols) {} 00265 EIGEN_DEVICE_FUNC void swap(DenseStorage& other) 00266 { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); } 00267 EIGEN_DEVICE_FUNC Index rows() const {return m_rows;} 00268 EIGEN_DEVICE_FUNC Index cols() const {return m_cols;} 00269 EIGEN_DEVICE_FUNC void conservativeResize(Index, Index rows, Index cols) { m_rows = rows; m_cols = cols; } 00270 EIGEN_DEVICE_FUNC void resize(Index, Index rows, Index cols) { m_rows = rows; m_cols = cols; } 00271 EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; } 00272 EIGEN_DEVICE_FUNC T *data() { return m_data.array; } 00273 }; 00274 00275 // dynamic-size matrix with fixed-size storage and fixed width 00276 template<typename T, int Size, int _Cols, int _Options> class DenseStorage<T, Size, Dynamic, _Cols, _Options> 00277 { 00278 internal::plain_array<T,Size,_Options> m_data; 00279 Index m_rows; 00280 public: 00281 EIGEN_DEVICE_FUNC DenseStorage() : m_rows(0) {} 00282 EIGEN_DEVICE_FUNC explicit DenseStorage(internal::constructor_without_unaligned_array_assert) 00283 : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0) {} 00284 EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_rows(other.m_rows) {} 00285 EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other) 00286 { 00287 if (this != &other) 00288 { 00289 m_data = other.m_data; 00290 m_rows = other.m_rows; 00291 } 00292 return *this; 00293 } 00294 EIGEN_DEVICE_FUNC DenseStorage(Index, Index rows, Index) : m_rows(rows) {} 00295 EIGEN_DEVICE_FUNC void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); } 00296 EIGEN_DEVICE_FUNC Index rows(void) const {return m_rows;} 00297 EIGEN_DEVICE_FUNC Index cols(void) const {return _Cols;} 00298 EIGEN_DEVICE_FUNC void conservativeResize(Index, Index rows, Index) { m_rows = rows; } 00299 EIGEN_DEVICE_FUNC void resize(Index, Index rows, Index) { m_rows = rows; } 00300 EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; } 00301 EIGEN_DEVICE_FUNC T *data() { return m_data.array; } 00302 }; 00303 00304 // dynamic-size matrix with fixed-size storage and fixed height 00305 template<typename T, int Size, int _Rows, int _Options> class DenseStorage<T, Size, _Rows, Dynamic, _Options> 00306 { 00307 internal::plain_array<T,Size,_Options> m_data; 00308 Index m_cols; 00309 public: 00310 EIGEN_DEVICE_FUNC DenseStorage() : m_cols(0) {} 00311 EIGEN_DEVICE_FUNC explicit DenseStorage(internal::constructor_without_unaligned_array_assert) 00312 : m_data(internal::constructor_without_unaligned_array_assert()), m_cols(0) {} 00313 EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_cols(other.m_cols) {} 00314 EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other) 00315 { 00316 if (this != &other) 00317 { 00318 m_data = other.m_data; 00319 m_cols = other.m_cols; 00320 } 00321 return *this; 00322 } 00323 EIGEN_DEVICE_FUNC DenseStorage(Index, Index, Index cols) : m_cols(cols) {} 00324 EIGEN_DEVICE_FUNC void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); } 00325 EIGEN_DEVICE_FUNC Index rows(void) const {return _Rows;} 00326 EIGEN_DEVICE_FUNC Index cols(void) const {return m_cols;} 00327 void conservativeResize(Index, Index, Index cols) { m_cols = cols; } 00328 void resize(Index, Index, Index cols) { m_cols = cols; } 00329 EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; } 00330 EIGEN_DEVICE_FUNC T *data() { return m_data.array; } 00331 }; 00332 00333 // purely dynamic matrix. 00334 template<typename T, int _Options> class DenseStorage<T, Dynamic, Dynamic, Dynamic, _Options> 00335 { 00336 T *m_data; 00337 Index m_rows; 00338 Index m_cols; 00339 public: 00340 EIGEN_DEVICE_FUNC DenseStorage() : m_data(0), m_rows(0), m_cols(0) {} 00341 EIGEN_DEVICE_FUNC explicit DenseStorage(internal::constructor_without_unaligned_array_assert) 00342 : m_data(0), m_rows(0), m_cols(0) {} 00343 EIGEN_DEVICE_FUNC DenseStorage(Index size, Index rows, Index cols) 00344 : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size)), m_rows(rows), m_cols(cols) 00345 { 00346 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN 00347 eigen_internal_assert(size==rows*cols && rows>=0 && cols >=0); 00348 } 00349 EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other) 00350 : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(other.m_rows*other.m_cols)) 00351 , m_rows(other.m_rows) 00352 , m_cols(other.m_cols) 00353 { 00354 internal::smart_copy(other.m_data, other.m_data+other.m_rows*other.m_cols, m_data); 00355 } 00356 EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other) 00357 { 00358 if (this != &other) 00359 { 00360 DenseStorage tmp(other); 00361 this->swap(tmp); 00362 } 00363 return *this; 00364 } 00365 #ifdef EIGEN_HAVE_RVALUE_REFERENCES 00366 EIGEN_DEVICE_FUNC 00367 DenseStorage(DenseStorage&& other) 00368 : m_data(std::move(other.m_data)) 00369 , m_rows(std::move(other.m_rows)) 00370 , m_cols(std::move(other.m_cols)) 00371 { 00372 other.m_data = nullptr; 00373 other.m_rows = 0; 00374 other.m_cols = 0; 00375 } 00376 EIGEN_DEVICE_FUNC 00377 DenseStorage& operator=(DenseStorage&& other) 00378 { 00379 using std::swap; 00380 swap(m_data, other.m_data); 00381 swap(m_rows, other.m_rows); 00382 swap(m_cols, other.m_cols); 00383 return *this; 00384 } 00385 #endif 00386 EIGEN_DEVICE_FUNC ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols); } 00387 EIGEN_DEVICE_FUNC void swap(DenseStorage& other) 00388 { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); } 00389 EIGEN_DEVICE_FUNC Index rows(void) const {return m_rows;} 00390 EIGEN_DEVICE_FUNC Index cols(void) const {return m_cols;} 00391 void conservativeResize(Index size, Index rows, Index cols) 00392 { 00393 m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, m_rows*m_cols); 00394 m_rows = rows; 00395 m_cols = cols; 00396 } 00397 EIGEN_DEVICE_FUNC void resize(Index size, Index rows, Index cols) 00398 { 00399 if(size != m_rows*m_cols) 00400 { 00401 internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols); 00402 if (size) 00403 m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size); 00404 else 00405 m_data = 0; 00406 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN 00407 } 00408 m_rows = rows; 00409 m_cols = cols; 00410 } 00411 EIGEN_DEVICE_FUNC const T *data() const { return m_data; } 00412 EIGEN_DEVICE_FUNC T *data() { return m_data; } 00413 }; 00414 00415 // matrix with dynamic width and fixed height (so that matrix has dynamic size). 00416 template<typename T, int _Rows, int _Options> class DenseStorage<T, Dynamic, _Rows, Dynamic, _Options> 00417 { 00418 T *m_data; 00419 Index m_cols; 00420 public: 00421 EIGEN_DEVICE_FUNC DenseStorage() : m_data(0), m_cols(0) {} 00422 explicit DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_cols(0) {} 00423 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) 00424 { 00425 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN 00426 eigen_internal_assert(size==rows*cols && rows==_Rows && cols >=0); 00427 EIGEN_UNUSED_VARIABLE(rows); 00428 } 00429 EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other) 00430 : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(_Rows*other.m_cols)) 00431 , m_cols(other.m_cols) 00432 { 00433 internal::smart_copy(other.m_data, other.m_data+_Rows*m_cols, m_data); 00434 } 00435 EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other) 00436 { 00437 if (this != &other) 00438 { 00439 DenseStorage tmp(other); 00440 this->swap(tmp); 00441 } 00442 return *this; 00443 } 00444 #ifdef EIGEN_HAVE_RVALUE_REFERENCES 00445 EIGEN_DEVICE_FUNC 00446 DenseStorage(DenseStorage&& other) 00447 : m_data(std::move(other.m_data)) 00448 , m_cols(std::move(other.m_cols)) 00449 { 00450 other.m_data = nullptr; 00451 other.m_cols = 0; 00452 } 00453 EIGEN_DEVICE_FUNC 00454 DenseStorage& operator=(DenseStorage&& other) 00455 { 00456 using std::swap; 00457 swap(m_data, other.m_data); 00458 swap(m_cols, other.m_cols); 00459 return *this; 00460 } 00461 #endif 00462 EIGEN_DEVICE_FUNC ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols); } 00463 EIGEN_DEVICE_FUNC void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); } 00464 EIGEN_DEVICE_FUNC static Index rows(void) {return _Rows;} 00465 EIGEN_DEVICE_FUNC Index cols(void) const {return m_cols;} 00466 EIGEN_DEVICE_FUNC void conservativeResize(Index size, Index, Index cols) 00467 { 00468 m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, _Rows*m_cols); 00469 m_cols = cols; 00470 } 00471 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index size, Index, Index cols) 00472 { 00473 if(size != _Rows*m_cols) 00474 { 00475 internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols); 00476 if (size) 00477 m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size); 00478 else 00479 m_data = 0; 00480 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN 00481 } 00482 m_cols = cols; 00483 } 00484 EIGEN_DEVICE_FUNC const T *data() const { return m_data; } 00485 EIGEN_DEVICE_FUNC T *data() { return m_data; } 00486 }; 00487 00488 // matrix with dynamic height and fixed width (so that matrix has dynamic size). 00489 template<typename T, int _Cols, int _Options> class DenseStorage<T, Dynamic, Dynamic, _Cols, _Options> 00490 { 00491 T *m_data; 00492 Index m_rows; 00493 public: 00494 EIGEN_DEVICE_FUNC DenseStorage() : m_data(0), m_rows(0) {} 00495 explicit DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_rows(0) {} 00496 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) 00497 { 00498 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN 00499 eigen_internal_assert(size==rows*cols && rows>=0 && cols == _Cols); 00500 EIGEN_UNUSED_VARIABLE(cols); 00501 } 00502 EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage& other) 00503 : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(other.m_rows*_Cols)) 00504 , m_rows(other.m_rows) 00505 { 00506 internal::smart_copy(other.m_data, other.m_data+other.m_rows*_Cols, m_data); 00507 } 00508 EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other) 00509 { 00510 if (this != &other) 00511 { 00512 DenseStorage tmp(other); 00513 this->swap(tmp); 00514 } 00515 return *this; 00516 } 00517 #ifdef EIGEN_HAVE_RVALUE_REFERENCES 00518 EIGEN_DEVICE_FUNC 00519 DenseStorage(DenseStorage&& other) 00520 : m_data(std::move(other.m_data)) 00521 , m_rows(std::move(other.m_rows)) 00522 { 00523 other.m_data = nullptr; 00524 other.m_rows = 0; 00525 } 00526 EIGEN_DEVICE_FUNC 00527 DenseStorage& operator=(DenseStorage&& other) 00528 { 00529 using std::swap; 00530 swap(m_data, other.m_data); 00531 swap(m_rows, other.m_rows); 00532 return *this; 00533 } 00534 #endif 00535 EIGEN_DEVICE_FUNC ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows); } 00536 EIGEN_DEVICE_FUNC void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); } 00537 EIGEN_DEVICE_FUNC Index rows(void) const {return m_rows;} 00538 EIGEN_DEVICE_FUNC static Index cols(void) {return _Cols;} 00539 void conservativeResize(Index size, Index rows, Index) 00540 { 00541 m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, m_rows*_Cols); 00542 m_rows = rows; 00543 } 00544 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index size, Index rows, Index) 00545 { 00546 if(size != m_rows*_Cols) 00547 { 00548 internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows); 00549 if (size) 00550 m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size); 00551 else 00552 m_data = 0; 00553 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN 00554 } 00555 m_rows = rows; 00556 } 00557 EIGEN_DEVICE_FUNC const T *data() const { return m_data; } 00558 EIGEN_DEVICE_FUNC T *data() { return m_data; } 00559 }; 00560 00561 } // end namespace Eigen 00562 00563 #endif // EIGEN_MATRIX_H