From a9232af845702d62d81c49b4d92b39f29410cea0 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 16 Jan 2017 16:17:01 +0100 Subject: Introduce a variable_or_fixed proxy returned by fix(val) to pass both a compile-time and runtime fallback value in case N means "runtime". This mechanism is used by the seq/seqN functions. The proxy object is immediately converted to pure compile-time (as fix) or pure runtime (i.e., an Index) to avoid redundant template instantiations. --- test/indexed_view.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'test/indexed_view.cpp') diff --git a/test/indexed_view.cpp b/test/indexed_view.cpp index e2c0e886d..472268010 100644 --- a/test/indexed_view.cpp +++ b/test/indexed_view.cpp @@ -8,7 +8,12 @@ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifdef EIGEN_TEST_PART_2 -// Make sure we also check c++98 implementation +// Make sure we also check c++11 max implementation +#define EIGEN_MAX_CPP_VER 11 +#endif + +#ifdef EIGEN_TEST_PART_3 +// Make sure we also check c++98 max implementation #define EIGEN_MAX_CPP_VER 03 #endif @@ -49,6 +54,13 @@ is_same_type(const T1& a, const T2& b) return (a == b).all(); } +template +typename internal::enable_if::value,bool>::type +is_same_seq_type(const T1& a, const T2& b) +{ + return a.size() == b.size() && a.first()==b.first() && Index(a.incrObject())==Index(b.incrObject()); +} + void check_indexed_view() { using Eigen::placeholders::all; @@ -157,6 +169,23 @@ void check_indexed_view() VERIFY_IS_EQUAL( (B(seqN(1,2,fix<2>), seq(1,3,fix<3>))).InnerStrideAtCompileTime , 2); VERIFY_IS_EQUAL( (B(seqN(1,2,fix<2>), seq(1,3,fix<3>))).OuterStrideAtCompileTime , 3*4); + VERIFY_IS_EQUAL( (A(seqN(2,fix<5>), seqN(1,fix<3>))).RowsAtCompileTime, 5); + VERIFY_IS_EQUAL( (A(seqN(2,fix<5>), seqN(1,fix<3>))).ColsAtCompileTime, 3); + VERIFY_IS_EQUAL( (A(seqN(2,fix<5>(5)), seqN(1,fix<3>(3)))).RowsAtCompileTime, 5); + VERIFY_IS_EQUAL( (A(seqN(2,fix<5>(5)), seqN(1,fix<3>(3)))).ColsAtCompileTime, 3); + VERIFY_IS_EQUAL( (A(seqN(2,fix(5)), seqN(1,fix(3)))).RowsAtCompileTime, Dynamic); + VERIFY_IS_EQUAL( (A(seqN(2,fix(5)), seqN(1,fix(3)))).ColsAtCompileTime, Dynamic); + VERIFY_IS_EQUAL( (A(seqN(2,fix(5)), seqN(1,fix(3)))).rows(), 5); + VERIFY_IS_EQUAL( (A(seqN(2,fix(5)), seqN(1,fix(3)))).cols(), 3); + + VERIFY( is_same_seq_type( seqN(2,5,fix<-1>), seqN(2,5,fix<-1>(-1)) ) ); + VERIFY( is_same_seq_type( seqN(2,5), seqN(2,5,fix<1>(1)) ) ); + VERIFY( is_same_seq_type( seqN(2,5,3), seqN(2,5,fix(3)) ) ); + VERIFY( is_same_seq_type( seq(2,7,fix<3>), seqN(2,2,fix<3>) ) ); + VERIFY( is_same_seq_type( seqN(2,fix(5),3), seqN(2,5,fix(3)) ) ); + VERIFY( is_same_seq_type( seqN(2,fix<5>(5),fix<-2>), seqN(2,fix<5>,fix<-2>()) ) ); + + VERIFY( (A(seqN(2,fix<5>), 5)).RowsAtCompileTime == 5); VERIFY( (A(4, all)).ColsAtCompileTime == Dynamic); VERIFY( (A(4, all)).RowsAtCompileTime == 1); -- cgit v1.2.3