PetscRandomGetValuesReal — PETSc 3.25.4 documentation

Skip to main content
`Ctrl`+`K`

# PetscRandomGetValuesReal

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

## Synopsis

    #include "petscsys.h"
    PetscErrorCode PetscRandomGetValuesReal(PetscRandom r, PetscInt n, PetscReal *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

## Note

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

## See Also

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

## Level

intermediate

## Location

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

## Examples

src/ksp/ksp/tutorials/ex82.c
src/ksp/ksp/tutorials/ex21.c

## Implementations

PetscRandomGetValuesReal_CURAND() in src/sys/classes/random/impls/curand/curand.c
PetscRandomGetValuesReal_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