1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 15:55:37 +00:00
Grid/lib/lattice/Grid_lattice_rng.h

33 lines
865 B
C
Raw Normal View History

2015-04-18 20:44:19 +01:00
#ifndef GRID_LATTICE_RNG_H
#define GRID_LATTICE_RNG_H
namespace Grid {
// FIXME Randomise; deprecate this
template <class vobj> inline void random(Lattice<vobj> &l){
Real *v_ptr = (Real *)&l._odata[0];
size_t v_len = l._grid->oSites()*sizeof(vobj);
size_t d_len = v_len/sizeof(Real);
for(int i=0;i<d_len;i++){
v_ptr[i]=drand48();
}
};
// FIXME Implement a consistent seed management strategy
template <class vobj> inline void gaussian(Lattice<vobj> &l){
// Zero mean, unit variance.
std::normal_distribution<double> distribution(0.0,1.0);
Real *v_ptr = (Real *)&l._odata[0];
size_t v_len = l._grid->oSites()*sizeof(vobj);
size_t d_len = v_len/sizeof(Real);
for(int i=0;i<d_len;i++){
v_ptr[i]= drand48();
}
};
}
#endif