Bin based drawing implemented (debug output not
yet removed)
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#include <memory>
|
||||
#include <random>
|
||||
|
||||
#include "blitz/array.h"
|
||||
|
||||
class RandomNumbers {
|
||||
public:
|
||||
RandomNumbers(int seed);
|
||||
@@ -19,4 +21,31 @@ class RandomNumbers {
|
||||
std::uniform_real_distribution<double> real_distribution_;
|
||||
};
|
||||
|
||||
// class to handle a random walk through a density field, where every
|
||||
// bin is visited exactly once
|
||||
class RandomIndex {
|
||||
public:
|
||||
// num_bins: contains the number of bins of all dimensions of a
|
||||
// density binning (order: radial, azimuthal, longitudinal,
|
||||
// pitch angle, energy)
|
||||
RandomIndex(blitz::TinyVector<int, 5> num_bins);
|
||||
|
||||
// get the next index
|
||||
blitz::TinyVector<int, 5> index();
|
||||
|
||||
// check if all bins have been visited
|
||||
bool visited_all();
|
||||
|
||||
// create a new random order and reset the check if all bins have been visited
|
||||
void reshuffle(std::mt19937* engine);
|
||||
|
||||
private:
|
||||
const blitz::TinyVector<int, 5> num_bins_;
|
||||
|
||||
std::vector<size_t> one_dimensional_indices_;
|
||||
|
||||
size_t total_bin_number_;
|
||||
size_t current_index_in_vector_;
|
||||
};
|
||||
|
||||
#endif /* RANDOM_NUMBERS_H */
|
||||
|
||||
Reference in New Issue
Block a user