relax Matrix/Array(Index) ctors to allow size 0, add test.

This commit is contained in:
Benoit Jacob 2011-02-01 07:46:02 -05:00
parent faa1284c12
commit 2d09b11a97
4 changed files with 8 additions and 3 deletions

View File

@ -147,7 +147,7 @@ class Array
{ {
Base::_check_template_params(); Base::_check_template_params();
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Array) EIGEN_STATIC_ASSERT_VECTOR_ONLY(Array)
eigen_assert(dim > 0); eigen_assert(dim >= 0);
eigen_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim); eigen_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim);
EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
} }

View File

@ -235,7 +235,7 @@ class Matrix
{ {
Base::_check_template_params(); Base::_check_template_params();
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Matrix) EIGEN_STATIC_ASSERT_VECTOR_ONLY(Matrix)
eigen_assert(dim > 0); eigen_assert(dim >= 0);
eigen_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim); eigen_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim);
EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
} }

View File

@ -22,7 +22,11 @@ and gives tips to help porting your application from Eigen2 to Eigen3.
\section CompatibilitySupport Eigen2 compatibility support \section CompatibilitySupport Eigen2 compatibility support
In order to ease the switch from Eigen2 to Eigen3, Eigen3 features a compatibility mode which can be enabled by defining the EIGEN2_SUPPORT preprocessor token \b before including any Eigen header (typically it should be set in your project options). In order to ease the switch from Eigen2 to Eigen3, Eigen3 features a Eigen2 support modes \ref TopicResizing "this page"..
The quick way to enable this is to define the EIGEN2_SUPPORT preprocessor token \b before including any Eigen header (typically it should be set in your project options).
Moreover, we also provided a staged migration path which may be useful to migrate large projects
\section Using The USING_PART_OF_NAMESPACE_EIGEN macro \section Using The USING_PART_OF_NAMESPACE_EIGEN macro

View File

@ -121,6 +121,7 @@ ei_add_test(permutationmatrices)
ei_add_test(eigen2support) ei_add_test(eigen2support)
ei_add_test(nullary) ei_add_test(nullary)
ei_add_test(nesting_ops "${CMAKE_CXX_FLAGS_DEBUG}") ei_add_test(nesting_ops "${CMAKE_CXX_FLAGS_DEBUG}")
ei_add_test(zerosized)
ei_add_test(prec_inverse_4x4) ei_add_test(prec_inverse_4x4)