From 87963f441c9abd8514b94b6b2c712652d646ed64 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 10 Jan 2017 14:25:30 +0100 Subject: Fallback to Block<> when possible (Index, all, seq with > increment). This is important to take advantage of the optimized implementations (evaluator, products, etc.), and to support sparse matrices. --- test/indexed_view.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/indexed_view.cpp') diff --git a/test/indexed_view.cpp b/test/indexed_view.cpp index e04fe0cd4..fde3ee8f9 100644 --- a/test/indexed_view.cpp +++ b/test/indexed_view.cpp @@ -41,6 +41,13 @@ bool match(const T& xpr, std::string ref, std::string str_xpr = "") { #define MATCH(X,R) match(X, R, #X) +template +typename internal::enable_if::value,bool>::type +is_same_type(const T1& a, const T2& b) +{ + return (a == b).all(); +} + void check_indexed_view() { using Eigen::placeholders::last; @@ -159,6 +166,16 @@ void check_indexed_view() VERIFY_IS_APPROX( A(seq(1,n-1-2), seq(n-1-5,7)), A(seq(1,last-2), seq(last-5,7)) ); VERIFY_IS_APPROX( A(seq(n-1-5,n-1-2), seq(n-1-5,n-1-2)), A(seq(last-5,last-2), seq(last-5,last-2)) ); + // Check fall-back to Block + { + const ArrayXXi& cA(A); + VERIFY( is_same_type(cA.col(0), cA(all,0)) ); + VERIFY( is_same_type(cA.row(0), cA(0,all)) ); + VERIFY( is_same_type(cA.block(0,0,2,2), cA(seqN(0,2),seq(0,1))) ); + VERIFY( is_same_type(cA.middleRows(2,4), cA(seqN(2,4),all)) ); + VERIFY( is_same_type(cA.middleCols(2,4), cA(all,seqN(2,4))) ); + } + #if EIGEN_HAS_CXX11 VERIFY( (A(all, std::array{{1,3,2,4}})).ColsAtCompileTime == 4); -- cgit v1.2.3