Skip to main content
Ctrl+K
PETSc v3.26.0-2-g3c5cfaeaff0b documentation - Home
  • Overview
  • Install
  • Tutorials
  • User-Guide
  • C/Fortran API
  • petsc4py API
  • FAQ
  • Community
  • Developers
  • Misc.
  • GitLab
  • Overview
  • Install
  • Tutorials
  • User-Guide
  • C/Fortran API
  • petsc4py API
  • FAQ
  • Community
  • Developers
  • Misc.
  • GitLab
  • PetscRandomG...

PetscRandomGetValuesReal#

Generates a sequence of real random numbers. Call this after first calling PetscRandomCreate().

Synopsis#

#include "petscsys.h" 
PetscErrorCode PetscRandomGetValuesReal(PetscRandom r, PetscInt n, PetscReal *val)

Not Collective

Input Parameters#

  • r - the random number generator context

  • n - number of random numbers to generate

Output Parameter#

  • val - the array to hold the values

Note#

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

See Also#

PetscRandom, PetscRandomCreate(), PetscRandomDestroy(), VecSetRandom(), PetscRandomGetValues()

Level#

intermediate

Location#

src/sys/classes/random/interface/random.c

Examples#

src/ksp/ksp/tutorials/ex21.c
src/ksp/ksp/tutorials/ex82.c
src/mat/tests/ex241.c
src/mat/tests/ex246.cxx
src/mat/tests/ex268.c
src/mat/tests/ex66.c
src/vec/is/utils/tests/ex1.c

Implementations#

PetscRandomGetValuesReal_CURAND() in src/sys/classes/random/impls/curand/curand.c
PetscRandomGetValuesReal_Random123() in src/sys/classes/random/impls/random123/random123.c


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

On this page
  • Synopsis
  • Input Parameters
  • Output Parameter
  • Note
  • See Also
  • Level
  • Location
  • Examples
  • Implementations
Edit on GitLab
Show Source

© Copyright 1991-2026, UChicago Argonne, LLC and the PETSc Development Team.

Created using Sphinx 7.3.7.

Built with the PyData Sphinx Theme 0.15.1.

Last updated on 2026-09-28T23:19:25-0500 (v3.26.0-2-g3c5cfaeaff0b).