|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r63276 - in trunk: boost/random libs/random/test
From: steven_at_[hidden]
Date: 2010-06-23 20:44:29
Author: steven_watanabe
Date: 2010-06-23 20:44:28 EDT (Wed, 23 Jun 2010)
New Revision: 63276
URL: http://svn.boost.org/trac/boost/changeset/63276
Log:
A few more fixes for msvc-7.1
Text files modified:
trunk/boost/random/discrete_distribution.hpp | 86 ++++++++++++++++++++++-----------------
trunk/libs/random/test/statistic_tests.hpp | 6 +
2 files changed, 52 insertions(+), 40 deletions(-)
Modified: trunk/boost/random/discrete_distribution.hpp
==============================================================================
--- trunk/boost/random/discrete_distribution.hpp (original)
+++ trunk/boost/random/discrete_distribution.hpp 2010-06-23 20:44:28 EDT (Wed, 23 Jun 2010)
@@ -119,19 +119,7 @@
operator<<(std::basic_ostream<CharT, Traits>& os,
const param_type& parm)
{
- typename std::vector<WeightType>::const_iterator
- iter = parm._probabilities.begin(),
- end = parm._probabilities.end();
- os << '[';
- if(iter != end) {
- os << *iter;
- ++iter;
- for(; iter != end; ++iter)
- {
- os << ' ' << *iter;
- }
- }
- os << ']';
+ parm.print(os);
return os;
}
@@ -140,31 +128,7 @@
friend std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, param_type& parm)
{
- std::vector<WeightType> result;
- char ch;
- if(!(is >> ch)) {
- return is;
- }
- if(ch != '[') {
- is.putback(ch);
- is.setstate(std::ios_base::failbit);
- return is;
- }
- WeightType val;
- while(is >> std::ws >> val) {
- result.push_back(val);
- }
- if(is.fail()) {
- is.clear();
- if(!(is >> ch)) {
- return is;
- }
- if(ch != ']') {
- is.putback(ch);
- is.setstate(std::ios_base::failbit);
- }
- }
- parm._probabilities.swap(result);
+ parm.read(is);
return is;
}
#endif
@@ -198,6 +162,52 @@
*iter /= sum;
}
}
+ template<class CharT, class Traits>
+ void print(std::basic_ostream<CharT, Traits>& os) const
+ {
+ typename std::vector<WeightType>::const_iterator
+ iter = _probabilities.begin(),
+ end = _probabilities.end();
+ os << '[';
+ if(iter != end) {
+ os << *iter;
+ ++iter;
+ for(; iter != end; ++iter)
+ {
+ os << ' ' << *iter;
+ }
+ }
+ os << ']';
+ }
+ template<class CharT, class Traits>
+ void read(std::basic_istream<CharT, Traits>& is)
+ {
+ std::vector<WeightType> result;
+ char ch;
+ if(!(is >> ch)) {
+ return;
+ }
+ if(ch != '[') {
+ is.putback(ch);
+ is.setstate(std::ios_base::failbit);
+ return;
+ }
+ WeightType val;
+ while(is >> std::ws >> val) {
+ result.push_back(val);
+ }
+ if(is.fail()) {
+ is.clear();
+ if(!(is >> ch)) {
+ return;
+ }
+ if(ch != ']') {
+ is.putback(ch);
+ is.setstate(std::ios_base::failbit);
+ }
+ }
+ _probabilities.swap(result);
+ }
std::vector<WeightType> _probabilities;
/// @endcond
};
Modified: trunk/libs/random/test/statistic_tests.hpp
==============================================================================
--- trunk/libs/random/test/statistic_tests.hpp (original)
+++ trunk/libs/random/test/statistic_tests.hpp 2010-06-23 20:44:28 EDT (Wed, 23 Jun 2010)
@@ -344,10 +344,12 @@
double probability(unsigned int r) const
{
if(r == classes()-1)
- return 1-fac<double>(d)/std::pow(d, static_cast<double>(d+classes()-2))*
+ return 1-fac<double>(d)/
+ std::pow(static_cast<double>(d), static_cast<double>(d+classes()-2)) *
stirling2<double>(d+classes()-2, d);
else
- return fac<double>(d)/std::pow(d, static_cast<double>(d+r)) *
+ return fac<double>(d)/
+ std::pow(static_cast<double>(d), static_cast<double>(d+r)) *
stirling2<double>(d+r-1, d-1);
}
private:
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