# PetscRandomRegister
Adds a new `PetscRandom` implementation 
## Synopsis
```
#include "petscsys.h" 
PetscErrorCode PetscRandomRegister(const char sname[], PetscErrorCode (*function)(PetscRandom))
```
Not Collective


## Input Parameters

- ***name        -*** The name of a new user-defined creation routine
- ***create_func -*** The creation routine itself



## Notes
`PetscRandomRegister()` may be called multiple times to add several user-defined randome number generators

For an example of the code needed to interface your own random number generator see src/sys/random/impls/rand/rand.c


## Sample usage
```none
    PetscRandomRegister("my_rand",  MyPetscRandomtorCreate);
```


Then, your random type can be chosen with the procedural interface via
```none
    PetscRandomCreate(MPI_Comm, PetscRandom *);
    PetscRandomSetType(PetscRandom,"my_random_name");
```

or at runtime via the option
```none
    -random_type my_random_name
```





## See Also
 `PetscRandom`, `PetscRandomRegisterAll()`, `PetscRandomRegisterDestroy()`, `PetscRandomRegister()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/classes/random/interface/randreg.c.html#PetscRandomRegister">src/sys/classes/random/interface/randreg.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/classes/random/interface/randreg.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)  
