blitz  Version 0.9
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
discrete-uniform.h
Go to the documentation of this file.
1 #ifndef BZ_RANDOM_DISCRETE_UNIFORM_H
2 #define BZ_RANDOM_DISCRETE_UNIFORM_H
3 
4 #include <random/default.h>
5 
6 BZ_NAMESPACE(ranlib)
7 
8 template<typename T = unsigned int, typename IRNG = defaultIRNG,
9  typename stateTag = defaultState>
10 class DiscreteUniform : public IRNGWrapper<IRNG,stateTag>
11 {
12 public:
13  typedef T T_numtype;
14 
16  {
17  BZPRECONDITION(n < 4294967295U);
18  n_ = n;
19  }
20 
21  T random()
22  {
23  return this->irng_.random() % n_;
24  }
25 
26 private:
27  T n_;
28 };
29 
31 
32 #endif // BZ_RANDOM_DISCRETE_UNIFORM_H