00001 /********************************************************************** 00002 rand.h - Pseudo random number generator. 00003 00004 Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc. 00005 Some portions Copyright (C) 2001-2006 by Geoffrey R. Hutchison 00006 00007 This file is part of the Open Babel project. 00008 For more information, see <http://openbabel.sourceforge.net/> 00009 00010 This program is free software; you can redistribute it and/or modify 00011 it under the terms of the GNU General Public License as published by 00012 the Free Software Foundation version 2 of the License. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 ***********************************************************************/ 00019 00020 #ifndef RAND_H 00021 #define RAND_H 00022 00023 #include <openbabel/babelconfig.h> 00024 00025 namespace OpenBabel 00026 { 00027 00028 //****************************************** 00029 //*** Stuff for random number generation *** 00030 //****************************************** 00031 00034 typedef struct 00035 { 00036 unsigned int hi; 00037 unsigned int lo; 00038 } 00039 DoubleType; 00040 00041 OBAPI void DoubleMultiply( unsigned int,unsigned int,DoubleType*); 00042 OBAPI void DoubleAdd( DoubleType*,unsigned int); 00043 OBAPI unsigned int DoubleModulus( DoubleType*,unsigned int); 00044 00047 00068 class OBAPI OBRandom 00069 { 00070 DoubleType d; 00071 unsigned int m,a,c; 00072 unsigned int p; 00073 unsigned int i; 00074 unsigned int x; 00075 bool OBRandomUseSysRand; 00076 00077 public: 00079 OBRandom(bool useSys= false); 00081 void Seed(int seed) 00082 { 00083 x = seed; 00084 } 00088 void TimeSeed(); 00090 int NextInt(); 00092 double NextFloat(); 00093 }; 00094 00095 } // end namespace OpenBabel 00096 00097 #endif // RAND_H 00098
This file is part of the documentation for Open Babel, version 2.2.0.