|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r86325 - trunk/boost/random
From: loufoque_at_[hidden]
Date: 2013-10-15 12:40:51
Author: mgaunard
Date: 2013-10-15 12:40:51 EDT (Tue, 15 Oct 2013)
New Revision: 86325
URL: http://svn.boost.org/trac/boost/changeset/86325
Log:
random: add explicit casts in normal_distribution.hpp to avoid truncation warnings with MSVC
Text files modified:
trunk/boost/random/normal_distribution.hpp | 144 ++++++++++++++++++++--------------------
1 files changed, 72 insertions(+), 72 deletions(-)
Modified: trunk/boost/random/normal_distribution.hpp
==============================================================================
--- trunk/boost/random/normal_distribution.hpp Tue Oct 15 12:18:02 2013 (r86324)
+++ trunk/boost/random/normal_distribution.hpp 2013-10-15 12:40:51 EDT (Tue, 15 Oct 2013) (r86325)
@@ -48,76 +48,76 @@
template<class RealType>
const RealType normal_table<RealType>::table_x[129] = {
- 3.7130862467403632609, 3.4426198558966521214, 3.2230849845786185446, 3.0832288582142137009,
- 2.9786962526450169606, 2.8943440070186706210, 2.8231253505459664379, 2.7611693723841538514,
- 2.7061135731187223371, 2.6564064112581924999, 2.6109722484286132035, 2.5690336259216391328,
- 2.5300096723854666170, 2.4934545220919507609, 2.4590181774083500943, 2.4264206455302115930,
- 2.3954342780074673425, 2.3658713701139875435, 2.3375752413355307354, 2.3104136836950021558,
- 2.2842740596736568056, 2.2590595738653295251, 2.2346863955870569803, 2.2110814088747278106,
- 2.1881804320720206093, 2.1659267937448407377, 2.1442701823562613518, 2.1231657086697899595,
- 2.1025731351849988838, 2.0824562379877246441, 2.0627822745039633575, 2.0435215366506694976,
- 2.0246469733729338782, 2.0061338699589668403, 1.9879595741230607243, 1.9701032608497132242,
- 1.9525457295488889058, 1.9352692282919002011, 1.9182573008597320303, 1.9014946531003176140,
- 1.8849670357028692380, 1.8686611409895420085, 1.8525645117230870617, 1.8366654602533840447,
- 1.8209529965910050740, 1.8054167642140487420, 1.7900469825946189862, 1.7748343955807692457,
- 1.7597702248942318749, 1.7448461281083765085, 1.7300541605582435350, 1.7153867407081165482,
- 1.7008366185643009437, 1.6863968467734863258, 1.6720607540918522072, 1.6578219209482075462,
- 1.6436741568569826489, 1.6296114794646783962, 1.6156280950371329644, 1.6017183802152770587,
- 1.5878768648844007019, 1.5740982160167497219, 1.5603772223598406870, 1.5467087798535034608,
- 1.5330878776675560787, 1.5195095847593707806, 1.5059690368565502602, 1.4924614237746154081,
- 1.4789819769830978546, 1.4655259573357946276, 1.4520886428822164926, 1.4386653166774613138,
- 1.4252512545068615734, 1.4118417124397602509, 1.3984319141236063517, 1.3850170377251486449,
- 1.3715922024197322698, 1.3581524543224228739, 1.3446927517457130432, 1.3312079496576765017,
- 1.3176927832013429910, 1.3041418501204215390, 1.2905495919178731508, 1.2769102735516997175,
- 1.2632179614460282310, 1.2494664995643337480, 1.2356494832544811749, 1.2217602305309625678,
- 1.2077917504067576028, 1.1937367078237721994, 1.1795873846544607035, 1.1653356361550469083,
- 1.1509728421389760651, 1.1364898520030755352, 1.1218769225722540661, 1.1071236475235353980,
- 1.0922188768965537614, 1.0771506248819376573, 1.0619059636836193998, 1.0464709007525802629,
- 1.0308302360564555907, 1.0149673952392994716, 0.99886423348064351303, 0.98250080350276038481,
- 0.96585507938813059489, 0.94890262549791195381, 0.93161619660135381056, 0.91396525100880177644,
- 0.89591535256623852894, 0.87742742909771569142, 0.85845684317805086354, 0.83895221428120745572,
- 0.81885390668331772331, 0.79809206062627480454, 0.77658398787614838598, 0.75423066443451007146,
- 0.73091191062188128150, 0.70647961131360803456, 0.68074791864590421664, 0.65347863871504238702,
- 0.62435859730908822111, 0.59296294244197797913, 0.55869217837551797140, 0.52065603872514491759,
- 0.47743783725378787681, 0.42654798630330512490, 0.36287143102841830424, 0.27232086470466385065,
- 0
+ RealType(3.7130862467403632609), RealType(3.4426198558966521214), RealType(3.2230849845786185446), RealType(3.0832288582142137009),
+ RealType(2.9786962526450169606), RealType(2.8943440070186706210), RealType(2.8231253505459664379), RealType(2.7611693723841538514),
+ RealType(2.7061135731187223371), RealType(2.6564064112581924999), RealType(2.6109722484286132035), RealType(2.5690336259216391328),
+ RealType(2.5300096723854666170), RealType(2.4934545220919507609), RealType(2.4590181774083500943), RealType(2.4264206455302115930),
+ RealType(2.3954342780074673425), RealType(2.3658713701139875435), RealType(2.3375752413355307354), RealType(2.3104136836950021558),
+ RealType(2.2842740596736568056), RealType(2.2590595738653295251), RealType(2.2346863955870569803), RealType(2.2110814088747278106),
+ RealType(2.1881804320720206093), RealType(2.1659267937448407377), RealType(2.1442701823562613518), RealType(2.1231657086697899595),
+ RealType(2.1025731351849988838), RealType(2.0824562379877246441), RealType(2.0627822745039633575), RealType(2.0435215366506694976),
+ RealType(2.0246469733729338782), RealType(2.0061338699589668403), RealType(1.9879595741230607243), RealType(1.9701032608497132242),
+ RealType(1.9525457295488889058), RealType(1.9352692282919002011), RealType(1.9182573008597320303), RealType(1.9014946531003176140),
+ RealType(1.8849670357028692380), RealType(1.8686611409895420085), RealType(1.8525645117230870617), RealType(1.8366654602533840447),
+ RealType(1.8209529965910050740), RealType(1.8054167642140487420), RealType(1.7900469825946189862), RealType(1.7748343955807692457),
+ RealType(1.7597702248942318749), RealType(1.7448461281083765085), RealType(1.7300541605582435350), RealType(1.7153867407081165482),
+ RealType(1.7008366185643009437), RealType(1.6863968467734863258), RealType(1.6720607540918522072), RealType(1.6578219209482075462),
+ RealType(1.6436741568569826489), RealType(1.6296114794646783962), RealType(1.6156280950371329644), RealType(1.6017183802152770587),
+ RealType(1.5878768648844007019), RealType(1.5740982160167497219), RealType(1.5603772223598406870), RealType(1.5467087798535034608),
+ RealType(1.5330878776675560787), RealType(1.5195095847593707806), RealType(1.5059690368565502602), RealType(1.4924614237746154081),
+ RealType(1.4789819769830978546), RealType(1.4655259573357946276), RealType(1.4520886428822164926), RealType(1.4386653166774613138),
+ RealType(1.4252512545068615734), RealType(1.4118417124397602509), RealType(1.3984319141236063517), RealType(1.3850170377251486449),
+ RealType(1.3715922024197322698), RealType(1.3581524543224228739), RealType(1.3446927517457130432), RealType(1.3312079496576765017),
+ RealType(1.3176927832013429910), RealType(1.3041418501204215390), RealType(1.2905495919178731508), RealType(1.2769102735516997175),
+ RealType(1.2632179614460282310), RealType(1.2494664995643337480), RealType(1.2356494832544811749), RealType(1.2217602305309625678),
+ RealType(1.2077917504067576028), RealType(1.1937367078237721994), RealType(1.1795873846544607035), RealType(1.1653356361550469083),
+ RealType(1.1509728421389760651), RealType(1.1364898520030755352), RealType(1.1218769225722540661), RealType(1.1071236475235353980),
+ RealType(1.0922188768965537614), RealType(1.0771506248819376573), RealType(1.0619059636836193998), RealType(1.0464709007525802629),
+ RealType(1.0308302360564555907), RealType(1.0149673952392994716), RealType(0.99886423348064351303), RealType(0.98250080350276038481),
+ RealType(0.96585507938813059489), RealType(0.94890262549791195381), RealType(0.93161619660135381056), RealType(0.91396525100880177644),
+ RealType(0.89591535256623852894), RealType(0.87742742909771569142), RealType(0.85845684317805086354), RealType(0.83895221428120745572),
+ RealType(0.81885390668331772331), RealType(0.79809206062627480454), RealType(0.77658398787614838598), RealType(0.75423066443451007146),
+ RealType(0.73091191062188128150), RealType(0.70647961131360803456), RealType(0.68074791864590421664), RealType(0.65347863871504238702),
+ RealType(0.62435859730908822111), RealType(0.59296294244197797913), RealType(0.55869217837551797140), RealType(0.52065603872514491759),
+ RealType(0.47743783725378787681), RealType(0.42654798630330512490), RealType(0.36287143102841830424), RealType(0.27232086470466385065),
+ RealType(0)
};
template<class RealType>
const RealType normal_table<RealType>::table_y[129] = {
- 0, 0.0026696290839025035092, 0.0055489952208164705392, 0.0086244844129304709682,
- 0.011839478657982313715, 0.015167298010672042468, 0.018592102737165812650, 0.022103304616111592615,
- 0.025693291936149616572, 0.029356317440253829618, 0.033087886146505155566, 0.036884388786968774128,
- 0.040742868074790604632, 0.044660862200872429800, 0.048636295860284051878, 0.052667401903503169793,
- 0.056752663481538584188, 0.060890770348566375972, 0.065080585213631873753, 0.069321117394180252601,
- 0.073611501884754893389, 0.077950982514654714188, 0.082338898242957408243, 0.086774671895542968998,
- 0.091257800827634710201, 0.09578784912257815216, 0.10036444102954554013, 0.10498725541035453978,
- 0.10965602101581776100, 0.11437051244988827452, 0.11913054670871858767, 0.12393598020398174246,
- 0.12878670619710396109, 0.13368265258464764118, 0.13862377998585103702, 0.14361008009193299469,
- 0.14864157424369696566, 0.15371831220958657066, 0.15884037114093507813, 0.16400785468492774791,
- 0.16922089223892475176, 0.17447963833240232295, 0.17978427212496211424, 0.18513499701071343216,
- 0.19053204032091372112, 0.19597565311811041399, 0.20146611007620324118, 0.20700370944187380064,
- 0.21258877307373610060, 0.21822164655637059599, 0.22390269938713388747, 0.22963232523430270355,
- 0.23541094226572765600, 0.24123899354775131610, 0.24711694751469673582, 0.25304529850976585934,
- 0.25902456739871074263, 0.26505530225816194029, 0.27113807914102527343, 0.27727350292189771153,
- 0.28346220822601251779, 0.28970486044581049771, 0.29600215684985583659, 0.30235482778947976274,
- 0.30876363800925192282, 0.31522938806815752222, 0.32175291587920862031, 0.32833509837615239609,
- 0.33497685331697116147, 0.34167914123501368412, 0.34844296754987246935, 0.35526938485154714435,
- 0.36215949537303321162, 0.36911445366827513952, 0.37613546951445442947, 0.38322381105988364587,
- 0.39038080824138948916, 0.39760785649804255208, 0.40490642081148835099, 0.41227804010702462062,
- 0.41972433205403823467, 0.42724699830956239880, 0.43484783025466189638, 0.44252871528024661483,
- 0.45029164368692696086, 0.45813871627287196483, 0.46607215269457097924, 0.47409430069824960453,
- 0.48220764633483869062, 0.49041482528932163741, 0.49871863547658432422, 0.50712205108130458951,
- 0.51562823824987205196, 0.52424057267899279809, 0.53296265938998758838, 0.54179835503172412311,
- 0.55075179312105527738, 0.55982741271069481791, 0.56902999107472161225, 0.57836468112670231279,
- 0.58783705444182052571, 0.59745315095181228217, 0.60721953663260488551, 0.61714337082656248870,
- 0.62723248525781456578, 0.63749547734314487428, 0.64794182111855080873, 0.65858200005865368016,
- 0.66942766735770616891, 0.68049184100641433355, 0.69178914344603585279, 0.70333609902581741633,
- 0.71515150742047704368, 0.72725691835450587793, 0.73967724368333814856, 0.75244155918570380145,
- 0.76558417390923599480, 0.77914608594170316563, 0.79317701178385921053, 0.80773829469612111340,
- 0.82290721139526200050, 0.83878360531064722379, 0.85550060788506428418, 0.87324304892685358879,
- 0.89228165080230272301, 0.91304364799203805999, 0.93628268170837107547, 0.96359969315576759960,
- 1
+ RealType(0), RealType(0.0026696290839025035092), RealType(0.0055489952208164705392), RealType(0.0086244844129304709682),
+ RealType(0.011839478657982313715), RealType(0.015167298010672042468), RealType(0.018592102737165812650), RealType(0.022103304616111592615),
+ RealType(0.025693291936149616572), RealType(0.029356317440253829618), RealType(0.033087886146505155566), RealType(0.036884388786968774128),
+ RealType(0.040742868074790604632), RealType(0.044660862200872429800), RealType(0.048636295860284051878), RealType(0.052667401903503169793),
+ RealType(0.056752663481538584188), RealType(0.060890770348566375972), RealType(0.065080585213631873753), RealType(0.069321117394180252601),
+ RealType(0.073611501884754893389), RealType(0.077950982514654714188), RealType(0.082338898242957408243), RealType(0.086774671895542968998),
+ RealType(0.091257800827634710201), RealType(0.09578784912257815216), RealType(0.10036444102954554013), RealType(0.10498725541035453978),
+ RealType(0.10965602101581776100), RealType(0.11437051244988827452), RealType(0.11913054670871858767), RealType(0.12393598020398174246),
+ RealType(0.12878670619710396109), RealType(0.13368265258464764118), RealType(0.13862377998585103702), RealType(0.14361008009193299469),
+ RealType(0.14864157424369696566), RealType(0.15371831220958657066), RealType(0.15884037114093507813), RealType(0.16400785468492774791),
+ RealType(0.16922089223892475176), RealType(0.17447963833240232295), RealType(0.17978427212496211424), RealType(0.18513499701071343216),
+ RealType(0.19053204032091372112), RealType(0.19597565311811041399), RealType(0.20146611007620324118), RealType(0.20700370944187380064),
+ RealType(0.21258877307373610060), RealType(0.21822164655637059599), RealType(0.22390269938713388747), RealType(0.22963232523430270355),
+ RealType(0.23541094226572765600), RealType(0.24123899354775131610), RealType(0.24711694751469673582), RealType(0.25304529850976585934),
+ RealType(0.25902456739871074263), RealType(0.26505530225816194029), RealType(0.27113807914102527343), RealType(0.27727350292189771153),
+ RealType(0.28346220822601251779), RealType(0.28970486044581049771), RealType(0.29600215684985583659), RealType(0.30235482778947976274),
+ RealType(0.30876363800925192282), RealType(0.31522938806815752222), RealType(0.32175291587920862031), RealType(0.32833509837615239609),
+ RealType(0.33497685331697116147), RealType(0.34167914123501368412), RealType(0.34844296754987246935), RealType(0.35526938485154714435),
+ RealType(0.36215949537303321162), RealType(0.36911445366827513952), RealType(0.37613546951445442947), RealType(0.38322381105988364587),
+ RealType(0.39038080824138948916), RealType(0.39760785649804255208), RealType(0.40490642081148835099), RealType(0.41227804010702462062),
+ RealType(0.41972433205403823467), RealType(0.42724699830956239880), RealType(0.43484783025466189638), RealType(0.44252871528024661483),
+ RealType(0.45029164368692696086), RealType(0.45813871627287196483), RealType(0.46607215269457097924), RealType(0.47409430069824960453),
+ RealType(0.48220764633483869062), RealType(0.49041482528932163741), RealType(0.49871863547658432422), RealType(0.50712205108130458951),
+ RealType(0.51562823824987205196), RealType(0.52424057267899279809), RealType(0.53296265938998758838), RealType(0.54179835503172412311),
+ RealType(0.55075179312105527738), RealType(0.55982741271069481791), RealType(0.56902999107472161225), RealType(0.57836468112670231279),
+ RealType(0.58783705444182052571), RealType(0.59745315095181228217), RealType(0.60721953663260488551), RealType(0.61714337082656248870),
+ RealType(0.62723248525781456578), RealType(0.63749547734314487428), RealType(0.64794182111855080873), RealType(0.65858200005865368016),
+ RealType(0.66942766735770616891), RealType(0.68049184100641433355), RealType(0.69178914344603585279), RealType(0.70333609902581741633),
+ RealType(0.71515150742047704368), RealType(0.72725691835450587793), RealType(0.73967724368333814856), RealType(0.75244155918570380145),
+ RealType(0.76558417390923599480), RealType(0.77914608594170316563), RealType(0.79317701178385921053), RealType(0.80773829469612111340),
+ RealType(0.82290721139526200050), RealType(0.83878360531064722379), RealType(0.85550060788506428418), RealType(0.87324304892685358879),
+ RealType(0.89228165080230272301), RealType(0.91304364799203805999), RealType(0.93628268170837107547), RealType(0.96359969315576759960),
+ RealType(1)
};
template<class Engine>
@@ -126,7 +126,7 @@
{
typedef typename Engine::result_type base_result;
typedef typename boost::make_unsigned<base_result>::type base_unsigned;
-
+
base_unsigned range =
detail::subtract<base_result>()((eng.max)(), (eng.min)());
base_unsigned y0_mask = (base_unsigned(2) << (bits - 1)) - 1;
@@ -143,15 +143,15 @@
{
typedef typename Engine::result_type base_result;
typedef typename boost::make_unsigned<base_result>::type base_unsigned;
-
+
base_unsigned range =
detail::subtract<base_result>()((eng.max)(), (eng.min)());
-
+
std::size_t m =
(range == (std::numeric_limits<base_unsigned>::max)()) ?
std::numeric_limits<base_unsigned>::digits :
detail::integer_log2(range + 1);
-
+
int bucket = 0;
// process as many full digits as possible into the int part
for(std::size_t i = 0; i < w/m; ++i) {
@@ -230,7 +230,7 @@
template<class Engine>
RealType generate_tail(Engine& eng) {
boost::random::exponential_distribution<RealType> exponential;
- const RealType tail_start(normal_table<double>::table_x[1]);
+ const RealType tail_start(normal_table<RealType>::table_x[1]);
for(;;) {
RealType x = exponential(eng)/tail_start;
RealType y = exponential(eng);
@@ -292,7 +292,7 @@
/** Returns true if the two sets of parameters are the same. */
BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(param_type, lhs, rhs)
{ return lhs._mean == rhs._mean && lhs._sigma == rhs._sigma; }
-
+
/** Returns true if the two sets of parameters are the different. */
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(param_type)
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk