PetscRandomGetValues — PETSc 3.21.4 documentation

Skip to main content
`Ctrl`+`K`

# PetscRandomGetValues

Generates a sequence of random numbers. Call this after first calling `PetscRandomCreate()`.

## Synopsis

    #include "petscsys.h"
    PetscErrorCode PetscRandomGetValues(PetscRandom r, PetscInt n, PetscScalar *val)

Not Collective

## Input Parameters

- r - the random number generator context

- n - number of random numbers to generate

## Output Parameter

- val - the array to hold the values

## Notes

Use `VecSetRandom()` to set the elements of a vector to random numbers.

When PETSc is compiled for complex numbers this returns an array of complex numbers with random real and complex parts. Use `PetscRandomGetValuesReal()` to get an array of random real numbers.

## See Also

`PetscRandom`, `PetscRandomCreate()`, `PetscRandomDestroy()`, `VecSetRandom()`, `PetscRandomGetValue()`

## Level

intermediate

## Location

src/sys/classes/random/interface/random.c

## Implementations

PetscRandomGetValues_CURAND() in src/sys/classes/random/impls/curand/curand.c
PetscRandomGetValues_Random123() in src/sys/classes/random/impls/random123/random123.c

Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages