Zero  0.1.0
randgen.h
Go to the documentation of this file.
1 /* -*- mode:C++; c-basic-offset:4 -*-
2  Shore-kits -- Benchmark implementations for Shore-MT
3 
4  Copyright (c) 2007-2009
5  Data Intensive Applications and Systems Labaratory (DIAS)
6  Ecole Polytechnique Federale de Lausanne
7 
8  All Rights Reserved.
9 
10  Permission to use, copy, modify and distribute this software and
11  its documentation is hereby granted, provided that both the
12  copyright notice and this permission notice appear in all copies of
13  the software, derivative works or modified versions, and any
14  portions thereof, and that both notices appear in supporting
15  documentation.
16 
17  This code is distributed in the hope that it will be useful, but
18  WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS
20  DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
21  RESULTING FROM THE USE OF THIS SOFTWARE.
22 */
23 
24 #ifndef __RANDGEN_H
25 #define __RANDGEN_H
26 
28 
29 #include <cassert>
30 
31 class randgen_t {
33 
34 public:
35 
36  void reset(unsigned int seed) {
37  rng.init(seed);
38  }
39 
40  int rand() {
41  return rng.randInt() & 0x7fffffff;
42  }
43 
48  int rand(int n) {
49  assert(n > 0);
50  return rng.randInt(n);
51  }
52 };
53 
54 #endif // __RANDGEN_H
RandomTempl< MersenneTwisterInternal > MersenneTwisterRandom
Definition: MersenneTwisterRandom.hpp:90
int rand()
Definition: randgen.h:40
int rand(int n)
Definition: randgen.h:48
MersenneTwisterRandom rng
Definition: randgen.h:32
void reset(unsigned int seed)
Definition: randgen.h:36
Mersenne Twister Randum Number Generator.
Definition: randgen.h:31