Skip to content

accept user-specified rng for random-number generation #303

@stevengj

Description

@stevengj

Rather than calling rand(...), it would be good to call rand(rng, ...) with an optionally user-specified rng::AbstractRNG keyword argument in algorithms that require pseudo-random initialization, e.g. lobpcg (

@inbounds X[:,j] .= rand.()
), bicgstabl (
r_shadow = rand(T, n)
), and idrs (
r_shadow = rand(T, n)
).

Rationale: if deterministic results are desired (as is often the case), it is better for the user to be able to specify an RNG than setting the global Random.seed!.

Moreover, arguably the default rng should be a new deterministic RNG object created with a fixed seed every time the iterative solver is initialized, so that the algorithm defaults to being deterministic.

(Note: "deterministic" ≠ "reproducible" … e.g. changing the Julia version could change the results. But it is useful to be able to run the same code with the same software on the same hardware multiple times and get exactly the same results as much as possible.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions