VecSetRandom#
Sets all components of a vector to random numbers.
Synopsis#
#include "petscvec.h"
PetscErrorCode VecSetRandom(Vec x, PetscRandom rctx)
Logically Collective
Input Parameters#
x - the vector
rctx - the random number context, formed by
PetscRandomCreate()
, or useNULL
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#
Vectors and Parallel Data, Vec
, VecSet()
, VecSetValues()
, PetscRandomCreate()
, PetscRandomDestroy()
Level#
intermediate
Location#
Examples#
src/ksp/pc/tutorials/ex4.c
src/tao/bound/tutorials/plate2.c
src/ksp/pc/tutorials/ex3.c
src/snes/tutorials/ex7.c
src/tao/tutorials/ex4.c
src/ksp/ksp/tutorials/ex52.c
src/tao/bound/tutorials/plate2f.F90
src/snes/tutorials/ex11.c
src/ksp/ksp/tutorials/ex5.c
src/tao/unconstrained/tutorials/minsurf2.c
Implementations#
VecSetRandom_Nest() in src/vec/vec/impls/nest/vecnest.c
VecSetRandom_Seq() in src/vec/vec/impls/seq/bvec2.c
VecSetRandom_SeqKokkos() in src/vec/vec/impls/seq/kokkos/veckok.kokkos.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