From e6832ce93d47e231dd0a2bbbd080fc4b7b420e93 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 10 Jun 2015 09:32:10 +0200 Subject: Add regression test for bug #890 --- test/permutationmatrices.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test/permutationmatrices.cpp') diff --git a/test/permutationmatrices.cpp b/test/permutationmatrices.cpp index 7b0dbc763..7fd4c5ebb 100644 --- a/test/permutationmatrices.cpp +++ b/test/permutationmatrices.cpp @@ -102,6 +102,30 @@ template void permutationmatrices(const MatrixType& m) } } +template +void bug890() +{ + typedef Matrix MatrixType; + typedef Matrix VectorType; + typedef Stride S; + typedef Map MapType; + typedef PermutationMatrix Perm; + + VectorType v1(2), v2(2), op(4), rhs(2); + v1 << 666,667; + op << 1,0,0,1; + rhs << 42,42; + + Perm P(2); + P.indices() << 1, 0; + + MapType(v1.data(),2,1,S(1,1)) = P * MapType(rhs.data(),2,1,S(1,1)); + VERIFY_IS_APPROX(v1, (P * rhs).eval()); + + MapType(v1.data(),2,1,S(1,1)) = P.inverse() * MapType(rhs.data(),2,1,S(1,1)); + VERIFY_IS_APPROX(v1, (P.inverse() * rhs).eval()); +} + void test_permutationmatrices() { for(int i = 0; i < g_repeat; i++) { @@ -113,4 +137,5 @@ void test_permutationmatrices() CALL_SUBTEST_6( permutationmatrices(Matrix(20, 30)) ); CALL_SUBTEST_7( permutationmatrices(MatrixXcf(15, 10)) ); } + CALL_SUBTEST_5( bug890() ); } -- cgit v1.2.3