mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-04 05:54:32 +00:00 
			
		
		
		
	Finalising traits
This commit is contained in:
		@@ -101,6 +101,20 @@ void ioTest(const std::string &filename, const O &object, const std::string &nam
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
template <typename T>
 | 
			
		||||
//typename std::enable_if<EigenIO::is_tensor<T>::value, void>::type
 | 
			
		||||
void dump_tensor(T & t)
 | 
			
		||||
{
 | 
			
		||||
  using Traits = typename EigenIO::Traits<typename T::Scalar>;
 | 
			
		||||
  for_all( t, [&](typename Traits::scalar_type &c, typename T::Index index, const std::size_t * pDims ){
 | 
			
		||||
    std::cout << "  ";
 | 
			
		||||
    for( int i = 0 ; i < t.NumDimensions + Traits::rank_non_trivial; i++ )
 | 
			
		||||
      std::cout << "[" << pDims[i] << "]";
 | 
			
		||||
    std::cout << " = " << c << std::endl;
 | 
			
		||||
  } );
 | 
			
		||||
  std::cout << "========================================" << std::endl;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//typedef int TestScalar;
 | 
			
		||||
typedef std::complex<double> TestScalar;
 | 
			
		||||
typedef Eigen::Tensor<iMatrix<TestScalar,1>, 6> TestTensorSingle;
 | 
			
		||||
@@ -145,6 +159,8 @@ bool EigenIOTest(void) {
 | 
			
		||||
        Val += Inc;
 | 
			
		||||
      }
 | 
			
		||||
  ioTest<Hdf5Writer, Hdf5Reader, TestTensor>("iotest_tensor.h5", t, "eigen_tensor_instance_name");
 | 
			
		||||
  std::cout << "t:";
 | 
			
		||||
  dump_tensor(t);
 | 
			
		||||
 | 
			
		||||
  // Now serialise a fixed size tensor
 | 
			
		||||
  using FixedTensor = Eigen::TensorFixedSize<TestScalar, Eigen::Sizes<8,4,3>>;
 | 
			
		||||
@@ -157,7 +173,9 @@ bool EigenIOTest(void) {
 | 
			
		||||
        Val += Inc;
 | 
			
		||||
      }
 | 
			
		||||
  ioTest<Hdf5Writer, Hdf5Reader, FixedTensor>("iotest_tensor_fixed.h5", tf, "eigen_tensor_fixed_name");
 | 
			
		||||
  
 | 
			
		||||
  std::cout << "tf:";
 | 
			
		||||
  dump_tensor(tf);
 | 
			
		||||
 | 
			
		||||
  ETSerClass o;
 | 
			
		||||
  ioTest<Hdf5Writer, Hdf5Reader, ETSerClass>("iotest_object.h5", o, "ETSerClass_object_instance_name");
 | 
			
		||||
  
 | 
			
		||||
@@ -174,14 +192,8 @@ bool EigenIOTest(void) {
 | 
			
		||||
            Val += Inc;
 | 
			
		||||
          }
 | 
			
		||||
  ioTest<Hdf5Writer, Hdf5Reader, LSCTensor>("iotest_LSCTensor.h5", l, "LSCTensor_object_instance_name");
 | 
			
		||||
  std::cout << "t:";
 | 
			
		||||
  for_all( l, [](std::complex<double> &c, LSCTensor::Index index, const std::size_t * pDims ){
 | 
			
		||||
    std::cout << "  ";
 | 
			
		||||
    for( int i = 0 ; i < 5; i++ )
 | 
			
		||||
      std::cout << "[" << pDims[i] << "]";
 | 
			
		||||
    std::cout << " = " << c << std::endl;
 | 
			
		||||
  } );
 | 
			
		||||
  std::cout << std::endl;
 | 
			
		||||
  std::cout << "l:";
 | 
			
		||||
  dump_tensor(l);
 | 
			
		||||
 | 
			
		||||
  // Tensor of spin colour
 | 
			
		||||
  LCMTensor l2;
 | 
			
		||||
 
 | 
			
		||||
@@ -467,13 +467,13 @@ bool DebugEigenTest()
 | 
			
		||||
template <typename T>
 | 
			
		||||
void DebugGridTensorTest_print( int i )
 | 
			
		||||
{
 | 
			
		||||
  std::cout << i << " : " << is_grid_tensor<T>::value
 | 
			
		||||
  << ", depth " << grid_tensor_att<T>::depth
 | 
			
		||||
  << ", rank " << grid_tensor_att<T>::rank
 | 
			
		||||
  << ", rank_non_trivial " << grid_tensor_att<T>::rank_non_trivial
 | 
			
		||||
  << ", count " << grid_tensor_att<T>::count
 | 
			
		||||
  << ", scalar_size " << grid_tensor_att<T>::scalar_size
 | 
			
		||||
  << ", size " << grid_tensor_att<T>::size
 | 
			
		||||
  std::cout << i << " : " << EigenIO::is_tensor<T>::value
 | 
			
		||||
  << ", depth " << EigenIO::Traits<T>::depth
 | 
			
		||||
  << ", rank " << EigenIO::Traits<T>::rank
 | 
			
		||||
  << ", rank_non_trivial " << EigenIO::Traits<T>::rank_non_trivial
 | 
			
		||||
  << ", count " << EigenIO::Traits<T>::count
 | 
			
		||||
  << ", scalar_size " << EigenIO::Traits<T>::scalar_size
 | 
			
		||||
  << ", size " << EigenIO::Traits<T>::size
 | 
			
		||||
  << std::endl;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -494,8 +494,24 @@ public:
 | 
			
		||||
  inline value_type * end(void) { return m_p + N; }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
bool DebugFelixTensorTest( void )
 | 
			
		||||
{
 | 
			
		||||
  unsigned int Nmom = 2;
 | 
			
		||||
  unsigned int Nt = 2;
 | 
			
		||||
  unsigned int N_1 = 2;
 | 
			
		||||
  unsigned int N_2 = 2;
 | 
			
		||||
  unsigned int N_3 = 2;
 | 
			
		||||
  using BaryonTensorSet = Eigen::Tensor<Complex, 6, Eigen::RowMajor>;
 | 
			
		||||
  BaryonTensorSet BField3(Nmom,4,Nt,N_1,N_2,N_3);
 | 
			
		||||
  std::vector<Complex> Memory(Nmom * Nt * N_1 * N_2 * N_3 * 2);
 | 
			
		||||
  using BaryonTensorMap = Eigen::TensorMap<BaryonTensorSet>;
 | 
			
		||||
  BaryonTensorMap BField4 (&Memory[0], Nmom,4,Nt,N_1,N_2,N_3);
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool DebugGridTensorTest( void )
 | 
			
		||||
{
 | 
			
		||||
  DebugFelixTensorTest();
 | 
			
		||||
  typedef Complex t1;
 | 
			
		||||
  typedef iScalar<t1> t2;
 | 
			
		||||
  typedef iVector<t1, Ns> t3;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user