gpurng
Control random number generation on the GPU
Syntax
Description
gpurng("default") initializes the GPU random number generator
using the default algorithm and seed. The default algorithm is the
Threefry generator with seed 0. The random
numbers produced are the same as if you had restarted MATLAB®.
The gpurng function controls the global GPU stream, which
determines how the rand, randi, randn, and randperm functions produce a
sequence of random numbers on the GPU. To create one or more independent streams
separate from the global GPU stream, see parallel.gpu.RandStream.
gpurng( specifies the seed for the GPU random
number generator using the current generator algorithm.seed)
Specify
seedas a nonnegative integer, such asgpurng(1), to initialize the GPU random number generator with that seed.Specify
seedas"shuffle"to initialize the generator seed based on the current time so thatrand,randi,randn, andrandpermproduce different sequences of numbers after each time you callgpurng.
gpurng( specifies the algorithm
for the GPU random number generator to use with a seed of generator)0. This
syntax is equivalent to gpurng(0,generator). (since R2023b)
gpurng( initializes the state of the random number
generator based on settings contained in a structure S)S with
fields Type, Seed, and
State. The structure S must be a
structure that is returned by a previous call to S = gpurng or
S = gpurng(__).
returns the current state of
the random number generator as a structure S = gpurngS with fields
Type, Seed, and
State.
returns the current
state of the random number generator in a structure S = gpurng(___)S before
changing the settings using the specified arguments.
Note
The default algorithm and seed for the random number generator in the MATLAB
Settings Window window affect random numbers generated on
the CPU only and do not affect calls to gpurng("default").
