mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-20 08:46:55 +01:00
Enough for tonight
This commit is contained in:
@ -103,8 +103,9 @@ void ioTest(const std::string &filename, const O &object, const std::string &nam
|
||||
#ifdef DEBUG
|
||||
//typedef int TestScalar;
|
||||
typedef std::complex<double> TestScalar;
|
||||
typedef Eigen::Tensor<TestScalar, 3> TestTensor;
|
||||
typedef Eigen::TensorFixedSize<TestScalar, Eigen::Sizes<9,4,2>> TestTensorFixed;
|
||||
typedef Eigen::Tensor<iMatrix<TestScalar,1>, 6> TestTensorSingle;
|
||||
typedef Eigen::Tensor<TestScalar, 3, Eigen::StorageOptions::RowMajor> TestTensor;
|
||||
typedef Eigen::TensorFixedSize<TestScalar, Eigen::Sizes<9,4,2>, Eigen::StorageOptions::RowMajor> TestTensorFixed;
|
||||
typedef std::vector<TestTensorFixed> aTestTensorFixed;
|
||||
typedef Eigen::TensorFixedSize<SpinColourVector, Eigen::Sizes<11,3,2>> LSCTensor;
|
||||
typedef Eigen::TensorFixedSize<LorentzColourMatrix, Eigen::Sizes<5,7,2>> LCMTensor;
|
||||
@ -124,15 +125,18 @@ public:
|
||||
};
|
||||
|
||||
bool EigenIOTest(void) {
|
||||
constexpr TestScalar Inc{1,-1};
|
||||
TestTensorSingle ts(1,1,1,1,1,1);
|
||||
ts(0,0,0,0,0,0) = Inc * 3.1415927;
|
||||
ioTest<Hdf5Writer, Hdf5Reader, TestTensorSingle>("iotest_single.h5", ts, "Singlet");
|
||||
|
||||
SpinColourVector scv, scv2;
|
||||
scv2 = scv;
|
||||
ioTest<Hdf5Writer, Hdf5Reader, SpinColourVector>("iotest_vector.h5", scv, "SpinColourVector");
|
||||
SpinColourMatrix scm;
|
||||
ioTest<Hdf5Writer, Hdf5Reader, SpinColourMatrix>("iotest_matrix.h5", scm, "SpinColourMatrix");
|
||||
|
||||
constexpr TestScalar Inc{1,-1};
|
||||
|
||||
TestTensor t(3,6,2);
|
||||
TestTensor t(6,3,2);
|
||||
TestScalar Val{Inc};
|
||||
for( int i = 0 ; i < t.dimension(0) ; i++)
|
||||
for( int j = 0 ; j < t.dimension(1) ; j++)
|
||||
@ -141,7 +145,7 @@ bool EigenIOTest(void) {
|
||||
Val += Inc;
|
||||
}
|
||||
ioTest<Hdf5Writer, Hdf5Reader, TestTensor>("iotest_tensor.h5", t, "eigen_tensor_instance_name");
|
||||
|
||||
|
||||
// Now serialise a fixed size tensor
|
||||
using FixedTensor = Eigen::TensorFixedSize<TestScalar, Eigen::Sizes<8,4,3>>;
|
||||
FixedTensor tf;
|
||||
@ -170,7 +174,15 @@ 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;
|
||||
|
||||
// Tensor of spin colour
|
||||
LCMTensor l2;
|
||||
Val = 0;
|
||||
|
@ -477,6 +477,23 @@ void DebugGridTensorTest_print( int i )
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
// begin() and end() are the minimum necessary to support range-for loops
|
||||
// should really turn this into an iterator ...
|
||||
template<typename T, int N>
|
||||
class TestObject {
|
||||
public:
|
||||
using value_type = T;
|
||||
private:
|
||||
value_type * m_p;
|
||||
public:
|
||||
TestObject() {
|
||||
m_p = reinterpret_cast<value_type *>(std::malloc(N * sizeof(value_type)));
|
||||
}
|
||||
~TestObject() { std::free(m_p); }
|
||||
inline value_type * begin(void) { return m_p; }
|
||||
inline value_type * end(void) { return m_p + N; }
|
||||
};
|
||||
|
||||
bool DebugGridTensorTest( void )
|
||||
{
|
||||
typedef Complex t1;
|
||||
@ -485,7 +502,8 @@ bool DebugGridTensorTest( void )
|
||||
typedef iMatrix<t1, Nc> t4;
|
||||
typedef iVector<iMatrix<t1,1>,4> t5;
|
||||
typedef iScalar<t5> t6;
|
||||
typedef iMatrix<iVector<iScalar<iMatrix<t6, 1>>,2>,7> t7;
|
||||
typedef iMatrix<t6, 3> t7;
|
||||
typedef iMatrix<iVector<iScalar<t7>,4>,2> t8;
|
||||
int i = 1;
|
||||
DebugGridTensorTest_print<t1>( i++ );
|
||||
DebugGridTensorTest_print<t2>( i++ );
|
||||
@ -494,6 +512,27 @@ bool DebugGridTensorTest( void )
|
||||
DebugGridTensorTest_print<t5>( i++ );
|
||||
DebugGridTensorTest_print<t6>( i++ );
|
||||
DebugGridTensorTest_print<t7>( i++ );
|
||||
DebugGridTensorTest_print<t8>( i++ );
|
||||
|
||||
//using TOC7 = TestObject<std::complex<double>, 7>;
|
||||
using TOC7 = t7;
|
||||
TOC7 toc7;
|
||||
constexpr std::complex<double> Inc{1,-1};
|
||||
std::complex<double> Start{Inc};
|
||||
for( auto &x : toc7 ) {
|
||||
x = Start;
|
||||
Start += Inc;
|
||||
}
|
||||
i = 0;
|
||||
for( auto x : toc7 ) std::cout << "toc7[" << i++ << "] = " << x << std::endl;
|
||||
|
||||
t2 o2;
|
||||
auto a2 = TensorRemove(o2);
|
||||
//t3 o3;
|
||||
//t4 o4;
|
||||
//auto a3 = TensorRemove(o3);
|
||||
//auto a4 = TensorRemove(o4);
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
@ -502,8 +541,12 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef DEBUG
|
||||
// Debug only - test of Eigen::Tensor
|
||||
std::cout << "sizeof(std::streamsize) = " << sizeof(std::streamsize) << std::endl;
|
||||
std::cout << "sizeof(Eigen::Index) = " << sizeof(Eigen::Index) << std::endl;
|
||||
std::cout << "sizeof(int) = " << sizeof(int)
|
||||
<< ", sizeof(long) = " << sizeof(long)
|
||||
<< ", sizeof(size_t) = " << sizeof(size_t)
|
||||
<< ", sizeof(std::size_t) = " << sizeof(std::size_t)
|
||||
<< ", sizeof(std::streamsize) = " << sizeof(std::streamsize)
|
||||
<< ", sizeof(Eigen::Index) = " << sizeof(Eigen::Index) << std::endl;
|
||||
//if( DebugEigenTest() ) return 0;
|
||||
if(DebugGridTensorTest()) return 0;
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user