Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/random/detail/const_mod.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
comparison
equal
deleted
inserted
replaced
100:793467b5e61c | 101:c530137014c0 |
---|---|
5 * accompanying file LICENSE_1_0.txt or copy at | 5 * accompanying file LICENSE_1_0.txt or copy at |
6 * http://www.boost.org/LICENSE_1_0.txt) | 6 * http://www.boost.org/LICENSE_1_0.txt) |
7 * | 7 * |
8 * See http://www.boost.org for most recent version including documentation. | 8 * See http://www.boost.org for most recent version including documentation. |
9 * | 9 * |
10 * $Id: const_mod.hpp 71018 2011-04-05 21:27:52Z steven_watanabe $ | 10 * $Id$ |
11 * | 11 * |
12 * Revision history | 12 * Revision history |
13 * 2001-02-18 moved to individual header files | 13 * 2001-02-18 moved to individual header files |
14 */ | 14 */ |
15 | 15 |
34 static IntType apply(IntType x) | 34 static IntType apply(IntType x) |
35 { | 35 { |
36 if(((unsigned_m() - 1) & unsigned_m()) == 0) | 36 if(((unsigned_m() - 1) & unsigned_m()) == 0) |
37 return (unsigned_type(x)) & (unsigned_m() - 1); | 37 return (unsigned_type(x)) & (unsigned_m() - 1); |
38 else { | 38 else { |
39 IntType supress_warnings = (m == 0); | 39 IntType suppress_warnings = (m == 0); |
40 BOOST_ASSERT(supress_warnings == 0); | 40 BOOST_ASSERT(suppress_warnings == 0); |
41 return x % (m + supress_warnings); | 41 return x % (m + suppress_warnings); |
42 } | 42 } |
43 } | 43 } |
44 | 44 |
45 static IntType add(IntType x, IntType c) | 45 static IntType add(IntType x, IntType c) |
46 { | 46 { |
75 if(((unsigned_m() - 1) & unsigned_m()) == 0) | 75 if(((unsigned_m() - 1) & unsigned_m()) == 0) |
76 return (unsigned_type(a) * unsigned_type(x) + unsigned_type(c)) & (unsigned_m() - 1); | 76 return (unsigned_type(a) * unsigned_type(x) + unsigned_type(c)) & (unsigned_m() - 1); |
77 else if(a == 0) | 77 else if(a == 0) |
78 return c; | 78 return c; |
79 else if(m <= (traits::const_max-c)/a) { // i.e. a*m+c <= max | 79 else if(m <= (traits::const_max-c)/a) { // i.e. a*m+c <= max |
80 IntType supress_warnings = (m == 0); | 80 IntType suppress_warnings = (m == 0); |
81 BOOST_ASSERT(supress_warnings == 0); | 81 BOOST_ASSERT(suppress_warnings == 0); |
82 return (a*x+c) % (m + supress_warnings); | 82 return (a*x+c) % (m + suppress_warnings); |
83 } else | 83 } else |
84 return add(mult(a, x), c); | 84 return add(mult(a, x), c); |
85 } | 85 } |
86 | 86 |
87 static IntType pow(IntType a, boost::uintmax_t exponent) | 87 static IntType pow(IntType a, boost::uintmax_t exponent) |
106 | 106 |
107 const_mod(); // don't instantiate | 107 const_mod(); // don't instantiate |
108 | 108 |
109 static IntType mult_small(IntType a, IntType x) | 109 static IntType mult_small(IntType a, IntType x) |
110 { | 110 { |
111 IntType supress_warnings = (m == 0); | 111 IntType suppress_warnings = (m == 0); |
112 BOOST_ASSERT(supress_warnings == 0); | 112 BOOST_ASSERT(suppress_warnings == 0); |
113 return a*x % (m + supress_warnings); | 113 return a*x % (m + suppress_warnings); |
114 } | 114 } |
115 | 115 |
116 static IntType mult_schrage(IntType a, IntType value) | 116 static IntType mult_schrage(IntType a, IntType value) |
117 { | 117 { |
118 const IntType q = m / a; | 118 const IntType q = m / a; |