samedi 25 juillet 2015

I am generating a list of coordinates on a square using

#include <random>
using namespace std;

int main(){

random_device rd;
long int seed = rd();
default_random_engine gen(seed);

double max=10.0, min=-10.0;
uniform_real_distribution<double> uni_real(min,max);

double random_x = uni_real(gen);
double random_y = uni_real(gen);

return 0;
}

I would like to ensure that there is a minimum distance between any two points. For my usage, this must hold when periodic boundary conditions are applied.

  • Preferred solution would be a built in method in the <random> library to this. Is there any?
  • Second best, any other package containing a fast way to perform the check (as long as it is easy to make use of).
  • Worst case, I can write my own basic script which would be O(n^2) as I am not too concerned with efficiency right now. Unless, there is some easy algorithm to implement that can do this.

Other questions around where either dealing with the third point or with other environment from <random>.




Aucun commentaire:

Enregistrer un commentaire