|
Orrery
A GPU-accelerated N-body gravitational simulator
|
A seeded stream of random numbers. More...
#include <orrery/core/random.hpp>
Public Member Functions | |
| RandomSource (std::uint64_t seed) noexcept | |
| Start a stream from the given seed. | |
| std::uint64_t | seed () const noexcept |
| The seed this stream was started from. | |
| Real | uniform () noexcept |
| A number in [0, 1). | |
| Real | uniform (Real low, Real high) noexcept |
| A number in [low, high). | |
| Vec3 | unit_vector () noexcept |
| A direction drawn uniformly over the unit sphere. | |
A seeded stream of random numbers.
Passed by reference to everything that needs randomness, so that one run draws from one stream. Two generators seeded independently inside one setup would make the configuration depend on the order in which they happened to be constructed.
|
explicitnoexcept |
Start a stream from the given seed.
There is no default seed and no seeding from a device. A generator that can be constructed without a seed will eventually be constructed without one, and the run that produced a result will not be repeatable.
|
inlinenodiscardnoexcept |
The seed this stream was started from.
Kept so that whatever reports a result, a failing test or a run's metadata, can record the one number needed to reproduce it without the caller having to carry it alongside.
|
nodiscardnoexcept |
A number in [0, 1).
Half open at the top on purpose: several samplers below divide by the value or raise it to a negative power, and the closed form would make those unbounded once in every few billion draws.
|
nodiscardnoexcept |
A direction drawn uniformly over the unit sphere.
Every spherically symmetric configuration in the project needs one, and the obvious construction, an angle from each of two uniform draws, is wrong: it concentrates points at the poles. Uniformity in area needs the cosine of the polar angle to be the uniform variable, which is what this does.