petsc-3.3-p7 2013-05-11

VecSetRandom

Sets all components of a vector to random numbers.

Synopsis

#include "petscvec.h" 
PetscErrorCode  VecSetRandom(Vec x,PetscRandom rctx)
Logically Collective on Vec

Input Parameters

x - the vector
rctx - the random number context, formed by PetscRandomCreate(), or PETSC_NULL and it will create one internally.

Output Parameter

x -the vector

Example of Usage

     PetscRandomCreate(PETSC_COMM_WORLD,&rctx);
     VecSetRandom(x,rctx);
     PetscRandomDestroy(rctx);

See Also

VecSet(), VecSetValues(), PetscRandomCreate(), PetscRandomDestroy()

Level:intermediate
Location:
src/vec/vec/interface/vector.c
Index of all Vec routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/ksp/ksp/examples/tutorials/ex2.c.html
src/ksp/ksp/examples/tutorials/ex4.c.html
src/ksp/ksp/examples/tutorials/ex11.c.html
src/ksp/ksp/examples/tutorials/ex39.c.html
src/ksp/ksp/examples/tutorials/ex40.c.html
src/ksp/ksp/examples/tutorials/ex46.c.html
src/ksp/ksp/examples/tutorials/ex52.c.html
src/ksp/ksp/examples/tutorials/ex2f.F.html
src/ksp/ksp/examples/tutorials/ex11f.F.html
src/snes/examples/tutorials/ex35.c.html
src/snes/examples/tutorials/ex54.c.html