petsc-3.7.1 2016-05-15
Report Typos and Errors

# PetscRandomGetValue

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

### Synopsis

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

Not Collective Many br

### Intput Parameter

r -the random number generator context Many br

### Output Parameter

val -the value Many br

Many br

### Notes

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

When PETSc is compiled for complex numbers this returns a complex number with random real and complex parts. Many brUse PetscGetValueReal() to get a random real number. Many br

To get a complex number with only a random real part, first call PetscRandomSetInterval() with a equal Many brlow and high imaginary part. Similarly to get a complex number with only a random imaginary part call Many brPetscRandomSetInterval() with a equal low and high real part. Many br

### Example of Usage

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

Many br

### See Also

PetscRandomCreate(), PetscRandomDestroy(), VecSetRandom(), PetscRandomGetValueReal()

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

### Examples

src/sys/classes/random/examples/tutorials/ex1.c.html
src/sys/classes/random/examples/tutorials/ex2.c.html
src/ksp/ksp/examples/tutorials/ex11.c.html
src/ksp/ksp/examples/tutorials/ex11f.F.html