On Thu, Jun 10, 2010 at 7:24 PM, Robert Patterson <ri...@cam.ac.uk> wrote: > Hi, > > I am writing some Monte Carlo simulation code. The problem can be > broken down via domain decomposition (several different sub-problems > that only need to communicate occasionally). I am implementing this > decomposition via cellfun, in order to avoid writing explicit loops. I > hope to parallelise with parcellfun from the general package on > octaveforge. > > Assuming I can reseed the random number generator with the same values > each time I run a calculation: > > 1. Will I get the same random number at each point in my code when using > cellfun as I would with a simple loop, or is the order at least stable > on any one implementation? >
Yes. Cellfun evaluates sequentially upwards, just like a loop. > 2. Is it safe to use parcellfun with the built in random number > generator? > Yes. parcellfun is not based on threads, but on process cloning (fork). Using any function is therefore safe. However, all cloned process will experience the same sequence of random numbers. The easiest way to avoid this is to generate all number beforehand or generate a seed for each input. Eventually, I could create a more general approach to solve this. -- RNDr. Jaroslav Hajek, PhD computing expert & GNU Octave developer Aeronautical Research and Test Institute (VZLU) Prague, Czech Republic url: www.highegg.matfyz.cz ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ Octave-dev mailing list Octave-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/octave-dev