Open Babel  3.0
rand.h
Go to the documentation of this file.
1 /**********************************************************************
2 rand.h - Pseudo random number generator.
3 
4 Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc.
5 Some portions Copyright (C) 2001-2006 by Geoffrey R. Hutchison
6 
7 This file is part of the Open Babel project.
8 For more information, see <http://openbabel.org/>
9 
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation version 2 of the License.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 ***********************************************************************/
19 
20 #ifndef RAND_H
21 #define RAND_H
22 
23 #include <openbabel/babelconfig.h>
24 
25 namespace OpenBabel
26 {
27 
28  //******************************************
29  //*** Stuff for random number generation ***
30  //******************************************
31 
34  typedef struct
35  {
36  unsigned int hi;
37  unsigned int lo;
38  }
39  DoubleType;
40 
41 
44 
65  class OBRandom
66  {
67  DoubleType d;
68  unsigned int m,a,c;
69  unsigned int p;
70  unsigned int i;
71  unsigned int x;
72  bool OBRandomUseSysRand;
73 
74  public:
76  OBRandom(bool useSys= false);
78  void Seed(int seed)
79  {
80  x = seed;
81  }
85  void TimeSeed();
87  int NextInt();
89  double NextFloat();
90  };
91 
92 } // end namespace OpenBabel
93 
94 #endif // RAND_H
95 
void TimeSeed()
Definition: rand.cpp:501
unsigned int lo
Definition: rand.h:37
unsigned int hi
Definition: rand.h:36
OBRandom(bool useSys=false)
Constructor. useSys will use the system rand() function.
Definition: rand.cpp:454
int NextInt()
Definition: rand.cpp:466
Used for internal random number generation OBRandom (unless the system random generator is used) ...
Definition: rand.h:34
void Seed(int seed)
Use seed for the random number generator seed.
Definition: rand.h:78
double NextFloat()
Definition: rand.cpp:483
Random number generator.
Definition: rand.h:65
Global namespace for all Open Babel code.
Definition: alias.h:22