rTRNG-package: TRNG C++ library functionality exposed to R.

rTRNG-packageR Documentation

TRNG C++ library functionality exposed to R.

Description

Tina's Random Number Generator Library (TRNG) is a state-of-the-art C++ pseudo-random number generator library for sequential and parallel Monte Carlo simulations (https://www.numbercrunch.de/trng/). It provides a variety of random number engines (pseudo-random number generators) and distributions. In particular, parallel random number engines provided by TRNG support techniques such as block-splitting and leapfrogging suitable for parallel algorithms. See ‘References’ for an introduction to the concepts and details around (parallel) random number generation.

rTRNG

Package rTRNG provides the R users with access to the functionality of the underlying TRNG C++ library in different ways and at different levels.

  • Base-R Random-like usage via TRNG.Random functions, for selecting and manipulating the current engine. This is the simplest and more immediate way for R users to use rTRNG.

  • Reference Objects wrapping the underlying C++ TRNG random number engines can be created and manipulated in OOP-style. This allows greater flexibility in using TRNG engines in R.

  • TRNG C++ library and headers are made available to other R projects and packages using C++.

    • Standalone C++ code sourced via sourceCpp can rely on the Rcpp::depends attribute to correctly set up building against rTRNG, with Rcpp::plugins(cpp11) enforcing the C++11 standard required by TRNG >= 4.22:

      // [[Rcpp::depends(rTRNG)]]
      // [[Rcpp::plugins(cpp11)]]
    • Creating an R package with C++ code using the TRNG library is achieved by LinkingTo: rTRNG in the DESCRIPTION file, adding importFrom(rTRNG, TRNG.Version) in the NAMESPACE file, and setting relevant linker flags (via LdFlags) and C++11 compilation (CXX_STD = CXX11) in Makevars[.win].

    • Note that C++ code using the TRNG library (sourced via Rcpp::sourceCpp or part of an R package) might fail on certain systems due to issues with building and linking against rTRNG. This is typically the case for macOS, and can generally be checked using check_rTRNG_linking.

See the package vignettes (browseVignettes("rTRNG")) for an overview and demos and refer to the examples in the documentation for further use cases.

Author(s)

Maintainer: Riccardo Porreca riccardo.porreca@mirai-solutions.com

Authors:

Other contributors:

  • Mirai Solutions GmbH info@mirai-solutions.com [copyright holder]

  • Heiko Bauke (TRNG sources and headers) [contributor, copyright holder]

References

Heiko Bauke, Tina's Random Number Generator Library, Version 4.23.1, https://github.com/rabauke/trng4/blob/v4.23.1/doc/trng.pdf.

Stephan Mertens, Random Number Generators: A Survival Guide for Large Scale Simulations, 2009, https://ui.adsabs.harvard.edu/abs/2009arXiv0905.4238M

See Also

Useful links:


miraisolutions/rTRNG documentation built on Feb. 4, 2024, 7:35 p.m.