From 27a94299aaf38be8510253235751fe55bb3e3f6f Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 6 Oct 2015 17:23:11 +0200 Subject: Add sparse vector to Ref conversion unit tests, and improve output of sparse_ref unit test in case of failure. --- test/sparse_ref.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'test/sparse_ref.cpp') diff --git a/test/sparse_ref.cpp b/test/sparse_ref.cpp index 93fb5efe7..d2d475616 100644 --- a/test/sparse_ref.cpp +++ b/test/sparse_ref.cpp @@ -26,7 +26,7 @@ inline void on_temporary_creation() { #define VERIFY_EVALUATION_COUNT(XPR,N) {\ nb_temporaries = 0; \ - XPR; \ + CALL_SUBTEST( XPR ); \ if(nb_temporaries!=N) std::cerr << "nb_temporaries == " << nb_temporaries << "\n"; \ VERIFY( (#XPR) && nb_temporaries==N ); \ } @@ -64,6 +64,8 @@ void call_ref() const SparseMatrix& Ac(A); Block > Ab(A,0,1, 3,3); const Block > Abc(A,0,1,3,3); + SparseVector vc = VectorXf::Random(10).sparseView(0.5,1); + SparseVector vr = VectorXf::Random(10).sparseView(0.5,1); SparseMatrix AA = A*A; @@ -104,6 +106,9 @@ void call_ref() VERIFY_EVALUATION_COUNT( call_ref_2(A.middleCols(1,3), A.middleCols(1,3)), 0); VERIFY_EVALUATION_COUNT( call_ref_2(A.col(2), A.col(2)), 0); + VERIFY_EVALUATION_COUNT( call_ref_2(vc, vc), 0); + VERIFY_EVALUATION_COUNT( call_ref_2(vr.transpose(), vr.transpose()), 0); + VERIFY_EVALUATION_COUNT( call_ref_2(vr, vr.transpose()), 0); VERIFY_EVALUATION_COUNT( call_ref_2(A.block(1,1,3,3), A.block(1,1,3,3)), 1); // should be 0 (allocate starts/nnz only) } -- cgit v1.2.3