R/Rng.R

Defines functions mpi.setup.rngstream

Documented in mpi.setup.rngstream

mpi.setup.rngstream <- function(iseed=NULL, comm = 1){
	#require(parallel)
    commsize <- mpi.comm.size(comm)
    if (commsize < 3)
        stop("There is no slave or only one slave")
    if (!mpi.is.master())
        stop("Can be run only on master")
	RNGkind("L'Ecuyer-CMRG")
    if (!is.null(iseed)) 
        set.seed(iseed)
	seeds <- vector("list", commsize)
	seeds[[1L]] <- .Random.seed
	for (i in seq_len(commsize - 1L)) seeds[[i + 1L]] <- nextRNGStream(seeds[[i]])
	initRNGstreamNode <- function(seed){
		RNGkind("L'Ecuyer-CMRG")
		.Random.seed <<- seed
	}
    invisible(mpi.apply(seeds[-1], initRNGstreamNode,comm=comm))
}

Try the Rmpi package in your browser

Any scripts or data that you put into this service are public.

Rmpi documentation built on April 11, 2018, 5:04 p.m.