aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/sparse_ref.cpp
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2015-10-06 17:23:11 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2015-10-06 17:23:11 +0200
commit27a94299aaf38be8510253235751fe55bb3e3f6f (patch)
treecfcec9ce0a07c31bdf885084e7f65688f3513b02 /test/sparse_ref.cpp
parent2e0ece7b66ddadb29db2a255a55ee157279eb037 (diff)
Add sparse vector to Ref<SparseMatrix> conversion unit tests, and improve output of sparse_ref unit test in case of failure.
Diffstat (limited to 'test/sparse_ref.cpp')
-rw-r--r--test/sparse_ref.cpp7
1 files changed, 6 insertions, 1 deletions
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<float>& Ac(A);
Block<SparseMatrix<float> > Ab(A,0,1, 3,3);
const Block<SparseMatrix<float> > Abc(A,0,1,3,3);
+ SparseVector<float> vc = VectorXf::Random(10).sparseView(0.5,1);
+ SparseVector<float,RowMajor> vr = VectorXf::Random(10).sparseView(0.5,1);
SparseMatrix<float> 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)
}