#include #include using namespace std; using namespace Grid; using namespace Grid::QCD; class funcPlus { public: funcPlus() {}; template void operator()(vec &rr,vec &i1,vec &i2) const { rr = i1+i2;} std::string name(void) const { return std::string("Plus"); } }; class funcMinus { public: funcMinus() {}; template void operator()(vec &rr,vec &i1,vec &i2) const { rr = i1-i2;} std::string name(void) const { return std::string("Minus"); } }; class funcTimes { public: funcTimes() {}; template void operator()(vec &rr,vec &i1,vec &i2) const { rr = i1*i2;} std::string name(void) const { return std::string("Times"); } }; class funcConj { public: funcConj() {}; template void operator()(vec &rr,vec &i1,vec &i2) const { rr = conj(i1);} std::string name(void) const { return std::string("Conj"); } }; class funcAdj { public: funcAdj() {}; template void operator()(vec &rr,vec &i1,vec &i2) const { rr = adj(i1);} std::string name(void) const { return std::string("Adj"); } }; class funcTimesI { public: funcTimesI() {}; template void operator()(vec &rr,vec &i1,vec &i2) const { rr = timesI(i1);} std::string name(void) const { return std::string("timesI"); } }; class funcTimesMinusI { public: funcTimesMinusI() {}; template void operator()(vec &rr,vec &i1,vec &i2) const { rr = timesMinusI(i1);} std::string name(void) const { return std::string("timesMinusI"); } }; template void Tester(const functor &func) { GridSerialRNG sRNG; sRNG.SeedRandomDevice(); int Nsimd = vec::Nsimd(); std::vector input1(Nsimd); std::vector input2(Nsimd); std::vector result(Nsimd); std::vector reference(Nsimd); std::vector > buf(3); vec & v_input1 = buf[0]; vec & v_input2 = buf[1]; vec & v_result = buf[2]; for(int i=0;i(v_input1,input1); merge(v_input2,input2); merge(v_result,result); func(v_result,v_input1,v_input2); for(int i=0;i(v_result,result); std::cout << " " << func.name()<0){ std::cout<< "*****" << std::endl; std::cout<< "["< simd_layout({1,1,2,2}); std::vector mpi_layout ({1,1,1,1}); std::vector latt_size ({8,8,8,8}); GridCartesian Grid(latt_size,simd_layout,mpi_layout); std::vector seeds({1,2,3,4}); // Insist that operations on random scalars gives // identical results to on vectors. std::cout << "==================================="<< std::endl; std::cout << "Testing vComplexF "<(funcTimesI()); Tester(funcTimesMinusI()); Tester(funcPlus()); Tester(funcMinus()); Tester(funcTimes()); Tester(funcConj()); Tester(funcAdj()); std::cout << "==================================="<< std::endl; std::cout << "Testing vComplexD "<(funcTimesI()); Tester(funcTimesMinusI()); Tester(funcPlus()); Tester(funcMinus()); Tester(funcTimes()); Tester(funcConj()); Tester(funcAdj()); std::cout << "==================================="<< std::endl; std::cout << "Testing vRealF "<(funcPlus()); Tester(funcMinus()); Tester(funcTimes()); Tester(funcAdj()); std::cout << "==================================="<< std::endl; std::cout << "Testing vRealD "<(funcPlus()); Tester(funcMinus()); Tester(funcTimes()); Tester(funcAdj()); Grid_finalize(); }