#ifndef RANDOM_NUMBERS_H #define RANDOM_NUMBERS_H #include #include #include #include "blitz/array.h" class RandomNumbers { public: RandomNumbers(int seed); int rollUniform(int min, int max); double rollUniform(double min, double max); std::mt19937* engine(); private: std::shared_ptr engine_; std::uniform_real_distribution 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 num_bins); // get the next index blitz::TinyVector 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 num_bins_; std::vector one_dimensional_indices_; size_t total_bin_number_; size_t current_index_in_vector_; }; #endif /* RANDOM_NUMBERS_H */