mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-13 01:05:36 +00:00
../tests/hadrons/Test_hadrons_distil.cc
This commit is contained in:
parent
ed7175076b
commit
4b3c566c89
@ -33,6 +33,7 @@ Author: Guido Cossu <guido.cossu@ed.ac.uk>
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <Grid/tensors/Tensors.h>
|
#include <Grid/tensors/Tensors.h>
|
||||||
#include <Grid/serialisation/VectorUtils.h>
|
#include <Grid/serialisation/VectorUtils.h>
|
||||||
|
#include <Grid/Eigen/unsupported/CXX11/Tensor>
|
||||||
|
|
||||||
namespace Grid {
|
namespace Grid {
|
||||||
// Abstract writer/reader classes ////////////////////////////////////////////
|
// Abstract writer/reader classes ////////////////////////////////////////////
|
||||||
@ -60,6 +61,9 @@ namespace Grid {
|
|||||||
void write(const std::string &s, const iVector<U, N> &output);
|
void write(const std::string &s, const iVector<U, N> &output);
|
||||||
template <typename U, int N>
|
template <typename U, int N>
|
||||||
void write(const std::string &s, const iMatrix<U, N> &output);
|
void write(const std::string &s, const iMatrix<U, N> &output);
|
||||||
|
template <typename Scalar_, int NumIndices_>
|
||||||
|
void write(const std::string &s, const Eigen::Tensor<Scalar_, NumIndices_, Eigen::RowMajor> &output);
|
||||||
|
|
||||||
void scientificFormat(const bool set);
|
void scientificFormat(const bool set);
|
||||||
bool isScientific(void);
|
bool isScientific(void);
|
||||||
void setPrecision(const unsigned int prec);
|
void setPrecision(const unsigned int prec);
|
||||||
@ -162,6 +166,14 @@ namespace Grid {
|
|||||||
upcast->writeDefault(s, tensorToVec(output));
|
upcast->writeDefault(s, tensorToVec(output));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
template <typename Scalar_, int NumIndices_>
|
||||||
|
void Writer<T>::write(const std::string &s, const Eigen::Tensor<Scalar_, NumIndices_, Eigen::RowMajor> &output)
|
||||||
|
{
|
||||||
|
//upcast->writeDefault(s, tensorToVec(output));
|
||||||
|
std::cout << "I really should add code to write Eigen::Tensor ..." << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Writer<T>::scientificFormat(const bool set)
|
void Writer<T>::scientificFormat(const bool set)
|
||||||
{
|
{
|
||||||
|
@ -422,6 +422,51 @@ bool DebugEigenTest()
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef iMatrix<Complex,7> OddBall;
|
||||||
|
|
||||||
|
// From Test_serialisation.cc
|
||||||
|
class myclass: Serializable {
|
||||||
|
public:
|
||||||
|
GRID_SERIALIZABLE_CLASS_MEMBERS(myclass
|
||||||
|
, OddBall, critter
|
||||||
|
, SpinColourVector, scv
|
||||||
|
, SpinColourMatrix, scm
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename W, typename R, typename O>
|
||||||
|
bool ioTest(const std::string &filename, const O &object, const std::string &name)
|
||||||
|
{
|
||||||
|
// writer needs to be destroyed so that writing physically happens
|
||||||
|
{
|
||||||
|
W writer(filename);
|
||||||
|
write(writer, "testobject", object);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*R reader(filename);
|
||||||
|
O buf;
|
||||||
|
bool good;
|
||||||
|
|
||||||
|
read(reader, "testobject", buf);
|
||||||
|
good = (object == buf);
|
||||||
|
std::cout << name << " IO test: " << (good ? "success" : "failure");
|
||||||
|
std::cout << std::endl;
|
||||||
|
return good;*/
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DebugIOTest(void) {
|
||||||
|
OddBall critter;
|
||||||
|
ioTest<Hdf5Writer, Hdf5Reader, OddBall>("iotest_oddball.h5", critter, "OddBall");
|
||||||
|
SpinColourMatrix scm;
|
||||||
|
ioTest<Hdf5Writer, Hdf5Reader, SpinColourMatrix>("iotest_matrix.h5", scm, "SpinColourMatrix");
|
||||||
|
SpinColourVector scv;
|
||||||
|
ioTest<Hdf5Writer, Hdf5Reader, SpinColourVector>("iotest_vector.h5", scv, "SpinColourVector");
|
||||||
|
myclass o;
|
||||||
|
ioTest<Hdf5Writer, Hdf5Reader, myclass>("iotest_object.h5", o, "myclass_object_instance_name");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@ -430,7 +475,8 @@ int main(int argc, char *argv[])
|
|||||||
// Debug only - test of Eigen::Tensor
|
// Debug only - test of Eigen::Tensor
|
||||||
std::cout << "sizeof(std::streamsize) = " << sizeof(std::streamsize) << std::endl;
|
std::cout << "sizeof(std::streamsize) = " << sizeof(std::streamsize) << std::endl;
|
||||||
std::cout << "sizeof(Eigen::Index) = " << sizeof(Eigen::Index) << std::endl;
|
std::cout << "sizeof(Eigen::Index) = " << sizeof(Eigen::Index) << std::endl;
|
||||||
if( DebugEigenTest() ) return 0;
|
//if( DebugEigenTest() ) return 0;
|
||||||
|
if(DebugIOTest()) return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Decode command-line parameters. 1st one is which test to run
|
// Decode command-line parameters. 1st one is which test to run
|
||||||
|
Loading…
Reference in New Issue
Block a user