From df0c8b5d846d757d600020321c563b43b176aa87 Mon Sep 17 00:00:00 2001 From: Michael Marshall Date: Fri, 15 Feb 2019 13:52:49 +0000 Subject: [PATCH] Test of Eigen slices --- tests/hadrons/Test_hadrons_distil.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/hadrons/Test_hadrons_distil.cc b/tests/hadrons/Test_hadrons_distil.cc index 685f5f13..6c871df3 100644 --- a/tests/hadrons/Test_hadrons_distil.cc +++ b/tests/hadrons/Test_hadrons_distil.cc @@ -506,6 +506,25 @@ bool DebugFelixTensorTest( void ) std::vector Memory(Nmom * Nt * N_1 * N_2 * N_3 * 2); using BaryonTensorMap = Eigen::TensorMap; BaryonTensorMap BField4 (&Memory[0], Nmom,4,Nt,N_1,N_2,N_3); + + using TestScalar = std::complex; + //typedef Eigen::TensorFixedSize, Eigen::StorageOptions::RowMajor> TestTensorFixed; + using T3 = Eigen::Tensor; + using T2 = Eigen::Tensor; + T3 a(4,3,2); + for_all( a, [&](TestScalar &c, float n, const std::size_t * pDims ){ + c = std::complex{n,-n}; + } ); + std::cout << "a initialised to:\n" << a << std::endl; + Eigen::array offsets = {0,0,0}; + Eigen::array extents = {1,3,2}; + T2 b(3,2); + auto c = a.slice( offsets, extents).reshape(extents); + std::cout << "c is:\n" << c << std::endl; + b = a.chip(0,0); + std::cout << "b is:\n" << b << std::endl; + //b = c; + return true; }