diff options
author | Benoit Jacob <jacob.benoit.1@gmail.com> | 2010-12-22 17:45:37 -0500 |
---|---|---|
committer | Benoit Jacob <jacob.benoit.1@gmail.com> | 2010-12-22 17:45:37 -0500 |
commit | 75b7d98665dd144c44d7a113c6613f5f998be626 (patch) | |
tree | bc75d316e2ed8e679e744bc34f159dcb0f285243 /test | |
parent | 3b6d97b51a7e7a4b0c69ae6be44b1c16d72c2e80 (diff) |
bug #54 - really fix const correctness except in Sparse
Diffstat (limited to 'test')
-rw-r--r-- | test/block.cpp | 14 | ||||
-rw-r--r-- | test/product_notemporary.cpp | 8 |
2 files changed, 19 insertions, 3 deletions
diff --git a/test/block.cpp b/test/block.cpp index 6c5681683..70852ee48 100644 --- a/test/block.cpp +++ b/test/block.cpp @@ -39,6 +39,7 @@ template<typename MatrixType> void block(const MatrixType& m) Index cols = m.cols(); MatrixType m1 = MatrixType::Random(rows, cols), + m1_copy = m1, m2 = MatrixType::Random(rows, cols), m3(rows, cols), mzero = MatrixType::Zero(rows, cols), @@ -58,8 +59,17 @@ template<typename MatrixType> void block(const MatrixType& m) //check row() and col() VERIFY_IS_EQUAL(m1.col(c1).transpose(), m1.transpose().row(c1)); //check operator(), both constant and non-constant, on row() and col() - m1.row(r1) += s1 * m1.row(r2); - m1.col(c1) += s1 * m1.col(c2); + m1 = m1_copy; + m1.row(r1) += s1 * m1_copy.row(r2); + VERIFY_IS_APPROX(m1.row(r1), m1_copy.row(r1) + s1 * m1_copy.row(r2)); + // check nested block xpr on lhs + m1.row(r1).row(0) += s1 * m1_copy.row(r2); + VERIFY_IS_APPROX(m1.row(r1), m1_copy.row(r1) + Scalar(2) * s1 * m1_copy.row(r2)); + m1 = m1_copy; + m1.col(c1) += s1 * m1_copy.col(c2); + VERIFY_IS_APPROX(m1.col(c1), m1_copy.col(c1) + s1 * m1_copy.col(c2)); + m1.col(c1).col(0) += s1 * m1_copy.col(c2); + VERIFY_IS_APPROX(m1.col(c1), m1_copy.col(c1) + Scalar(2) * s1 * m1_copy.col(c2)); //check block() Matrix<Scalar,Dynamic,Dynamic> b1(1,1); b1(0,0) = m1(r1,c1); diff --git a/test/product_notemporary.cpp b/test/product_notemporary.cpp index e5dd964c0..f4f846602 100644 --- a/test/product_notemporary.cpp +++ b/test/product_notemporary.cpp @@ -24,7 +24,13 @@ static int nb_temporaries; -#define EIGEN_DEBUG_MATRIX_CTOR { if(size!=0) nb_temporaries++; } +void on_temporary_creation(int size) { + // here's a great place to set a breakpoint when debugging failures in this test! + if(size!=0) nb_temporaries++; +} + + +#define EIGEN_DEBUG_MATRIX_CTOR { on_temporary_creation(size); } #include "main.h" |