Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: Parallel pr...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 14 of 27 Topic 26196 of 26972
Post > Topic >>

Re: Parallel program to calculate PI

by Eric Sosman <Eric.Sosman@[EMAIL PROTECTED] > May 13, 2008 at 12:43 PM

Richard Heathfield wrote:
> Spiros Bousbouras said:
> 
>> On 13 May, 17:00, Richard Heathfield <r...@[EMAIL PROTECTED]
> wrote:
>>> Spiros Bousbouras said:
>>>
>>> <snip>
>>>
>>>> And of course you must know that your random numbers
>>>> will be uniformly distributed within the square.
>>> That's easy. Use the following random point generator:
>>>
>>> #include <assert.h>
>>>
>>> void rndpt(unsigned long int *x,
>>>            unsigned long int *y,
>>>            unsigned long int max) /* max = side of square */
>>> {
>>>   static unsigned long int n = 0;
>>>   assert(x != NULL && y != NULL);
>>>   *x = n % max;
>>>   *y = n++ / max;
>>>   n %= max;
>>>   return;
>>>
>>> }
>>>
>>> If you call this i * max times, where max is a constant and i is an
>>> integer, the distribution of the random points will be uniform.
>> Since *y will always get the value 0 I don't think
>> so.
> 
> Since it won't, I do.

     Try running it for a while and making a histogram of
the y outputs.

     (The bug is in the line preceding the return.)

-- 
Eric.Sosman@[EMAIL PROTECTED]

 




 27 Posts in Topic:
Parallel program to calculate PI
Prime Mover <epleite@[  2008-05-13 07:20:09 
Re: Parallel program to calculate PI
Prime Mover <epleite@[  2008-05-13 07:28:37 
Re: Parallel program to calculate PI
Spiros Bousbouras <spi  2008-05-13 07:55:13 
Re: Parallel program to calculate PI
Spiros Bousbouras <spi  2008-05-13 07:57:53 
Re: Parallel program to calculate PI
Pietro Cerutti <gahr@[  2008-05-13 17:02:08 
Re: Parallel program to calculate PI
Richard Heathfield <rj  2008-05-13 15:28:47 
Re: Parallel program to calculate PI
CBFalconer <cbfalconer  2008-05-13 11:27:51 
Re: Parallel program to calculate PI
Bart <bc@[EMAIL PROTEC  2008-05-13 08:15:17 
Re: Parallel program to calculate PI
Spiros Bousbouras <spi  2008-05-13 08:31:25 
Re: Parallel program to calculate PI
Spiros Bousbouras <spi  2008-05-13 08:32:27 
Re: Parallel program to calculate PI
Richard Heathfield <rj  2008-05-13 16:00:59 
Re: Parallel program to calculate PI
Spiros Bousbouras <spi  2008-05-13 09:07:57 
Re: Parallel program to calculate PI
Richard Heathfield <rj  2008-05-13 16:38:59 
Re: Parallel program to calculate PI
Eric Sosman <Eric.Sosm  2008-05-13 12:43:51 
Re: Parallel program to calculate PI
Richard Heathfield <rj  2008-05-13 16:55:29 
Re: Parallel program to calculate PI
dj3vande@[EMAIL PROTECTED  2008-05-13 16:43:20 
Re: Parallel program to calculate PI
Bart <bc@[EMAIL PROTEC  2008-05-13 09:48:57 
Re: Parallel program to calculate PI
Richard Heathfield <rj  2008-05-13 17:06:03 
Re: Parallel program to calculate PI
CBFalconer <cbfalconer  2008-05-13 16:33:26 
Re: Parallel program to calculate PI
user923005 <dcorbit@[E  2008-05-13 12:08:38 
Re: Parallel program to calculate PI
Richard Heathfield <rj  2008-05-13 21:57:34 
Re: Parallel program to calculate PI
Prime Mover <epleite@[  2008-05-13 12:30:27 
Re: Parallel program to calculate PI
Keith Thompson <kst-u@  2008-05-13 13:02:02 
Re: Parallel program to calculate PI
Prime Mover <epleite@[  2008-05-13 13:00:38 
Re: Parallel program to calculate PI
Eric Sosman <Eric.Sosm  2008-05-13 16:19:35 
Re: Parallel program to calculate PI
user923005 <dcorbit@[E  2008-05-13 17:43:53 
Re: Parallel program to calculate PI
"dSpam@[EMAIL PROTEC  2008-05-15 02:42:48 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 16:18:21 CDT 2008.