# PetscRandomGetValue

Generates a random number. Call this after first calling PetscRandomCreate().

### Synopsis

    #include "petscsys.h"
    PetscErrorCode PETSC_DLLEXPORT PetscRandomGetValue(PetscRandom r,PetscScalar *val)

Not Collective

### Intput Parameter

r -the random number generator context

### Output Parameter

val -the value

### Notes

Use VecSetRandom() to set the elements of a vector to random numbers.

### Example of Usage

          PetscRandomCreate(PETSC_COMM_WORLD,RANDOM_DEFAULT,&r);
          PetscRandomGetValue(r,&value1);
          PetscRandomGetValue(r,&value2);
          PetscRandomGetValue(r,&value3);
          PetscRandomDestroy(r);

### See Also

PetscRandomCreate(), PetscRandomDestroy(), VecSetRandom()

Level:intermediate
Location:src/sys/src/utils/random.c
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/ksp/examples/tutorials/ex11.c.html
src/ksp/examples/tutorials/ex11f.F.html