petsc-3.9.4 2018-09-11
Report Typos and Errors

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 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

Examples

src/ksp/pc/examples/tutorials/ex3.c.html
src/ksp/ksp/examples/tutorials/ex2.c.html
src/ksp/ksp/examples/tutorials/ex5.c.html
src/ksp/ksp/examples/tutorials/ex11.c.html
src/ksp/ksp/examples/tutorials/ex18.c.html
src/ksp/ksp/examples/tutorials/ex46.c.html
src/ksp/ksp/examples/tutorials/ex52.c.html
src/ksp/ksp/examples/tutorials/ex2f.F90.html
src/ksp/ksp/examples/tutorials/ex11f.F90.html
src/snes/examples/tutorials/ex70.c.html
src/ts/examples/tutorials/ex42.c.html

Implementations

VecSetRandom_Seq in src/vec/vec/impls/seq/bvec2.c
VecSetRandom_SeqCUDA_Private in src/vec/vec/impls/seq/seqcuda/veccuda.c
VecSetRandom_SeqCUDA in src/vec/vec/impls/seq/seqcuda/veccuda.c
VecSetRandom_SeqViennaCL_Private in src/vec/vec/impls/seq/seqviennacl/vecviennacl.cxx
VecSetRandom_SeqViennaCL in src/vec/vec/impls/seq/seqviennacl/vecviennacl.cxx

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