Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] CGAL::Random

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] CGAL::Random


Chronological Thread 
  • From: Doug Epps <>
  • To:
  • Subject: Re: [cgal-discuss] CGAL::Random
  • Date: Tue, 21 Jun 2011 22:04:17 -0700


I believe (though i can't compile it right now) what Sylvain meant was to do:

CGAL::Random random;
for (int t = 1; t<4; t++)
{
double randi=random.get_double (0.0, 1);
std::cout << "randi" << randi << std::endl;
}

Note how the CGAL::Random is OUTSIDE the loop, and so is in scope for all 3
iterations of the loop, rather than being created for each one.

My intuition is that the creation of the CGAL::Random object seeds the
random-number generator.
So you're getting the same thing over and over.


On Jun 21, 2011, at 9:50 PM, sara Samadi wrote:

> for (int t=1; t<4; t++)
> > {
> > CGAL::Random random;
> > double randi=random.get_double (0.0, 1);
> > double mandi=random.get_double (0.0, 1);
> > std::cout<<"randi="<<randi<<std::endl;
> > std::cout<<"mandi="<<mandi<<std::endl;
> > }




Archive powered by MHonArc 2.6.16.

Top of Page