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: Guillaume Damiand <>
  • To: "" <>
  • Subject: Re: [cgal-discuss] CGAL::Random
  • Date: Wed, 22 Jun 2011 09:21:28 +0200

If you test, you will see that it is important...



I havent test your idea yet, but i think it is not important for compiler that initialization is in or out of for loop because the compiler translate the statement (CGAL::Random random) only one time.
 
 
 
--- On Wed, 6/22/11, Doug Epps wrote:

From: Doug Epps
Subject: Re: [cgal-discuss] CGAL::Random
To:
Date: Wednesday, June 22, 2011, 5:04 AM


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;
> > }


--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss



-- 
===================================================================
Guillaume DAMIAND

LIRIS UMR 5205
Université Claude Bernard
Bâtiment Nautibus (710)
43 Boulevard du 11 Novembre 1918
69622 Villeurbanne Cedex (France)
-------------------------------------------------------------------
Tél: +33 (0)4.72.43.26.62                 Fax: +33 (0)4.72.43.15.36
Mail: 
===================================================================



Archive powered by MHonArc 2.6.16.

Top of Page