PetscRandomRegister — PETSc 3.25.0 documentation

Skip to main content
`Ctrl`+`K`

# PetscRandomRegister

Adds a new `PetscRandom` implementation

## Synopsis

    #include "petscsys.h"
    PetscErrorCode PetscRandomRegister(const char sname[], PetscErrorCode (*function)(PetscRandom))

Not Collective, No Fortran Support

## 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 random number generators

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

## Example Usage

        PetscRandomRegister("my_rand",  MyPetscRandomtorCreate);

Then, your random type can be chosen with the procedural interface via

        PetscRandomCreate(MPI_Comm, PetscRandom *);
        PetscRandomSetType(PetscRandom,"my_random_name");

or at runtime via the option

        -random_type my_random_name

## See Also

`PetscRandom`, `PetscRandomRegisterAll()`, `PetscRandomRegisterDestroy()`

## Level

advanced

## Location

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

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