From 4214782b1e06ce8510d70cc2fc36a3b544508948 Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Thu, 14 Jan 2021 17:15:44 +0000 Subject: Move R package to separate directory Rearranging repository --- new_R/man/SyncRNG-class.Rd | 38 ++++++++++++++++++++++++++++++++ new_R/man/syncrng-package.Rd | 52 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 new_R/man/SyncRNG-class.Rd create mode 100644 new_R/man/syncrng-package.Rd (limited to 'new_R/man') diff --git a/new_R/man/SyncRNG-class.Rd b/new_R/man/SyncRNG-class.Rd new file mode 100644 index 0000000..7a2c69b --- /dev/null +++ b/new_R/man/SyncRNG-class.Rd @@ -0,0 +1,38 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/SyncRNG.R +\docType{class} +\name{SyncRNG-class} +\alias{SyncRNG} +\alias{SyncRNG-class} +\title{A Reference Class for SyncRNG} +\description{ +See \link{syncrng-package} for package documentation. +} +\section{Fields}{ + +\describe{ +\item{\code{seed}}{The seed for the random number generator} + +\item{\code{state}}{The current state of the RNG, should not be modified by the +user} +}} +\section{Methods}{ + +\describe{ +\item{\code{initialize(..., seed = 0)}}{Initialize the RNG using the C function R_syncrng_seed} + +\item{\code{rand()}}{Generate a single random float in the range [0, 1)} + +\item{\code{randbelow(n)}}{Generate a random integer below a given number} + +\item{\code{randi()}}{Generate a single random 32-bit integer} + +\item{\code{shuffle(x)}}{Randomly shuffle a provided array of values} +}} +\examples{ +s <- SyncRNG(seed=123456) +for (i in 1:10) + cat(s$randi(), '\\n') + +} + diff --git a/new_R/man/syncrng-package.Rd b/new_R/man/syncrng-package.Rd new file mode 100644 index 0000000..a1b3d32 --- /dev/null +++ b/new_R/man/syncrng-package.Rd @@ -0,0 +1,52 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/syncrng-package.R +\docType{package} +\name{syncrng-package} +\alias{syncrng-package} +\title{SyncRNG - Synchronized Random Numbers in R and Python} +\description{ +The SyncRNG package provides a random number generator implemented in C and +linked to both R and Python. This way, you can generate the same random +number sequence in both languages by using the same seed. + +The package implements a Tausworthe LSFR RNG (more details at +\url{https://gertjanvandenburg.com/blog/syncrng/}). This is a very fast +pseudo-random number generator. +} +\section{Usage}{ + +There are two ways to use this package in R. It can be used as a reference +class, where a SyncRNG object is used to keep the state of the generator and +numbers are generated using the object methods. It can also be used as a +user-defined random number generator using the strategy outlined in +.Random.user. See the examples section below. +} +\examples{ +library(SyncRNG) + +# As user defined RNG: + +set.seed(0, 'user', 'user') +runif(2) +# [1] 3.666952e-04 6.257184e-05 +set.seed(0, 'user', 'user') +rnorm(2) +# [1] 0.01006027 0.42889422 + +# As class: + +s <- SyncRNG(seed=0) +s$rand() +# [1] 0.0003666952 +s$rand() +# [1] 6.257184e-05 + +} +\author{ +Gerrit J.J. van den Burg\cr +Maintainer: Gerrit J.J. van den Burg +} +\references{ +URL: \url{https://github.com/GjjvdBurg/SyncRNG} +} + -- cgit v1.2.3 From 3409fc9201cc8ca460d36b77fb65f09b3d2f3be9 Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Thu, 14 Jan 2021 17:15:54 +0000 Subject: bump roxygen --- new_R/man/SyncRNG-class.Rd | 7 ++++--- new_R/man/syncrng-package.Rd | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'new_R/man') diff --git a/new_R/man/SyncRNG-class.Rd b/new_R/man/SyncRNG-class.Rd index 7a2c69b..92316da 100644 --- a/new_R/man/SyncRNG-class.Rd +++ b/new_R/man/SyncRNG-class.Rd @@ -2,8 +2,8 @@ % Please edit documentation in R/SyncRNG.R \docType{class} \name{SyncRNG-class} -\alias{SyncRNG} \alias{SyncRNG-class} +\alias{SyncRNG} \title{A Reference Class for SyncRNG} \description{ See \link{syncrng-package} for package documentation. @@ -16,6 +16,7 @@ See \link{syncrng-package} for package documentation. \item{\code{state}}{The current state of the RNG, should not be modified by the user} }} + \section{Methods}{ \describe{ @@ -29,10 +30,10 @@ user} \item{\code{shuffle(x)}}{Randomly shuffle a provided array of values} }} + \examples{ s <- SyncRNG(seed=123456) for (i in 1:10) - cat(s$randi(), '\\n') + cat(s$randi(), '\n') } - diff --git a/new_R/man/syncrng-package.Rd b/new_R/man/syncrng-package.Rd index a1b3d32..f8cfe02 100644 --- a/new_R/man/syncrng-package.Rd +++ b/new_R/man/syncrng-package.Rd @@ -21,6 +21,7 @@ numbers are generated using the object methods. It can also be used as a user-defined random number generator using the strategy outlined in .Random.user. See the examples section below. } + \examples{ library(SyncRNG) @@ -41,12 +42,11 @@ s$rand() s$rand() # [1] 6.257184e-05 +} +\references{ +URL: \url{https://github.com/GjjvdBurg/SyncRNG} } \author{ Gerrit J.J. van den Burg\cr Maintainer: Gerrit J.J. van den Burg } -\references{ -URL: \url{https://github.com/GjjvdBurg/SyncRNG} -} - -- cgit v1.2.3