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 EIGEN_DENSE_STORAGE_CTOR_PLUGIN; 18 #define EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN 25 struct constructor_without_unaligned_array_assert {};
27 template<
typename T,
int Size>
void check_static_allocation_size()
30 #if EIGEN_STACK_ALLOCATION_LIMIT 31 EIGEN_STATIC_ASSERT(Size *
sizeof(T) <= EIGEN_STACK_ALLOCATION_LIMIT, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG);
39 template <
typename T,
int Size,
int MatrixOrArrayOptions,
40 int Alignment = (MatrixOrArrayOptions&
DontAlign) ? 0
41 : (((Size*
sizeof(T))%16)==0) ? 16
49 check_static_allocation_size<T,Size>();
52 plain_array(constructor_without_unaligned_array_assert)
54 check_static_allocation_size<T,Size>();
58 #if defined(EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT) 59 #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) 60 #elif EIGEN_GNUC_AT_LEAST(4,7) 64 template<
typename PtrType>
65 EIGEN_ALWAYS_INLINE PtrType eigen_unaligned_array_assert_workaround_gcc47(PtrType array) {
return array; }
66 #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) \ 67 eigen_assert((reinterpret_cast<size_t>(eigen_unaligned_array_assert_workaround_gcc47(array)) & sizemask) == 0 \ 68 && "this assertion is explained here: " \ 69 "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" \ 70 " **** READ THIS WEB PAGE !!! ****"); 72 #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) \ 73 eigen_assert((reinterpret_cast<size_t>(array) & sizemask) == 0 \ 74 && "this assertion is explained here: " \ 75 "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" \ 76 " **** READ THIS WEB PAGE !!! ****"); 79 template <
typename T,
int Size,
int MatrixOrArrayOptions>
80 struct plain_array<T, Size, MatrixOrArrayOptions, 16>
82 EIGEN_USER_ALIGN16 T array[Size];
86 EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(0xf);
87 check_static_allocation_size<T,Size>();
90 plain_array(constructor_without_unaligned_array_assert)
92 check_static_allocation_size<T,Size>();
96 template <
typename T,
int MatrixOrArrayOptions,
int Alignment>
97 struct plain_array<T, 0, MatrixOrArrayOptions, Alignment>
99 EIGEN_USER_ALIGN16 T array[1];
101 plain_array(constructor_without_unaligned_array_assert) {}
118 template<
typename T,
int Size,
int _Rows,
int _Cols,
int _Options>
class DenseStorage;
121 template<
typename T,
int Size,
int _Rows,
int _Cols,
int _Options>
class DenseStorage
123 internal::plain_array<T,Size,_Options> m_data;
125 inline DenseStorage() {}
126 inline DenseStorage(internal::constructor_without_unaligned_array_assert)
127 : m_data(
internal::constructor_without_unaligned_array_assert()) {}
128 inline DenseStorage(DenseIndex,DenseIndex,DenseIndex) {}
129 inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); }
130 static inline DenseIndex rows(
void) {
return _Rows;}
131 static inline DenseIndex cols(
void) {
return _Cols;}
132 inline void conservativeResize(DenseIndex,DenseIndex,DenseIndex) {}
133 inline void resize(DenseIndex,DenseIndex,DenseIndex) {}
134 inline const T *data()
const {
return m_data.array; }
135 inline T *data() {
return m_data.array; }
139 template<
typename T,
int _Rows,
int _Cols,
int _Options>
class DenseStorage<T, 0, _Rows, _Cols, _Options>
142 inline DenseStorage() {}
143 inline DenseStorage(internal::constructor_without_unaligned_array_assert) {}
144 inline DenseStorage(DenseIndex,DenseIndex,DenseIndex) {}
145 inline void swap(DenseStorage& ) {}
146 static inline DenseIndex rows(
void) {
return _Rows;}
147 static inline DenseIndex cols(
void) {
return _Cols;}
148 inline void conservativeResize(DenseIndex,DenseIndex,DenseIndex) {}
149 inline void resize(DenseIndex,DenseIndex,DenseIndex) {}
150 inline const T *data()
const {
return 0; }
151 inline T *data() {
return 0; }
155 template<
typename T,
int _Options>
class DenseStorage<T, 0, Dynamic, Dynamic, _Options>
156 :
public DenseStorage<T, 0, 0, 0, _Options> { };
158 template<
typename T,
int _Rows,
int _Options>
class DenseStorage<T, 0, _Rows, Dynamic, _Options>
159 :
public DenseStorage<T, 0, 0, 0, _Options> { };
161 template<
typename T,
int _Cols,
int _Options>
class DenseStorage<T, 0, Dynamic, _Cols, _Options>
162 :
public DenseStorage<T, 0, 0, 0, _Options> { };
165 template<
typename T,
int Size,
int _Options>
class DenseStorage<T, Size, Dynamic, Dynamic, _Options>
167 internal::plain_array<T,Size,_Options> m_data;
171 inline DenseStorage() : m_rows(0), m_cols(0) {}
172 inline DenseStorage(internal::constructor_without_unaligned_array_assert)
173 : m_data(
internal::constructor_without_unaligned_array_assert()), m_rows(0), m_cols(0) {}
174 inline DenseStorage(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) : m_rows(nbRows), m_cols(nbCols) {}
175 inline void swap(DenseStorage& other)
176 { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); }
177 inline DenseIndex rows()
const {
return m_rows;}
178 inline DenseIndex cols()
const {
return m_cols;}
179 inline void conservativeResize(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) { m_rows = nbRows; m_cols = nbCols; }
180 inline void resize(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) { m_rows = nbRows; m_cols = nbCols; }
181 inline const T *data()
const {
return m_data.array; }
182 inline T *data() {
return m_data.array; }
186 template<
typename T,
int Size,
int _Cols,
int _Options>
class DenseStorage<T, Size, Dynamic, _Cols, _Options>
188 internal::plain_array<T,Size,_Options> m_data;
191 inline DenseStorage() : m_rows(0) {}
192 inline DenseStorage(internal::constructor_without_unaligned_array_assert)
193 : m_data(
internal::constructor_without_unaligned_array_assert()), m_rows(0) {}
194 inline DenseStorage(DenseIndex, DenseIndex nbRows, DenseIndex) : m_rows(nbRows) {}
195 inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); }
196 inline DenseIndex rows(
void)
const {
return m_rows;}
197 inline DenseIndex cols(
void)
const {
return _Cols;}
198 inline void conservativeResize(DenseIndex, DenseIndex nbRows, DenseIndex) { m_rows = nbRows; }
199 inline void resize(DenseIndex, DenseIndex nbRows, DenseIndex) { m_rows = nbRows; }
200 inline const T *data()
const {
return m_data.array; }
201 inline T *data() {
return m_data.array; }
205 template<
typename T,
int Size,
int _Rows,
int _Options>
class DenseStorage<T, Size, _Rows, Dynamic, _Options>
207 internal::plain_array<T,Size,_Options> m_data;
210 inline DenseStorage() : m_cols(0) {}
211 inline DenseStorage(internal::constructor_without_unaligned_array_assert)
212 : m_data(
internal::constructor_without_unaligned_array_assert()), m_cols(0) {}
213 inline DenseStorage(DenseIndex, DenseIndex, DenseIndex nbCols) : m_cols(nbCols) {}
214 inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); }
215 inline DenseIndex rows(
void)
const {
return _Rows;}
216 inline DenseIndex cols(
void)
const {
return m_cols;}
217 inline void conservativeResize(DenseIndex, DenseIndex, DenseIndex nbCols) { m_cols = nbCols; }
218 inline void resize(DenseIndex, DenseIndex, DenseIndex nbCols) { m_cols = nbCols; }
219 inline const T *data()
const {
return m_data.array; }
220 inline T *data() {
return m_data.array; }
224 template<
typename T,
int _Options>
class DenseStorage<T, Dynamic, Dynamic, Dynamic, _Options>
230 inline DenseStorage() : m_data(0), m_rows(0), m_cols(0) {}
231 inline DenseStorage(internal::constructor_without_unaligned_array_assert)
232 : m_data(0), m_rows(0), m_cols(0) {}
233 inline DenseStorage(DenseIndex size, DenseIndex nbRows, DenseIndex nbCols)
234 : m_data(
internal::conditional_aligned_new_auto<T,(_Options&
DontAlign)==0>(size)), m_rows(nbRows), m_cols(nbCols)
235 { EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN }
236 inline ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols); }
237 inline void swap(DenseStorage& other)
238 { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); }
239 inline DenseIndex rows(
void)
const {
return m_rows;}
240 inline DenseIndex cols(
void)
const {
return m_cols;}
241 inline void conservativeResize(DenseIndex size, DenseIndex nbRows, DenseIndex nbCols)
243 m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, m_rows*m_cols);
247 void resize(DenseIndex size, DenseIndex nbRows, DenseIndex nbCols)
249 if(size != m_rows*m_cols)
251 internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols);
253 m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size);
256 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN
261 inline const T *data()
const {
return m_data; }
262 inline T *data() {
return m_data; }
266 template<
typename T,
int _Rows,
int _Options>
class DenseStorage<T, Dynamic, _Rows, Dynamic, _Options>
271 inline DenseStorage() : m_data(0), m_cols(0) {}
272 inline DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_cols(0) {}
273 inline DenseStorage(DenseIndex size, DenseIndex, DenseIndex nbCols) : m_data(
internal::conditional_aligned_new_auto<T,(_Options&
DontAlign)==0>(size)), m_cols(nbCols)
274 { EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN }
275 inline ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols); }
276 inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); }
277 static inline DenseIndex rows(
void) {
return _Rows;}
278 inline DenseIndex cols(
void)
const {
return m_cols;}
279 inline void conservativeResize(DenseIndex size, DenseIndex, DenseIndex nbCols)
281 m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, _Rows*m_cols);
284 EIGEN_STRONG_INLINE
void resize(DenseIndex size, DenseIndex, DenseIndex nbCols)
286 if(size != _Rows*m_cols)
288 internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols);
290 m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size);
293 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN
297 inline const T *data()
const {
return m_data; }
298 inline T *data() {
return m_data; }
302 template<
typename T,
int _Cols,
int _Options>
class DenseStorage<T, Dynamic, Dynamic, _Cols, _Options>
307 inline DenseStorage() : m_data(0), m_rows(0) {}
308 inline DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_rows(0) {}
309 inline DenseStorage(DenseIndex size, DenseIndex nbRows, DenseIndex) : m_data(
internal::conditional_aligned_new_auto<T,(_Options&
DontAlign)==0>(size)), m_rows(nbRows)
310 { EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN }
311 inline ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows); }
312 inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); }
313 inline DenseIndex rows(
void)
const {
return m_rows;}
314 static inline DenseIndex cols(
void) {
return _Cols;}
315 inline void conservativeResize(DenseIndex size, DenseIndex nbRows, DenseIndex)
317 m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, m_rows*_Cols);
320 EIGEN_STRONG_INLINE
void resize(DenseIndex size, DenseIndex nbRows, DenseIndex)
322 if(size != m_rows*_Cols)
324 internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows);
326 m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size);
329 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN
333 inline const T *data()
const {
return m_data; }
334 inline T *data() {
return m_data; }
339 #endif // EIGEN_MATRIX_H
Definition: Constants.h:270
Definition: Eigen_Colamd.h:54