From c172abdcc74c42ed1bb7028636f0c8ca38c34373 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 29 Mar 2012 11:29:43 +0200 Subject: add sparse * permutation products with assiciated unit tests --- test/sparse_permutations.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'test/sparse_permutations.cpp') 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 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().twistedBy(p_null); res_d = up_sym_d; @@ -76,6 +96,41 @@ template void sparse_permutations(c res = lo.template selfadjointView().twistedBy(p_null); res_d = lo_sym_d; VERIFY(res.isApprox(res_d) && "lower selfadjoint full"); + + + res = mat.template selfadjointView(); + res_d = up_sym_d; + VERIFY(res.isApprox(res_d) && "full selfadjoint upper to full"); + + res = mat.template selfadjointView(); + res_d = lo_sym_d; + VERIFY(res.isApprox(res_d) && "full selfadjoint lower to full"); + + res = up.template selfadjointView(); + res_d = up_sym_d; + VERIFY(res.isApprox(res_d) && "upper selfadjoint to full"); + + res = lo.template selfadjointView(); + res_d = lo_sym_d; + VERIFY(res.isApprox(res_d) && "lower selfadjoint full"); + + + res.template selfadjointView() = mat.template selfadjointView(); + res_d = up_sym_d.template triangularView(); + VERIFY(res.isApprox(res_d) && "full selfadjoint upper to upper"); + + res.template selfadjointView() = mat.template selfadjointView(); + res_d = up_sym_d.template triangularView(); + VERIFY(res.isApprox(res_d) && "full selfadjoint upper to lower"); + + res.template selfadjointView() = mat.template selfadjointView(); + res_d = lo_sym_d.template triangularView(); + VERIFY(res.isApprox(res_d) && "full selfadjoint lower to upper"); + + res.template selfadjointView() = mat.template selfadjointView(); + res_d = lo_sym_d.template triangularView(); + VERIFY(res.isApprox(res_d) && "full selfadjoint lower to lower"); + res.template selfadjointView() = mat.template selfadjointView().twistedBy(p); -- cgit v1.2.3