* Added support for a comma initializer: mat.block(i,j,2,2) << 1, 2, 3, 4;

If the number of coefficients does not match the matrix size, then an assertion is raised.
  No support for xpr on the right side for the moment.

* Added support for assertion checking. This allows to test that an assertion is indeed raised
  when it should be.

* Fixed a mistake in the CwiseUnary example.
This commit is contained in:
Gael Guennebaud
2008-03-08 19:02:24 +00:00
parent 138aad0ed0
commit 721626dfc5
13 changed files with 259 additions and 67 deletions

View File

@@ -5,12 +5,12 @@
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -18,7 +18,7 @@
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// You should have received a copy of the GNU Lesser General Public
// License and a copy of the GNU General Public License along with
// Eigen. If not, see <http://www.gnu.org/licenses/>.
@@ -27,15 +27,80 @@
#include <QtTest/QtTest>
//#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER RowMajor
#define EIGEN_INTERNAL_DEBUGGING
#include <Eigen/Core>
#include <cstdlib>
#include <ctime>
#define DEFAULT_REPEAT 50
#ifndef EIGEN_NO_ASSERTION_CHECKING
namespace Eigen
{
struct ei_assert_exception
{};
static const bool should_raise_an_assert = false;
}
#define EI_PP_MAKE_STRING2(S) #S
#define EI_PP_MAKE_STRING(S) EI_PP_MAKE_STRING2(S)
#ifdef assert
#undef assert
#endif
// If EIGEN_DEBUG_ASSERTS is defined and if no assertion is raised while
// one should have been, then the list of excecuted assertions is printed out.
//
// EIGEN_DEBUG_ASSERTS is not enabled by default as it
// significantly increases the compilation time
// and might even introduce side effects that would hide
// some memory errors.
#ifdef EIGEN_DEBUG_ASSERTS
namespace Eigen
{
static bool ei_push_assert = false;
static std::vector<std::string> ei_assert_list;
}
#define assert(a) if (!(a)) { throw Eigen::ei_assert_exception();} \
else if (Eigen::ei_push_assert) {ei_assert_list.push_back( std::string(EI_PP_MAKE_STRING(__FILE__)) + " (" + EI_PP_MAKE_STRING(__LINE__) + ") : " + #a );}
#define VERIFY_RAISES_ASSERT(a) {\
try { \
Eigen::ei_assert_list.clear(); \
Eigen::ei_push_assert = true; \
a; \
Eigen::ei_push_assert = false; \
std::cout << "One of the following asserts should have been raised:\n"; \
for (uint ai=0 ; ai<ei_assert_list.size() ; ++ai) \
std::cout << " " << ei_assert_list[ai] << "\n"; \
QVERIFY(Eigen::should_raise_an_assert && # a); \
} catch (Eigen::ei_assert_exception e) { Eigen::ei_push_assert = false; QVERIFY(true);} }
#else // EIGEN_DEBUG_ASSERTS
#define assert(a) if (!(a)) { throw Eigen::ei_assert_exception();}
#define VERIFY_RAISES_ASSERT(a) {\
try {a; QVERIFY(Eigen::should_raise_an_assert && # a); } \
catch (Eigen::ei_assert_exception e) { QVERIFY(true);} }
#endif // EIGEN_DEBUG_ASSERTS
#define EIGEN_CUSTOM_ASSERT
#else // EIGEN_NO_ASSERTION_CHECKING
#define VERIFY_RAISES_ASSERT(a) {}
#endif // EIGEN_NO_ASSERTION_CHECKING
//#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER RowMajor
#define EIGEN_INTERNAL_DEBUGGING
#include <Eigen/Core>
#define VERIFY(a) QVERIFY(a)
#define VERIFY_IS_APPROX(a, b) QVERIFY(test_ei_isApprox(a, b))
#define VERIFY_IS_NOT_APPROX(a, b) QVERIFY(!test_ei_isApprox(a, b))