Warning, file /include/opencascade/math_BullardGenerator.hxx was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _math_BullardGenerator_HeaderFile
0017 #define _math_BullardGenerator_HeaderFile
0018
0019 #include <Standard_Real.hxx>
0020
0021
0022 class math_BullardGenerator
0023 {
0024 public:
0025
0026
0027 math_BullardGenerator (unsigned int theSeed = 1)
0028 : myStateHi (theSeed)
0029 {
0030 SetSeed (theSeed);
0031 }
0032
0033
0034 void SetSeed (unsigned int theSeed = 1)
0035 {
0036 myStateHi = theSeed;
0037 myStateLo = theSeed ^ 0x49616E42;
0038 }
0039
0040
0041 unsigned int NextInt()
0042 {
0043 myStateHi = (myStateHi >> 2) + (myStateHi << 2);
0044
0045 myStateHi += myStateLo;
0046 myStateLo += myStateHi;
0047
0048 return myStateHi;
0049 }
0050
0051
0052 Standard_Real NextReal()
0053 {
0054 return NextInt() / static_cast<Standard_Real> (0xFFFFFFFFu);
0055 }
0056
0057 private:
0058
0059 unsigned int myStateHi;
0060 unsigned int myStateLo;
0061
0062 };
0063
0064 #endif