aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2012-03-29 11:29:43 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2012-03-29 11:29:43 +0200
commitc172abdcc74c42ed1bb7028636f0c8ca38c34373 (patch)
treeebecbee6fa3092d2d25f504d80fe3223d0bb7d37 /test
parent8ff882aa4cca8cd3e809a16bfb4e55db1b8277e2 (diff)
add sparse * permutation products with assiciated unit tests
Diffstat (limited to 'test')
-rw-r--r--test/sparse_permutations.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/sparse_permutations.cpp b/test/sparse_permutations.cpp
index 522e78f67..4d22e358e 100644
--- a/test/sparse_permutations.cpp
+++ b/test/sparse_permutations.cpp
@@ -59,6 +59,26 @@ template<int OtherStorage, typename SparseMatrixType> void sparse_permutations(c
randomPermutationVector(pi, cols);
p.indices() = pi;
+ res = mat*p;
+ res_d = mat_d*p;
+ VERIFY(res.isApprox(res_d) && "mat*p");
+
+ res = p*mat;
+ res_d = p*mat_d;
+ VERIFY(res.isApprox(res_d) && "p*mat");
+
+ res = mat*p.inverse();
+ res_d = mat*p.inverse();
+ VERIFY(res.isApprox(res_d) && "mat*inv(p)");
+
+ res = p.inverse()*mat;
+ res_d = p.inverse()*mat_d;
+ VERIFY(res.isApprox(res_d) && "inv(p)*mat");
+
+ res = mat.twistedBy(p);
+ res_d = (p * mat_d) * p.inverse();
+ VERIFY(res.isApprox(res_d) && "p*mat*inv(p)");
+
res = mat.template selfadjointView<Upper>().twistedBy(p_null);
res_d = up_sym_d;
@@ -76,6 +96,41 @@ template<int OtherStorage, typename SparseMatrixType> void sparse_permutations(c
res = lo.template selfadjointView<Lower>().twistedBy(p_null);
res_d = lo_sym_d;
VERIFY(res.isApprox(res_d) && "lower selfadjoint full");
+
+
+ res = mat.template selfadjointView<Upper>();
+ res_d = up_sym_d;
+ VERIFY(res.isApprox(res_d) && "full selfadjoint upper to full");
+
+ res = mat.template selfadjointView<Lower>();
+ res_d = lo_sym_d;
+ VERIFY(res.isApprox(res_d) && "full selfadjoint lower to full");
+
+ res = up.template selfadjointView<Upper>();
+ res_d = up_sym_d;
+ VERIFY(res.isApprox(res_d) && "upper selfadjoint to full");
+
+ res = lo.template selfadjointView<Lower>();
+ res_d = lo_sym_d;
+ VERIFY(res.isApprox(res_d) && "lower selfadjoint full");
+
+
+ res.template selfadjointView<Upper>() = mat.template selfadjointView<Upper>();
+ res_d = up_sym_d.template triangularView<Upper>();
+ VERIFY(res.isApprox(res_d) && "full selfadjoint upper to upper");
+
+ res.template selfadjointView<Lower>() = mat.template selfadjointView<Upper>();
+ res_d = up_sym_d.template triangularView<Lower>();
+ VERIFY(res.isApprox(res_d) && "full selfadjoint upper to lower");
+
+ res.template selfadjointView<Upper>() = mat.template selfadjointView<Lower>();
+ res_d = lo_sym_d.template triangularView<Upper>();
+ VERIFY(res.isApprox(res_d) && "full selfadjoint lower to upper");
+
+ res.template selfadjointView<Lower>() = mat.template selfadjointView<Lower>();
+ res_d = lo_sym_d.template triangularView<Lower>();
+ VERIFY(res.isApprox(res_d) && "full selfadjoint lower to lower");
+
res.template selfadjointView<Upper>() = mat.template selfadjointView<Upper>().twistedBy(p);