mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 15:55:37 +00:00
Merge branch 'master' into hadrons
This commit is contained in:
commit
405b175665
3
.gitignore
vendored
3
.gitignore
vendored
@ -94,8 +94,7 @@ Thumbs.db
|
||||
|
||||
# build directory #
|
||||
###################
|
||||
build/*
|
||||
build_debug/*
|
||||
build*/*
|
||||
|
||||
# IDE related files #
|
||||
#####################
|
||||
|
@ -65,7 +65,10 @@ inline uint64_t cyclecount(void){
|
||||
return tmp;
|
||||
}
|
||||
#elif defined __x86_64__
|
||||
#include <immintrin.h>
|
||||
#ifndef __INTEL_COMPILER
|
||||
#include <x86intrin.h>
|
||||
#endif
|
||||
inline uint64_t cyclecount(void){
|
||||
return __rdtsc();
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ namespace Grid {
|
||||
|
||||
std::seed_seq src;
|
||||
|
||||
fixedSeed(std::vector<int> &seeds) : src(seeds.begin(),seeds.end()) {};
|
||||
fixedSeed(const std::vector<int> &seeds) : src(seeds.begin(),seeds.end()) {};
|
||||
|
||||
result_type operator () (void){
|
||||
|
||||
@ -122,6 +122,7 @@ namespace Grid {
|
||||
std::vector<RngEngine> _generators;
|
||||
std::vector<std::uniform_real_distribution<RealD>> _uniform;
|
||||
std::vector<std::normal_distribution<RealD>> _gaussian;
|
||||
std::vector<std::discrete_distribution<RealD>> _bernoulli;
|
||||
|
||||
void GetState(std::vector<RngStateType> & saved,int gen) {
|
||||
saved.resize(RngStateCount);
|
||||
@ -161,6 +162,7 @@ namespace Grid {
|
||||
_generators.resize(1);
|
||||
_uniform.resize(1,std::uniform_real_distribution<RealD>{0,1});
|
||||
_gaussian.resize(1,std::normal_distribution<RealD>(0.0,1.0) );
|
||||
_bernoulli.resize(1,std::discrete_distribution<RealD>{1,1});
|
||||
_seeded=0;
|
||||
}
|
||||
|
||||
@ -242,7 +244,7 @@ namespace Grid {
|
||||
std::random_device rd;
|
||||
Seed(rd);
|
||||
}
|
||||
void SeedFixedIntegers(std::vector<int> &seeds){
|
||||
void SeedFixedIntegers(const std::vector<int> &seeds){
|
||||
fixedSeed src(seeds);
|
||||
Seed(src);
|
||||
}
|
||||
@ -266,6 +268,7 @@ namespace Grid {
|
||||
_generators.resize(_vol);
|
||||
_uniform.resize(_vol,std::uniform_real_distribution<RealD>{0,1});
|
||||
_gaussian.resize(_vol,std::normal_distribution<RealD>(0.0,1.0) );
|
||||
_bernoulli.resize(_vol,std::discrete_distribution<RealD>{1,1});
|
||||
_seeded=0;
|
||||
}
|
||||
|
||||
@ -354,7 +357,7 @@ PARALLEL_FOR_LOOP
|
||||
std::random_device rd;
|
||||
Seed(rd);
|
||||
}
|
||||
void SeedFixedIntegers(std::vector<int> &seeds){
|
||||
void SeedFixedIntegers(const std::vector<int> &seeds){
|
||||
fixedSeed src(seeds);
|
||||
Seed(src);
|
||||
}
|
||||
@ -369,13 +372,21 @@ PARALLEL_FOR_LOOP
|
||||
rng.fill(l,rng._gaussian);
|
||||
}
|
||||
|
||||
template <class vobj> inline void bernoulli(GridParallelRNG &rng,Lattice<vobj> &l){
|
||||
rng.fill(l,rng._bernoulli);
|
||||
}
|
||||
|
||||
template <class sobj> inline void random(GridSerialRNG &rng,sobj &l){
|
||||
rng.fill(l,rng._uniform);
|
||||
}
|
||||
|
||||
template <class sobj> inline void gaussian(GridSerialRNG &rng,sobj &l){
|
||||
rng.fill(l,rng._gaussian);
|
||||
}
|
||||
|
||||
template <class sobj> inline void bernoulli(GridSerialRNG &rng,sobj &l){
|
||||
rng.fill(l,rng._bernoulli);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -383,7 +383,6 @@ namespace QCD {
|
||||
//////////////////////////////////////////////
|
||||
// Poke scalars
|
||||
//////////////////////////////////////////////
|
||||
|
||||
template<class vobj> void pokeSpin(vobj &lhs,const decltype(peekIndex<SpinIndex>(lhs,0)) & rhs,int i)
|
||||
{
|
||||
pokeIndex<SpinIndex>(lhs,rhs,i);
|
||||
@ -407,6 +406,40 @@ namespace QCD {
|
||||
pokeIndex<LorentzIndex>(lhs,rhs,i);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Fermion <-> propagator assignements
|
||||
//////////////////////////////////////////////
|
||||
template <class Prop, class Ferm>
|
||||
void FermToProp(Prop &p, const Ferm &f, const int s, const int c)
|
||||
{
|
||||
for(int j = 0; j < Ns; ++j)
|
||||
{
|
||||
auto pjs = peekSpin(p, j, s);
|
||||
auto fj = peekSpin(f, j);
|
||||
|
||||
for(int i = 0; i < Nc; ++i)
|
||||
{
|
||||
pokeColour(pjs, peekColour(fj, i), i, c);
|
||||
}
|
||||
pokeSpin(p, pjs, j, s);
|
||||
}
|
||||
}
|
||||
|
||||
template <class Prop, class Ferm>
|
||||
void PropToFerm(Ferm &f, const Prop &p, const int s, const int c)
|
||||
{
|
||||
for(int j = 0; j < Ns; ++j)
|
||||
{
|
||||
auto pjs = peekSpin(p, j, s);
|
||||
auto fj = peekSpin(f, j);
|
||||
|
||||
for(int i = 0; i < Nc; ++i)
|
||||
{
|
||||
pokeColour(fj, peekColour(pjs, i, c), i);
|
||||
}
|
||||
pokeSpin(f, fj, j);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// transpose array and scalar
|
||||
|
@ -32,6 +32,22 @@ Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
#include <type_traits>
|
||||
|
||||
namespace Grid {
|
||||
// helper function to read space-separated values
|
||||
template <typename T>
|
||||
std::vector<T> strToVec(const std::string s)
|
||||
{
|
||||
std::istringstream sstr(s);
|
||||
T buf;
|
||||
std::vector<T> v;
|
||||
|
||||
while(!sstr.eof())
|
||||
{
|
||||
sstr >> buf;
|
||||
v.push_back(buf);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
class Serializable {};
|
||||
|
||||
|
@ -140,4 +140,18 @@ int main(int argc,char **argv)
|
||||
std::cout << "Loaded (txt) -----------------" << std::endl;
|
||||
std::cout << copy3 << std::endl << veccopy3 << std::endl;
|
||||
}
|
||||
|
||||
std::vector<int> iv = strToVec<int>("1 2 2 4");
|
||||
std::vector<std::string> sv = strToVec<std::string>("bli bla blu");
|
||||
|
||||
for (auto &e: iv)
|
||||
{
|
||||
std::cout << e << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
for (auto &e: sv)
|
||||
{
|
||||
std::cout << e << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user