diff options
author | Miao Wang <miaowang@google.com> | 2017-03-06 13:45:08 -0800 |
---|---|---|
committer | Miao Wang <miaowang@google.com> | 2017-03-07 16:30:11 -0800 |
commit | 2b8756b6f1de65d3f8bffab45be6c44ceb7411fc (patch) | |
tree | 0488797fc544fe977bec6418c73445759f052482 /test/commainitializer.cpp | |
parent | 353bba589de58014a35f8f3666b7b96353c300f8 (diff) | |
download | eigen-2b8756b6f1de65d3f8bffab45be6c44ceb7411fc.tar.gz |
Rebase Eigen to 3.3.3.
Bug: 34161771
Test: mm and RenderScript BLAS tests pass on bullhead.
Change-Id: Ia448b3202708e395fed9c783ea4323289d69dbef
Diffstat (limited to 'test/commainitializer.cpp')
-rw-r--r-- | test/commainitializer.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/test/commainitializer.cpp b/test/commainitializer.cpp index 99102b966..9844adbd2 100644 --- a/test/commainitializer.cpp +++ b/test/commainitializer.cpp @@ -9,6 +9,62 @@ #include "main.h" + +template<int M1, int M2, int N1, int N2> +void test_blocks() +{ + Matrix<int, M1+M2, N1+N2> m_fixed; + MatrixXi m_dynamic(M1+M2, N1+N2); + + Matrix<int, M1, N1> mat11; mat11.setRandom(); + Matrix<int, M1, N2> mat12; mat12.setRandom(); + Matrix<int, M2, N1> mat21; mat21.setRandom(); + Matrix<int, M2, N2> mat22; mat22.setRandom(); + + MatrixXi matx11 = mat11, matx12 = mat12, matx21 = mat21, matx22 = mat22; + + { + VERIFY_IS_EQUAL((m_fixed << mat11, mat12, mat21, matx22).finished(), (m_dynamic << mat11, matx12, mat21, matx22).finished()); + VERIFY_IS_EQUAL((m_fixed.template topLeftCorner<M1,N1>()), mat11); + VERIFY_IS_EQUAL((m_fixed.template topRightCorner<M1,N2>()), mat12); + VERIFY_IS_EQUAL((m_fixed.template bottomLeftCorner<M2,N1>()), mat21); + VERIFY_IS_EQUAL((m_fixed.template bottomRightCorner<M2,N2>()), mat22); + VERIFY_IS_EQUAL((m_fixed << mat12, mat11, matx21, mat22).finished(), (m_dynamic << mat12, matx11, matx21, mat22).finished()); + } + + if(N1 > 0) + { + VERIFY_RAISES_ASSERT((m_fixed << mat11, mat12, mat11, mat21, mat22)); + VERIFY_RAISES_ASSERT((m_fixed << mat11, mat12, mat21, mat21, mat22)); + } + else + { + // allow insertion of zero-column blocks: + VERIFY_IS_EQUAL((m_fixed << mat11, mat12, mat11, mat11, mat21, mat21, mat22).finished(), (m_dynamic << mat12, mat22).finished()); + } + if(M1 != M2) + { + VERIFY_RAISES_ASSERT((m_fixed << mat11, mat21, mat12, mat22)); + } +} + + +template<int N> +struct test_block_recursion +{ + static void run() + { + test_blocks<(N>>6)&3, (N>>4)&3, (N>>2)&3, N & 3>(); + test_block_recursion<N-1>::run(); + } +}; + +template<> +struct test_block_recursion<-1> +{ + static void run() { } +}; + void test_commainitializer() { Matrix3d m3; @@ -43,4 +99,8 @@ void test_commainitializer() 4, 5, 6, vec[2].transpose(); VERIFY_IS_APPROX(m3, ref); + + + // recursively test all block-sizes from 0 to 3: + test_block_recursion<(1<<8) - 1>(); } |