PetscRandomSetFromOptions — PETSc 3.21.4 documentation

Skip to main content
`Ctrl`+`K`

# PetscRandomSetFromOptions

Configures the random number generator from the options database.

## Synopsis

    #include "petscsys.h"
    PetscErrorCode PetscRandomSetFromOptions(PetscRandom rnd)

Collective

## Input Parameter

- rnd - The random number generator context

## Options Database Keys

- -random_seed - provide a seed to the random number generator

- -random_no_imaginary_part - makes the imaginary part of the random number zero, this is useful when you want the same code to produce the same result when run with real numbers or complex numbers for regression testing purposes

## Note

Must be called after `PetscRandomCreate()` but before the rnd is used.

## See Also

`PetscRandom`, `PetscRandomCreate()`, `PetscRandomSetType()`

## Level

beginner

## Location

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

## Examples

src/ksp/ksp/tutorials/ex46.c
src/ksp/ksp/tutorials/ex52.c
src/ksp/ksp/tutorials/ex11.c
src/dm/field/tutorials/ex1.c
src/ksp/ksp/tutorials/ex57f.F90
src/ksp/ksp/tutorials/ex2f.F90
src/ksp/ksp/tutorials/ex11f.F90
src/ksp/ksp/tutorials/ex5.c
src/ksp/ksp/tutorials/ex21.c
src/ksp/ksp/tutorials/ex18.c

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