rexpGpu {clrng} | R Documentation |
rexpGpu
Description
Generate exponential random numbers parallely on a GPU.
Usage
rexpGpu(
n,
rate = 1,
streams,
Nglobal = getOption("clrng.Nglobal"),
type = getOption("clrng.type"),
verbose = FALSE
)
Arguments
n |
a number or a vector specifying the size of the output vector or matrix. |
rate |
a number specifying the distribution parameter, mean equals to 1/rate. |
streams |
a vclMatrix of streams. |
Nglobal |
a (non-empty) integer vector specifying size of work items for use, with default value from global option 'clrng.Nglobal'. |
type |
a character string specifying "double" or "float" of random numbers, with default value from global option 'clrng.type'. |
verbose |
a logical value, if TRUE, print extra information, default is FALSE. |
Details
type
specifies the precision type of random numbers. If GPU supports "double", 'clrng.Nglobal' is "double", otherwise, ‘clrng.Nglobal’ is "single".
Value
a 'vclVector' or 'vclMatrix' of exponential random numbers.
Examples
library('clrng')
if (detectGPUs() >= 1) {
setContext(grep("gpu", listContexts()$device_type)[1])
streams <- createStreamsGpu()
as.vector(rexpGpu(7, streams=streams))
# produce float precision random numbers
options(clrng.type='float')
as.matrix(rexpGpu(c(2,3), rate=0.5, streams))} else {
message("No GPU context available")
}
[Package clrng version 0.0.5 Index]