aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/permutationmatrices.cpp
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2015-06-10 09:32:10 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2015-06-10 09:32:10 +0200
commite6832ce93d47e231dd0a2bbbd080fc4b7b420e93 (patch)
tree60f19069ceb8cafcae1b8368f8980f23847218b3 /test/permutationmatrices.cpp
parent0b2cbb2bdc6ea55654da7a11887e823cd619b842 (diff)
Add regression test for bug #890
Diffstat (limited to 'test/permutationmatrices.cpp')
-rw-r--r--test/permutationmatrices.cpp25
1 files changed, 25 insertions, 0 deletions
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<typename MatrixType> void permutationmatrices(const MatrixType& m)
}
}
+template<typename T>
+void bug890()
+{
+ typedef Matrix<T, Dynamic, Dynamic> MatrixType;
+ typedef Matrix<T, Dynamic, 1> VectorType;
+ typedef Stride<Dynamic,Dynamic> S;
+ typedef Map<MatrixType, Aligned, S> MapType;
+ typedef PermutationMatrix<Dynamic> 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<double,Dynamic,Dynamic,RowMajor>(20, 30)) );
CALL_SUBTEST_7( permutationmatrices(MatrixXcf(15, 10)) );
}
+ CALL_SUBTEST_5( bug890<double>() );
}