diff options
author | Gael Guennebaud <g.gael@free.fr> | 2017-01-10 14:25:30 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2017-01-10 14:25:30 +0100 |
commit | 87963f441c9abd8514b94b6b2c712652d646ed64 (patch) | |
tree | 9988b56b0a9d0692b76072d9298ddb488be2e660 /test/indexed_view.cpp | |
parent | a98c7efb163a1183d61ae56cacc7d903057285f0 (diff) |
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.
Diffstat (limited to 'test/indexed_view.cpp')
-rw-r--r-- | test/indexed_view.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
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 T1,typename T2> +typename internal::enable_if<internal::is_same<T1,T2>::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<int,4>{{1,3,2,4}})).ColsAtCompileTime == 4); |