1.1 --- a/lemon/random.h Fri Mar 02 17:56:22 2007 +0000
1.2 +++ b/lemon/random.h Fri Mar 02 18:04:28 2007 +0000
1.3 @@ -121,19 +121,19 @@
1.4 static const int length = 312;
1.5 static const int shift = 156;
1.6
1.7 - static const Word mul = (Word)0x5851F42Du << 32 | (Word)0x4C957F2Du;
1.8 - static const Word arrayInit = (Word)0x00000000u << 32 |(Word)0x012BD6AAu;
1.9 - static const Word arrayMul1 = (Word)0x369DEA0Fu << 32 |(Word)0x31A53F85u;
1.10 - static const Word arrayMul2 = (Word)0x27BB2EE6u << 32 |(Word)0x87B0B0FDu;
1.11 + static const Word mul = Word(0x5851F42Du) << 32 | Word(0x4C957F2Du);
1.12 + static const Word arrayInit = Word(0x00000000u) << 32 |Word(0x012BD6AAu);
1.13 + static const Word arrayMul1 = Word(0x369DEA0Fu) << 32 |Word(0x31A53F85u);
1.14 + static const Word arrayMul2 = Word(0x27BB2EE6u) << 32 |Word(0x87B0B0FDu);
1.15
1.16 - static const Word mask = (Word)0xB5026F5Au << 32 | (Word)0xA96619E9u;
1.17 - static const Word loMask = ((Word)1u << 31) - 1;
1.18 + static const Word mask = Word(0xB5026F5Au) << 32 | Word(0xA96619E9u);
1.19 + static const Word loMask = (Word(1u) << 31) - 1;
1.20 static const Word hiMask = ~loMask;
1.21
1.22 static Word tempering(Word rnd) {
1.23 - rnd ^= (rnd >> 29) & ((Word)0x55555555u << 32 | (Word)0x55555555u);
1.24 - rnd ^= (rnd << 17) & ((Word)0x71D67FFFu << 32 | (Word)0xEDA60000u);
1.25 - rnd ^= (rnd << 37) & ((Word)0xFFF7EEE0u << 32 | (Word)0x00000000u);
1.26 + rnd ^= (rnd >> 29) & (Word(0x55555555u) << 32 | Word(0x55555555u));
1.27 + rnd ^= (rnd << 17) & (Word(0x71D67FFFu) << 32 | Word(0xEDA60000u));
1.28 + rnd ^= (rnd << 37) & (Word(0xFFF7EEE0u) << 32 | Word(0x00000000u));
1.29 rnd ^= (rnd >> 43);
1.30 return rnd;
1.31 }
1.32 @@ -216,7 +216,7 @@
1.33 }
1.34 }
1.35
1.36 - state[length - 1] = (Word)1 << (bits - 1);
1.37 + state[length - 1] = Word(1) << (bits - 1);
1.38 }
1.39
1.40 void copyState(const RandomCore& other) {
1.41 @@ -273,14 +273,14 @@
1.42 struct Masker {
1.43 static Result mask(const Result& result) {
1.44 return Masker<Result, (shift + 1) / 2>::
1.45 - mask((Result)(result | (result >> shift)));
1.46 + mask(static_cast<Result>(result | (result >> shift)));
1.47 }
1.48 };
1.49
1.50 template <typename Result>
1.51 struct Masker<Result, 1> {
1.52 static Result mask(const Result& result) {
1.53 - return (Result)(result | (result >> 1));
1.54 + return static_cast<Result>(result | (result >> 1));
1.55 }
1.56 };
1.57
1.58 @@ -291,7 +291,7 @@
1.59 static const int bits = std::numeric_limits<Word>::digits;
1.60
1.61 static Result convert(RandomCore<Word>& rnd) {
1.62 - return (Result)(rnd() >> (bits - rest)) << shift;
1.63 + return static_cast<Result>(rnd() >> (bits - rest)) << shift;
1.64 }
1.65
1.66 };
1.67 @@ -301,7 +301,7 @@
1.68 static const int bits = std::numeric_limits<Word>::digits;
1.69
1.70 static Result convert(RandomCore<Word>& rnd) {
1.71 - return ((Result)rnd() << shift) |
1.72 + return (static_cast<Result>(rnd()) << shift) |
1.73 IntConversion<Result, Word, rest - bits, shift + bits>::convert(rnd);
1.74 }
1.75 };
1.76 @@ -312,7 +312,7 @@
1.77 std::numeric_limits<Result>::digits>
1.78 struct Mapping {
1.79 static Result map(RandomCore<Word>& rnd, const Result& bound) {
1.80 - Word max = (Word)(bound - 1);
1.81 + Word max = Word(bound - 1);
1.82 Result mask = Masker<Result>::mask(bound - 1);
1.83 Result num;
1.84 do {
1.85 @@ -325,7 +325,7 @@
1.86 template <typename Result, typename Word>
1.87 struct Mapping<Result, Word, false> {
1.88 static Result map(RandomCore<Word>& rnd, const Result& bound) {
1.89 - Word max = (Word)(bound - 1);
1.90 + Word max = Word(bound - 1);
1.91 Word mask = Masker<Word, (std::numeric_limits<Result>::digits + 1) / 2>
1.92 ::mask(max);
1.93 Word num;
1.94 @@ -341,7 +341,7 @@
1.95 static const Result multiplier() {
1.96 Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
1.97 res *= res;
1.98 - if ((exp & 1) == 1) res *= (Result)2.0;
1.99 + if ((exp & 1) == 1) res *= static_cast<Result>(2.0);
1.100 return res;
1.101 }
1.102 };
1.103 @@ -351,7 +351,7 @@
1.104 static const Result multiplier() {
1.105 Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
1.106 res *= res;
1.107 - if ((exp & 1) == 1) res *= (Result)0.5;
1.108 + if ((exp & 1) == 1) res *= static_cast<Result>(0.5);
1.109 return res;
1.110 }
1.111 };
1.112 @@ -359,35 +359,35 @@
1.113 template <typename Result>
1.114 struct ShiftMultiplier<Result, 0, true> {
1.115 static const Result multiplier() {
1.116 - return (Result)1.0;
1.117 + return static_cast<Result>(1.0);
1.118 }
1.119 };
1.120
1.121 template <typename Result>
1.122 struct ShiftMultiplier<Result, -20, true> {
1.123 static const Result multiplier() {
1.124 - return (Result)(1.0/1048576.0);
1.125 + return static_cast<Result>(1.0/1048576.0);
1.126 }
1.127 };
1.128
1.129 template <typename Result>
1.130 struct ShiftMultiplier<Result, -32, true> {
1.131 static const Result multiplier() {
1.132 - return (Result)(1.0/424967296.0);
1.133 + return static_cast<Result>(1.0/424967296.0);
1.134 }
1.135 };
1.136
1.137 template <typename Result>
1.138 struct ShiftMultiplier<Result, -53, true> {
1.139 static const Result multiplier() {
1.140 - return (Result)(1.0/9007199254740992.0);
1.141 + return static_cast<Result>(1.0/9007199254740992.0);
1.142 }
1.143 };
1.144
1.145 template <typename Result>
1.146 struct ShiftMultiplier<Result, -64, true> {
1.147 static const Result multiplier() {
1.148 - return (Result)(1.0/18446744073709551616.0);
1.149 + return static_cast<Result>(1.0/18446744073709551616.0);
1.150 }
1.151 };
1.152
1.153 @@ -406,7 +406,7 @@
1.154
1.155 static Result convert(RandomCore<Word>& rnd) {
1.156 return Shifting<Result, - shift - rest>::
1.157 - shift((Result)(rnd() >> (bits - rest)));
1.158 + shift(static_cast<Result>(rnd() >> (bits - rest)));
1.159 }
1.160 };
1.161
1.162 @@ -415,8 +415,10 @@
1.163 static const int bits = std::numeric_limits<Word>::digits;
1.164
1.165 static Result convert(RandomCore<Word>& rnd) {
1.166 - return Shifting<Result, - shift - bits>::shift((Result)rnd()) +
1.167 - RealConversion<Result, Word, rest-bits, shift + bits>::convert(rnd);
1.168 + return Shifting<Result, - shift - bits>::
1.169 + shift(static_cast<Result>(rnd())) +
1.170 + RealConversion<Result, Word, rest-bits, shift + bits>::
1.171 + convert(rnd);
1.172 }
1.173 };
1.174
1.175 @@ -427,7 +429,7 @@
1.176 static void init(RandomCore<Word>& rnd, Iterator begin, Iterator end) {
1.177 std::vector<Word> ws;
1.178 for (Iterator it = begin; it != end; ++it) {
1.179 - ws.push_back((Word)*it);
1.180 + ws.push_back(Word(*it));
1.181 }
1.182 rnd.initState(ws.begin(), ws.end());
1.183 }