# PetscRandomSeed
Seed the random number generator. 
## Synopsis
```
#include "petscsys.h" 
PetscErrorCode PetscRandomSeed(PetscRandom r)
```
Not collective


## Input Parameters

- ***r -*** The random number generator context





## Usage
```none
      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
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/classes/random/interface/randomc.c.html#PetscRandomSeed">src/sys/classes/random/interface/randomc.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/classes/random/tutorials/ex1.c.html">src/sys/classes/random/tutorials/ex1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex70.c.html">src/ksp/ksp/tutorials/ex70.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex12.c.html">src/snes/tutorials/ex12.c.html</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/classes/random/impls/curand/curand.c.html#PetscRandomSeed_CURAND">PetscRandomSeed_CURAND in src/sys/classes/random/impls/curand/curand.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/classes/random/impls/rand/rand.c.html#PetscRandomSeed_Rand">PetscRandomSeed_Rand in src/sys/classes/random/impls/rand/rand.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/classes/random/impls/rand48/rand48.c.html#PetscRandomSeed_Rand48">PetscRandomSeed_Rand48 in src/sys/classes/random/impls/rand48/rand48.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/classes/random/impls/rander48/rander48.c.html#PetscRandomSeed_Rander48">PetscRandomSeed_Rander48 in src/sys/classes/random/impls/rander48/rander48.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/classes/random/impls/random123/random123.c.html#PetscRandomSeed_Random123">PetscRandomSeed_Random123 in src/sys/classes/random/impls/random123/random123.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/classes/random/impls/sprng/sprng.c.html#PetscRandomSeed_Sprng">PetscRandomSeed_Sprng in src/sys/classes/random/impls/sprng/sprng.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/classes/random/interface/randomc.c)


[Index of all Sys routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
