petsc4py.PETSc.Random#

class petsc4py.PETSc.Random#

Bases: Object

The random number generator object.

See also

PetscRandom

Enumerations

Type

The random number generator type.

Methods Summary

appendOptionsPrefix(prefix)

Append to prefix used for all Random options in the database.

create([comm])

Create a random number generator object.

destroy()

Destroy the random number generator object.

getInterval()

Return the interval containing the random numbers generated.

getOptionsPrefix()

Return the prefix used for all Random options in the database.

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.

setOptionsPrefix(prefix)

Set the prefix used for all Random options in the database.

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

appendOptionsPrefix(prefix)#

Append to prefix used for all Random options in the database.

Logically collective.

Parameters:

prefix (str | None) – The options prefix to append.

Return type:

None

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

create(comm=None)#

Create a random number generator object.

Collective.

Parameters:

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

Return type:

Self

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

destroy()#

Destroy the random number generator object.

Collective.

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

Return type:

Self

getInterval()#

Return the interval containing the random numbers generated.

Not collective.

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

Return type:

tuple[Scalar, Scalar]

getOptionsPrefix()#

Return the prefix used for all Random options in the database.

Not collective.

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

Return type:

str

getSeed()#

Return the random number generator seed.

Not collective.

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

Return type:

int

getType()#

Return the type of the random number generator object.

Not collective.

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

Return type:

str

getValue()#

Generate a scalar random number.

Not collective.

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

Return type:

Scalar

getValueReal()#

Generate a real random number.

Not collective.

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

Return type:

float

setFromOptions()#

Configure the random number generator from the options database.

Collective.

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

Return type:

None

setInterval(interval)#

Set the interval of the random number generator.

Not collective.

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

Parameters:

interval (tuple[Scalar, Scalar])

Return type:

None

setOptionsPrefix(prefix)#

Set the prefix used for all Random options in the database.

Logically collective.

Parameters:

prefix (str | None) – The options prefix.

Return type:

None

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

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

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

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

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

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

PetscRandomView

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

Attributes Documentation

interval#

The interval of the generated random numbers.

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

seed#

The seed of the random number generator.

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