Skip to contents

Creates an initial RNG state from a seed. This state is required by all random sampling functions and is updated after each call.

Usage

nv_rng_state(seed, device = NULL)

Arguments

seed

(arrayish)
Scalar seed. Must be a signed or unsigned integer; it is brought to i32, so a wider one is narrowed to its low 32 bits. An R integer is built at i32 directly, whatever the default integer data type is.

device

(NULL | character(1) | device)
The device the data lives on, given either as:

  • a device string naming the platform (e.g. "cpu", "cuda", "cuda:<n>"), which is resolved against the backend in use, or

  • a device object as returned by nv_device(): a PJRTDevice for the "pjrt" backend or a quickr_device for the "quickr" backend. Because a device object is backend-specific, it also determines the backend.

The default (NULL) uses default_device().

Value

(arrayish)
A ui64 array of length 2, whatever seed's data type was.

Examples

state <- nv_rng_state(42L)
state
#> AnvlArray
#>  42
#>   0
#> [ CPUui64{2} ]