Skip to main content
`Ctrl`+`K`

# PetscRandomSeed

Seed the random number generator.

## Synopsis

    #include "petscsys.h"
    PetscErrorCode PetscRandomSeed(PetscRandom r)

Not collective

## Input Parameter

- r - The random number generator context

## Example Usage

          PetscRandomSetSeed(r,a positive integer);
          PetscRandomSeed(r);
          PetscRandomGetValue() will now start with the new seed.

          PetscRandomSeed(r) without a call to PetscRandomSetSeed() re-initializes
          the seed. The random numbers generated will be the same as before.

## See Also

`PetscRandomCreate()`, `PetscRandomGetSeed()`, `PetscRandomSetSeed()`

## Level

intermediate

## Location

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

## Examples

src/ml/da/tutorials/ex2.c
src/snes/tutorials/ex12.c
src/ml/da/tutorials/ex3.c
src/sys/classes/random/tutorials/ex1.c
src/ml/da/tutorials/ex4.c
src/ml/da/tutorials/ex1.c
src/ksp/ksp/tutorials/ex70.c

## Implementations

PetscRandomSeed_CURAND() in src/sys/classes/random/impls/curand/curand.c
PetscRandomSeed_Rand() in src/sys/classes/random/impls/rand/rand.c
PetscRandomSeed_Rand48() in src/sys/classes/random/impls/rand48/rand48.c
PetscRandomSeed_Rander48() in src/sys/classes/random/impls/rander48/rander48.c
PetscRandomSeed_Random123() in src/sys/classes/random/impls/random123/random123.c
PetscRandomSeed_Sprng() in src/sys/classes/random/impls/sprng/sprng.c

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