:orphan: # PetscRandomRegister Adds a new `PetscRandom` implementation ## Synopsis ``` #include "petscsys.h" PetscErrorCode PetscRandomRegister(const char sname[], PetscErrorCode (*function)(PetscRandom)) ``` Not Collective ## Input Parameters - ***sname -*** The name of a new user-defined creation routine - ***function -*** The creation routine ## 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 src/sys/classes/random/interface/randreg.c --- [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](/manualpages/index.md) [Index of all manual pages](/manualpages/singleindex.md)