gpucoder.rng
R2026bDescription
gpucoder.rng initializes the random number generator in
generated GPU code by using the NVIDIA® cuRAND library. When you generate GPU code from
gpucoder.rng, the generated code initializes the generator and uses it for
subsequent calls to gpucoder.rand, gpucoder.randi,
and gpucoder.randn. Use this function to reproduce sequences of random
numbers or generate different sequences of random numbers. For more information, see Reproducibility.
If you call gpucoder.rng in MATLAB®, gpucoder.rng initializes the MATLAB random number generator by using the rng function.
Note
Because the NVIDIA cuRAND library and MATLAB use different random number generators, the random numbers produced in
MATLAB for gpucoder.rand, gpucoder.randn,
and gpucoder.randi do not match the random numbers produced by
generated GPU code.
gpucoder.rng("default") initializes the random number generator
with the default seed of 0. In generated GPU code, the random number
generator uses the CURAND_RNG_PSEUDO_XORWOW generator type. For more
information, see the cuRAND documentation on the NVIDIA website.
Examples
Input Arguments
More About
Extended Capabilities
Version History
Introduced in R2026b