diff options
author | Benoit Jacob <jacob.benoit.1@gmail.com> | 2009-01-10 13:10:23 +0000 |
---|---|---|
committer | Benoit Jacob <jacob.benoit.1@gmail.com> | 2009-01-10 13:10:23 +0000 |
commit | 0c1ef2f4c67430e3c6605adfb1ddc3ac1d1e779f (patch) | |
tree | 15aad48552efe309e4d18c440cff5b1ac63b68d5 /Eigen | |
parent | 3efe6e4176dd76fc3a4e6981ec44ef9741c361d9 (diff) |
make the std::vector fix work also with dynamic size Eigen objects, e.g.
std::vector<VectorXd>
update unit test
Diffstat (limited to 'Eigen')
-rw-r--r-- | Eigen/StdVector | 5 | ||||
-rw-r--r-- | Eigen/src/Core/Matrix.h | 5 | ||||
-rw-r--r-- | Eigen/src/Core/MatrixStorage.h | 33 |
3 files changed, 20 insertions, 23 deletions
diff --git a/Eigen/StdVector b/Eigen/StdVector index 6d5366468..19be257db 100644 --- a/Eigen/StdVector +++ b/Eigen/StdVector @@ -29,7 +29,7 @@ #include "Core" #include <vector> -namespace Eigen{ +namespace Eigen { template<typename aligned_type> class ei_unaligned_type; template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> @@ -38,9 +38,10 @@ class ei_unaligned_type<Matrix<_Scalar,_Rows,_Cols,_Options,_MaxRows,_MaxCols> > { public: typedef Matrix<_Scalar,_Rows,_Cols,_Options,_MaxRows,_MaxCols> aligned_base; - ei_unaligned_type() : aligned_base(ei_select_matrix_constructor_doing_absolutely_nothing()) {} + ei_unaligned_type() : aligned_base(ei_constructor_without_unaligned_array_assert()) {} ei_unaligned_type(const aligned_base& other) { + resize(other.rows(), other.cols()); ei_assign_impl<ei_unaligned_type,aligned_base,NoVectorization>::run(*this, other); } }; diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index a95da9995..5349029bf 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -25,7 +25,6 @@ #ifndef EIGEN_MATRIX_H #define EIGEN_MATRIX_H -struct ei_select_matrix_constructor_doing_absolutely_nothing {}; /** \class Matrix * @@ -133,8 +132,8 @@ class Matrix protected: ei_matrix_storage<Scalar, MaxSizeAtCompileTime, RowsAtCompileTime, ColsAtCompileTime, Options> m_storage; - Matrix(ei_select_matrix_constructor_doing_absolutely_nothing) // this ctor does not even do an assertion - : m_storage(ei_select_matrix_storage_constructor_doing_absolutely_nothing()) {} + Matrix(ei_constructor_without_unaligned_array_assert) + : m_storage(ei_constructor_without_unaligned_array_assert()) {} public: enum { NeedsToAlign = (Options&AutoAlign) == AutoAlign diff --git a/Eigen/src/Core/MatrixStorage.h b/Eigen/src/Core/MatrixStorage.h index a1a10ead5..972ea558a 100644 --- a/Eigen/src/Core/MatrixStorage.h +++ b/Eigen/src/Core/MatrixStorage.h @@ -26,8 +26,7 @@ #ifndef EIGEN_MATRIXSTORAGE_H #define EIGEN_MATRIXSTORAGE_H -struct ei_select_matrix_storage_constructor_doing_absolutely_nothing {}; -struct ei_select_matrix_array_constructor_doing_absolutely_nothing {}; +struct ei_constructor_without_unaligned_array_assert {}; /** \internal * Static array automatically aligned if the total byte size is a multiple of 16 and the matrix options require auto alignment @@ -46,14 +45,14 @@ template <typename T, int Size, int MatrixOptions, #endif } - ei_matrix_array(ei_select_matrix_array_constructor_doing_absolutely_nothing) {} + ei_matrix_array(ei_constructor_without_unaligned_array_assert) {} }; template <typename T, int Size, int MatrixOptions> struct ei_matrix_array<T,Size,MatrixOptions,false> { T array[Size]; ei_matrix_array() {} - ei_matrix_array(ei_select_matrix_array_constructor_doing_absolutely_nothing) {} + ei_matrix_array(ei_constructor_without_unaligned_array_assert) {} }; /** \internal @@ -75,8 +74,8 @@ template<typename T, int Size, int _Rows, int _Cols, int _Options> class ei_matr ei_matrix_array<T,Size,_Options> m_data; public: inline explicit ei_matrix_storage() {} - inline ei_matrix_storage(ei_select_matrix_storage_constructor_doing_absolutely_nothing) - : m_data(ei_select_matrix_array_constructor_doing_absolutely_nothing()) {} + inline ei_matrix_storage(ei_constructor_without_unaligned_array_assert) + : m_data(ei_constructor_without_unaligned_array_assert()) {} inline ei_matrix_storage(int,int,int) {} inline void swap(ei_matrix_storage& other) { std::swap(m_data,other.m_data); } inline static int rows(void) {return _Rows;} @@ -94,8 +93,8 @@ template<typename T, int Size, int _Options> class ei_matrix_storage<T, Size, Dy int m_cols; public: inline explicit ei_matrix_storage() : m_rows(0), m_cols(0) {} - inline ei_matrix_storage(ei_select_matrix_storage_constructor_doing_absolutely_nothing) - : m_data(ei_select_matrix_array_constructor_doing_absolutely_nothing()) {} + inline ei_matrix_storage(ei_constructor_without_unaligned_array_assert) + : m_data(ei_constructor_without_unaligned_array_assert()), m_rows(0), m_cols(0) {} inline ei_matrix_storage(int, int rows, int cols) : m_rows(rows), m_cols(cols) {} inline ~ei_matrix_storage() {} inline void swap(ei_matrix_storage& other) @@ -118,8 +117,8 @@ template<typename T, int Size, int _Cols, int _Options> class ei_matrix_storage< int m_rows; public: inline explicit ei_matrix_storage() : m_rows(0) {} - inline ei_matrix_storage(ei_select_matrix_storage_constructor_doing_absolutely_nothing) - : m_data(ei_select_matrix_array_constructor_doing_absolutely_nothing()) {} + inline ei_matrix_storage(ei_constructor_without_unaligned_array_assert) + : m_data(ei_constructor_without_unaligned_array_assert()), m_rows(0) {} inline ei_matrix_storage(int, int rows, int) : m_rows(rows) {} inline ~ei_matrix_storage() {} inline void swap(ei_matrix_storage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); } @@ -140,8 +139,8 @@ template<typename T, int Size, int _Rows, int _Options> class ei_matrix_storage< int m_cols; public: inline explicit ei_matrix_storage() : m_cols(0) {} - inline ei_matrix_storage(ei_select_matrix_storage_constructor_doing_absolutely_nothing) - : m_data(ei_select_matrix_array_constructor_doing_absolutely_nothing()) {} + inline ei_matrix_storage(ei_constructor_without_unaligned_array_assert) + : m_data(ei_constructor_without_unaligned_array_assert()), m_cols(0) {} inline ei_matrix_storage(int, int, int cols) : m_cols(cols) {} inline ~ei_matrix_storage() {} inline void swap(ei_matrix_storage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); } @@ -163,8 +162,8 @@ template<typename T, int _Options> class ei_matrix_storage<T, Dynamic, Dynamic, int m_cols; public: inline explicit ei_matrix_storage() : m_data(0), m_rows(0), m_cols(0) {} - inline ei_matrix_storage(ei_select_matrix_storage_constructor_doing_absolutely_nothing) - : m_data(ei_select_matrix_array_constructor_doing_absolutely_nothing()) {} + inline ei_matrix_storage(ei_constructor_without_unaligned_array_assert) + : m_data(0), m_rows(0), m_cols(0) {} inline ei_matrix_storage(int size, int rows, int cols) : m_data(ei_aligned_new<T>(size)), m_rows(rows), m_cols(cols) {} inline ~ei_matrix_storage() { ei_aligned_delete(m_data, m_rows*m_cols); } @@ -193,8 +192,7 @@ template<typename T, int _Rows, int _Options> class ei_matrix_storage<T, Dynamic int m_cols; public: inline explicit ei_matrix_storage() : m_data(0), m_cols(0) {} - inline ei_matrix_storage(ei_select_matrix_storage_constructor_doing_absolutely_nothing) - : m_data(ei_select_matrix_array_constructor_doing_absolutely_nothing()) {} + inline ei_matrix_storage(ei_constructor_without_unaligned_array_assert) : m_data(0), m_cols(0) {} inline ei_matrix_storage(int size, int, int cols) : m_data(ei_aligned_new<T>(size)), m_cols(cols) {} inline ~ei_matrix_storage() { ei_aligned_delete(m_data, _Rows*m_cols); } inline void swap(ei_matrix_storage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); } @@ -220,8 +218,7 @@ template<typename T, int _Cols, int _Options> class ei_matrix_storage<T, Dynamic int m_rows; public: inline explicit ei_matrix_storage() : m_data(0), m_rows(0) {} - inline ei_matrix_storage(ei_select_matrix_storage_constructor_doing_absolutely_nothing) - : m_data(ei_select_matrix_array_constructor_doing_absolutely_nothing()) {} + inline ei_matrix_storage(ei_constructor_without_unaligned_array_assert) : m_data(0), m_rows(0) {} inline ei_matrix_storage(int size, int rows, int) : m_data(ei_aligned_new<T>(size)), m_rows(rows) {} inline ~ei_matrix_storage() { ei_aligned_delete(m_data, _Cols*m_rows); } inline void swap(ei_matrix_storage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); } |