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 {};
31 template <
typename T,
int Size,
int MatrixOrArrayOptions,
32 int Alignment = (MatrixOrArrayOptions&
DontAlign) ? 0
33 : (((Size*
sizeof(T))%16)==0) ? 16
41 EIGEN_STATIC_ASSERT(Size *
sizeof(T) <= 128 * 128 * 8, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG);
44 plain_array(constructor_without_unaligned_array_assert)
46 EIGEN_STATIC_ASSERT(Size *
sizeof(T) <= 128 * 128 * 8, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG);
50 #if defined(EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT)
51 #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask)
52 #elif EIGEN_GNUC_AT_LEAST(4,7)
56 template<
typename PtrType>
57 EIGEN_ALWAYS_INLINE PtrType eigen_unaligned_array_assert_workaround_gcc47(PtrType array) {
return array; }
58 #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) \
59 eigen_assert((reinterpret_cast<size_t>(eigen_unaligned_array_assert_workaround_gcc47(array)) & sizemask) == 0 \
60 && "this assertion is explained here: " \
61 "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" \
62 " **** READ THIS WEB PAGE !!! ****");
64 #define EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(sizemask) \
65 eigen_assert((reinterpret_cast<size_t>(array) & sizemask) == 0 \
66 && "this assertion is explained here: " \
67 "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" \
68 " **** READ THIS WEB PAGE !!! ****");
71 template <
typename T,
int Size,
int MatrixOrArrayOptions>
72 struct plain_array<T, Size, MatrixOrArrayOptions, 16>
74 EIGEN_USER_ALIGN16 T array[Size];
78 EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(0xf);
79 EIGEN_STATIC_ASSERT(Size *
sizeof(T) <= 128 * 128 * 8, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG);
82 plain_array(constructor_without_unaligned_array_assert)
84 EIGEN_STATIC_ASSERT(Size *
sizeof(T) <= 128 * 128 * 8, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG);
88 template <
typename T,
int MatrixOrArrayOptions,
int Alignment>
89 struct plain_array<T, 0, MatrixOrArrayOptions, Alignment>
91 EIGEN_USER_ALIGN16 T array[1];
93 plain_array(constructor_without_unaligned_array_assert) {}
110 template<
typename T,
int Size,
int _Rows,
int _Cols,
int _Options>
class DenseStorage;
113 template<
typename T,
int Size,
int _Rows,
int _Cols,
int _Options>
class DenseStorage
115 internal::plain_array<T,Size,_Options> m_data;
117 inline DenseStorage() {}
118 inline DenseStorage(internal::constructor_without_unaligned_array_assert)
119 : m_data(internal::constructor_without_unaligned_array_assert()) {}
120 inline DenseStorage(DenseIndex,DenseIndex,DenseIndex) {}
121 inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); }
122 static inline DenseIndex rows(
void) {
return _Rows;}
123 static inline DenseIndex cols(
void) {
return _Cols;}
124 inline void conservativeResize(DenseIndex,DenseIndex,DenseIndex) {}
125 inline void resize(DenseIndex,DenseIndex,DenseIndex) {}
126 inline const T *data()
const {
return m_data.array; }
127 inline T *data() {
return m_data.array; }
131 template<
typename T,
int _Rows,
int _Cols,
int _Options>
class DenseStorage<T, 0, _Rows, _Cols, _Options>
134 inline DenseStorage() {}
135 inline DenseStorage(internal::constructor_without_unaligned_array_assert) {}
136 inline DenseStorage(DenseIndex,DenseIndex,DenseIndex) {}
137 inline void swap(DenseStorage& ) {}
138 static inline DenseIndex rows(
void) {
return _Rows;}
139 static inline DenseIndex cols(
void) {
return _Cols;}
140 inline void conservativeResize(DenseIndex,DenseIndex,DenseIndex) {}
141 inline void resize(DenseIndex,DenseIndex,DenseIndex) {}
142 inline const T *data()
const {
return 0; }
143 inline T *data() {
return 0; }
147 template<
typename T,
int _Options>
class DenseStorage<T, 0, Dynamic, Dynamic, _Options>
148 :
public DenseStorage<T, 0, 0, 0, _Options> { };
150 template<
typename T,
int _Rows,
int _Options>
class DenseStorage<T, 0, _Rows, Dynamic, _Options>
151 :
public DenseStorage<T, 0, 0, 0, _Options> { };
153 template<
typename T,
int _Cols,
int _Options>
class DenseStorage<T, 0, Dynamic, _Cols, _Options>
154 :
public DenseStorage<T, 0, 0, 0, _Options> { };
157 template<
typename T,
int Size,
int _Options>
class DenseStorage<T, Size, Dynamic, Dynamic, _Options>
159 internal::plain_array<T,Size,_Options> m_data;
163 inline DenseStorage() : m_rows(0), m_cols(0) {}
164 inline DenseStorage(internal::constructor_without_unaligned_array_assert)
165 : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0), m_cols(0) {}
166 inline DenseStorage(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) : m_rows(nbRows), m_cols(nbCols) {}
167 inline void swap(DenseStorage& other)
168 { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); }
169 inline DenseIndex rows()
const {
return m_rows;}
170 inline DenseIndex cols()
const {
return m_cols;}
171 inline void conservativeResize(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) { m_rows = nbRows; m_cols = nbCols; }
172 inline void resize(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) { m_rows = nbRows; m_cols = nbCols; }
173 inline const T *data()
const {
return m_data.array; }
174 inline T *data() {
return m_data.array; }
178 template<
typename T,
int Size,
int _Cols,
int _Options>
class DenseStorage<T, Size, Dynamic, _Cols, _Options>
180 internal::plain_array<T,Size,_Options> m_data;
183 inline DenseStorage() : m_rows(0) {}
184 inline DenseStorage(internal::constructor_without_unaligned_array_assert)
185 : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0) {}
186 inline DenseStorage(DenseIndex, DenseIndex nbRows, DenseIndex) : m_rows(nbRows) {}
187 inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); }
188 inline DenseIndex rows(
void)
const {
return m_rows;}
189 inline DenseIndex cols(
void)
const {
return _Cols;}
190 inline void conservativeResize(DenseIndex, DenseIndex nbRows, DenseIndex) { m_rows = nbRows; }
191 inline void resize(DenseIndex, DenseIndex nbRows, DenseIndex) { m_rows = nbRows; }
192 inline const T *data()
const {
return m_data.array; }
193 inline T *data() {
return m_data.array; }
197 template<
typename T,
int Size,
int _Rows,
int _Options>
class DenseStorage<T, Size, _Rows, Dynamic, _Options>
199 internal::plain_array<T,Size,_Options> m_data;
202 inline DenseStorage() : m_cols(0) {}
203 inline DenseStorage(internal::constructor_without_unaligned_array_assert)
204 : m_data(internal::constructor_without_unaligned_array_assert()), m_cols(0) {}
205 inline DenseStorage(DenseIndex, DenseIndex, DenseIndex nbCols) : m_cols(nbCols) {}
206 inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); }
207 inline DenseIndex rows(
void)
const {
return _Rows;}
208 inline DenseIndex cols(
void)
const {
return m_cols;}
209 inline void conservativeResize(DenseIndex, DenseIndex, DenseIndex nbCols) { m_cols = nbCols; }
210 inline void resize(DenseIndex, DenseIndex, DenseIndex nbCols) { m_cols = nbCols; }
211 inline const T *data()
const {
return m_data.array; }
212 inline T *data() {
return m_data.array; }
216 template<
typename T,
int _Options>
class DenseStorage<T, Dynamic, Dynamic, Dynamic, _Options>
222 inline DenseStorage() : m_data(0), m_rows(0), m_cols(0) {}
223 inline DenseStorage(internal::constructor_without_unaligned_array_assert)
224 : m_data(0), m_rows(0), m_cols(0) {}
225 inline DenseStorage(DenseIndex size, DenseIndex nbRows, DenseIndex nbCols)
226 : m_data(internal::conditional_aligned_new_auto<T,(_Options&
DontAlign)==0>(size)), m_rows(nbRows), m_cols(nbCols)
227 { EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN }
228 inline ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols); }
229 inline void swap(DenseStorage& other)
230 { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); }
231 inline DenseIndex rows(
void)
const {
return m_rows;}
232 inline DenseIndex cols(
void)
const {
return m_cols;}
233 inline void conservativeResize(DenseIndex size, DenseIndex nbRows, DenseIndex nbCols)
235 m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, m_rows*m_cols);
239 void resize(DenseIndex size, DenseIndex nbRows, DenseIndex nbCols)
241 if(size != m_rows*m_cols)
243 internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols);
245 m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size);
248 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN
253 inline const T *data()
const {
return m_data; }
254 inline T *data() {
return m_data; }
258 template<
typename T,
int _Rows,
int _Options>
class DenseStorage<T, Dynamic, _Rows, Dynamic, _Options>
263 inline DenseStorage() : m_data(0), m_cols(0) {}
264 inline DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_cols(0) {}
265 inline DenseStorage(DenseIndex size, DenseIndex, DenseIndex nbCols) : m_data(internal::conditional_aligned_new_auto<T,(_Options&
DontAlign)==0>(size)), m_cols(nbCols)
266 { EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN }
267 inline ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols); }
268 inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); }
269 static inline DenseIndex rows(
void) {
return _Rows;}
270 inline DenseIndex cols(
void)
const {
return m_cols;}
271 inline void conservativeResize(DenseIndex size, DenseIndex, DenseIndex nbCols)
273 m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, _Rows*m_cols);
276 EIGEN_STRONG_INLINE
void resize(DenseIndex size, DenseIndex, DenseIndex nbCols)
278 if(size != _Rows*m_cols)
280 internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols);
282 m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size);
285 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN
289 inline const T *data()
const {
return m_data; }
290 inline T *data() {
return m_data; }
294 template<
typename T,
int _Cols,
int _Options>
class DenseStorage<T, Dynamic, Dynamic, _Cols, _Options>
299 inline DenseStorage() : m_data(0), m_rows(0) {}
300 inline DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_rows(0) {}
301 inline DenseStorage(DenseIndex size, DenseIndex nbRows, DenseIndex) : m_data(internal::conditional_aligned_new_auto<T,(_Options&
DontAlign)==0>(size)), m_rows(nbRows)
302 { EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN }
303 inline ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows); }
304 inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); }
305 inline DenseIndex rows(
void)
const {
return m_rows;}
306 static inline DenseIndex cols(
void) {
return _Cols;}
307 inline void conservativeResize(DenseIndex size, DenseIndex nbRows, DenseIndex)
309 m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, m_rows*_Cols);
312 EIGEN_STRONG_INLINE
void resize(DenseIndex size, DenseIndex nbRows, DenseIndex)
314 if(size != m_rows*_Cols)
316 internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows);
318 m_data = internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size);
321 EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN
325 inline const T *data()
const {
return m_data; }
326 inline T *data() {
return m_data; }
331 #endif // EIGEN_MATRIX_H
Definition: Constants.h:270