LOOS  v2.3.2
utils_random.cpp
1 /*
2  This file is part of LOOS.
3 
4  LOOS (Lightweight Object-Oriented Structure library)
5  Copyright (c) 2008, Tod D. Romo, Alan Grossfield
6  Department of Biochemistry and Biophysics
7  School of Medicine & Dentistry, University of Rochester
8 
9  This package (LOOS) is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation under version 3 of the License.
12 
13  This package is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 
23 #include <boost/random.hpp>
24 #include <utils_random.hpp>
25 
26 namespace loos {
27  base_generator_type& rng_singleton(void) {
28  static base_generator_type rng;
29 
30  return(rng);
31  }
32 
33 
34  // Seeding based on the block is not the best method, but probably
35  // sufficient for our purposes...
36  uint randomSeedRNG(void) {
37  base_generator_type& rng = rng_singleton();
38 
39  uint seedval = static_cast<uint>(time(0));
40 
41  rng.seed(seedval);
42  return(seedval);
43  }
44 };
uint randomSeedRNG(void)
Randomly seeds the RNG.
base_generator_type & rng_singleton(void)
Suite-wide random number generator singleton.
Namespace for most things not already encapsulated within a class.