petsc4py.PETSc.Random

class petsc4py.PETSc.Random

Bases: Object

The random number generator object.

See also

petsc.PetscRandom

Enumerations

Type

The random number generator type.

Methods Summary

create([comm])

Create a random number generator object.

destroy()

Destroy the random number generator object.

getInterval()

Return the interval containing the random numbers generated.

getSeed()

Return the random number generator seed.

getType()

Return the type of the random number generator object.

getValue()

Generate a scalar random number.

getValueReal()

Generate a real random number.

setFromOptions()

Configure the random number generator from the options database.

setInterval(interval)

Set the interval of the random number generator.

setSeed([seed])

Set the seed of random number generator.

setType(rnd_type)

Set the type of the random number generator object.

view([viewer])

View a random number generator object.

Attributes Summary

interval

The interval of the generated random numbers.

seed

The seed of the random number generator.

Methods Documentation

create(comm=None)

Create a random number generator object.

Collective.

Parameters:

comm (Comm | None) – MPI communicator, defaults to Sys.getDefaultComm.

Return type:

Self

See also

Sys.getDefaultComm, petsc.PetscRandomCreate

Source code at petsc4py/PETSc/Random.pyx:73

destroy()

Destroy the random number generator object.

Collective.

See also

petsc.PetscRandomDestroy

Source code at petsc4py/PETSc/Random.pyx:60

Return type:

Self

getInterval()

Return the interval containing the random numbers generated.

Not collective.

See also

setInterval, petsc.PetscRandomGetInterval

Source code at petsc4py/PETSc/Random.pyx:198

Return type:

tuple[Scalar, Scalar]

getSeed()

Return the random number generator seed.

Not collective.

See also

setSeed, petsc.PetscRandomGetSeed

Source code at petsc4py/PETSc/Random.pyx:165

Return type:

int

getType()

Return the type of the random number generator object.

Not collective.

See also

setType, petsc.PetscRandomGetType

Source code at petsc4py/PETSc/Random.pyx:111

Return type:

str

getValue()

Generate a scalar random number.

Not collective.

See also

petsc.PetscRandomGetValue

Source code at petsc4py/PETSc/Random.pyx:137

Return type:

Scalar

getValueReal()

Generate a real random number.

Not collective.

See also

petsc.PetscRandomGetValueReal

Source code at petsc4py/PETSc/Random.pyx:151

Return type:

float

setFromOptions()

Configure the random number generator from the options database.

Collective.

See also

Working with PETSc options (TODO), petsc.PetscRandomSetFromOptions

Source code at petsc4py/PETSc/Random.pyx:125

Return type:

None

setInterval(interval)

Set the interval of the random number generator.

Not collective.

See also

getInterval, petsc.PetscRandomSetInterval

Source code at petsc4py/PETSc/Random.pyx:213

Parameters:

interval (tuple[Scalar, Scalar]) –

Return type:

None

setSeed(seed=None)

Set the seed of random number generator.

Not collective.

Parameters:

seed (int | None) – The value for the seed. If None, it only seeds the generator.

Return type:

None

See also

getSeed, petsc.PetscRandomSetSeed, petsc.PetscRandomSeed

Source code at petsc4py/PETSc/Random.pyx:179

setType(rnd_type)

Set the type of the random number generator object.

Collective.

Parameters:

rnd_type (Type | str) – The type of the generator.

Return type:

None

See also

getType, petsc.PetscRandomSetType

Source code at petsc4py/PETSc/Random.pyx:92

view(viewer=None)

View a random number generator object.

Collective.

Parameters:

viewer (Viewer | None) – A Viewer instance or None for the default viewer.

Return type:

None

See also

petsc.PetscRandomView

Source code at petsc4py/PETSc/Random.pyx:40

Attributes Documentation

interval

The interval of the generated random numbers.

Source code at petsc4py/PETSc/Random.pyx:239

seed

The seed of the random number generator.

Source code at petsc4py/PETSc/Random.pyx:232