PetaVision  Alpha
RandomSeed.hpp
1 /*
2  * RandomSeed.hpp
3  *
4  * Created on: Jul 26, 2016
5  * Author: pschultz
6  */
7 
8 #ifndef RANDOMSEED_HPP_
9 #define RANDOMSEED_HPP_
10 
11 namespace PV {
12 
13 class RandomSeed {
14  public:
15  static RandomSeed *instance();
16  void initialize(unsigned int initialSeed);
17  unsigned int allocate(unsigned int numRequested);
18  unsigned int getInitialSeed() { return mInitialSeed; }
19 
20  private:
21  RandomSeed();
22  virtual ~RandomSeed() {}
23 
24  public:
25  static unsigned int constexpr minSeed = 10000000U;
26 
27  private:
28  unsigned int mNextSeed = 0U;
29  unsigned int mInitialSeed = 0U;
30  bool mInitialized = false;
31  // minSeed needs to be high enough that for the pseudorandom sequence to be
32  // good,
33  // but must be less than (and should be much less than) ULONG_MAX/2
34 };
35 
36 } /* namespace PV */
37 
38 #endif /* RANDOMSEED_HPP_ */