utilisation de drand48_-
This commit is contained in:
@@ -6,10 +6,15 @@
|
|||||||
void* nbDansCercleSeq( void* nbLancers )
|
void* nbDansCercleSeq( void* nbLancers )
|
||||||
{
|
{
|
||||||
long nb = 0;
|
long nb = 0;
|
||||||
unsigned int seed;
|
struct drand48_data bf;
|
||||||
|
double x,y;
|
||||||
|
srand48_r(pthread_self(),&bf); // initialisation de la graine
|
||||||
|
// avec le numero du thread
|
||||||
|
|
||||||
for( long i = 0; i < (long) nbLancers; i++ ) {
|
for( long i = 0; i < (long) nbLancers; i++ ) {
|
||||||
double x = (double) rand_r(&seed) / RAND_MAX;
|
drand48_r(&bf,&x);
|
||||||
double y = (double) rand_r(&seed) / RAND_MAX;
|
drand48_r(&bf,&y);
|
||||||
|
|
||||||
if ( x * x + y * y <= 1.0 ) {
|
if ( x * x + y * y <= 1.0 ) {
|
||||||
nb += 1;
|
nb += 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user