What is the most fast and safe way of generating random numbers inside a pararelled loop? I did as below but I'm not sure if it is correct or not:
using namespace std;
std::minstd_rand gen(std::random_device{}());
std::uniform_real_distribution<double> unirnd(0, 1);
int main(){
double eta=something;
double x[N];
//initializing x[]
for (i=0;i<N;i++)
{
double z= unirnd(gen) * eta;
x[i] = some function of x[i] and z
}
}
To compile the code, I use g++ -fopenmp -std=gnu++11 -Wall -Wextra -g code.cpp -o a.out
using namespace std;
Also there are no openmp pragmas in your code. Code posted to Code Review should be compilable, yours clearly isn't. \$\endgroup\$