|
sgsPy
structurally guided sampling
|
#include <helper.h>
Public Member Functions | |
| RandValController (int xBlockSize, int yBlockSize, uint64_t multiplier, xso::xoshiro_4x64_plus *p_rng) | |
| void | calculateRandValues (void) |
| bool | next (void) |
This struct controls the calculation and usage of random values during the iteration through the raster. A random number must be generated for each pixel to see if it will be saved for potential sampling.
The xoshiro random number generator is used because it is efficient and statistically sound. The specific generator used (xso::xoshrio_4x64_plus) is used because it is very fast. However, it's lowest 11 bits have low linear complexity (Blackman & Vigna).
We have no need for these lower 11 bits, instead using only the upper 53 bits of the uint64_t value. Proof of this is that, supposing we require the use of all 53 bits, this means a probability of 1/(2^(56)), or roughly 1 sample per 10^16 pixels. If there were 10^16 pixels to process than a minimum of multiple years would likely pass before execution finished.
Rather than calling the generator on every iteration, the generator is repeatedly called at the beginning of a block for the remaining required pixels, and the true/false values for whether to save a pixel or not are stored in a vector of type boolean.
|
inline |
Constructor, sets the size of the boolean vector, and assigns the randValIndex, multiplier, and p_rng member variables.
| int | xBlockSize |
| int | yBlockSize |
| uint64_t | multiplier |
| xso::xoshiro_4x64_plus | *p_rng |
|
inline |
Calculates the true/false values from rand values, a number of times equal to the number of used random values from the previous block. The return value of the random number generator is bit shifted by 11 to ignore the lower 11 bits, which have low linear complexity.
Next, the bit shifted random value is masked with the multiplier, and if the random value contains a 1 in every bit which the multiplier does, true is added to the rand val vector.
This function is called before iterating through a new block.
|
inline |
get the next boolean value from the storage vector, and increment the index of this vector.