R version 2.11.1 (2010-05-31) Copyright (C) 2010 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > > library(rlecuyer) > > .lec.SetPackageSeed(c(42, 666, 100001, 123454321, 7, 123456789)) [1] 42 666 100001 123454321 7 123456789 > > nstream <- 4 > stream.names <- LETTERS[1:nstream] > > stream.names [1] "A" "B" "C" "D" > > .lec.CreateStream(stream.names) > > ##### .lec.WriteStateFull(stream.names) > > for (i in 1:nstream) { + .lec.CurrentStream(stream.names[i]) + .lec.IncreasedPrecis(stream.names[i], incp = TRUE) + cat("stream", stream.names[i], "\n") + print(runif(5)) + .lec.CurrentStreamEnd() + } stream A [1] 0.5233823 0.4638017 0.7125774 0.5318066 0.3249247 stream B [1] 0.2898913 0.4814183 0.4294409 0.2402501 0.5292961 stream C [1] 0.927069337 0.838032908 0.837572562 0.237087596 0.005263117 stream D [1] 0.8078419 0.2436070 0.3762762 0.9139202 0.9150680 > > library(multicore) > > ##### note we don't reset the seed; we just keep using the streams > > foo <- function(name) { + .lec.CurrentStream(name) + result <- runif(5) + .lec.CurrentStreamEnd() + return(result) + } > > for (i in 1:nstream) parallel(foo(stream.names[i]), name = stream.names[i]) > > out <- collect() > > out $`20548` [1] 0.12387387 0.39981922 0.05656899 0.25850595 0.77134976 $`20547` [1] 0.5760145 0.1274918 0.0964879 0.9548364 0.5517083 $`20546` [1] 0.00282699 0.99021310 0.27727362 0.08932219 0.31730579 $`20545` [1] 0.4089789 0.7439181 0.2269386 0.3957532 0.4454894 > > ##### try it again > > for (i in 1:nstream) parallel(foo(stream.names[i])) > > out2 <- collect() > > out2 $`20552` [1] 0.12387387 0.39981922 0.05656899 0.25850595 0.77134976 $`20551` [1] 0.5760145 0.1274918 0.0964879 0.9548364 0.5517083 $`20550` [1] 0.00282699 0.99021310 0.27727362 0.08932219 0.31730579 $`20549` [1] 0.4089789 0.7439181 0.2269386 0.3957532 0.4454894 > > > proc.time() user system elapsed 0.213 0.020 0.477