random.tcc (__transform): Remove.

2013-02-12  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/bits/random.tcc (__transform): Remove.
	(__normalize): Add.
	(discrete_distribution<>::param_type::_M_initialize): Adjust.
	(piecewise_constant_distribution<>::param_type::_M_initialize):
	Likewise.
	(piecewise_linear_distribution<>::param_type::_M_initialize):
	Likewise.

From-SVN: r195970
This commit is contained in:
Paolo Carlini 2013-02-12 10:26:54 +00:00 committed by Paolo Carlini
parent f80e0faf19
commit 60f3a59f29
2 changed files with 23 additions and 14 deletions

View File

@ -1,3 +1,13 @@
2013-02-12 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/random.tcc (__transform): Remove.
(__normalize): Add.
(discrete_distribution<>::param_type::_M_initialize): Adjust.
(piecewise_constant_distribution<>::param_type::_M_initialize):
Likewise.
(piecewise_linear_distribution<>::param_type::_M_initialize):
Likewise.
2013-02-11 Benjamin Kosnik <bkoz@redhat.com> 2013-02-11 Benjamin Kosnik <bkoz@redhat.com>
* src/c++11/Makefile.am (hashtable_c++0x.lo, hashtable_c++0x.o): * src/c++11/Makefile.am (hashtable_c++0x.lo, hashtable_c++0x.o):

View File

@ -79,13 +79,13 @@ namespace std _GLIBCXX_VISIBILITY(default)
} }
template<typename _InputIterator, typename _OutputIterator, template<typename _InputIterator, typename _OutputIterator,
typename _UnaryOperation> typename _Tp>
_OutputIterator _OutputIterator
__transform(_InputIterator __first, _InputIterator __last, __normalize(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _UnaryOperation __unary_op) _OutputIterator __result, const _Tp& __factor)
{ {
for (; __first != __last; ++__first, ++__result) for (; __first != __last; ++__first, ++__result)
*__result = __unary_op(*__first); *__result = *__first / __factor;
return __result; return __result;
} }
@ -2802,8 +2802,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const double __sum = std::accumulate(_M_prob.begin(), const double __sum = std::accumulate(_M_prob.begin(),
_M_prob.end(), 0.0); _M_prob.end(), 0.0);
// Now normalize the probabilites. // Now normalize the probabilites.
__detail::__transform(_M_prob.begin(), _M_prob.end(), _M_prob.begin(), __detail::__normalize(_M_prob.begin(), _M_prob.end(), _M_prob.begin(),
std::bind2nd(std::divides<double>(), __sum)); __sum);
// Accumulate partial sums. // Accumulate partial sums.
_M_cp.reserve(_M_prob.size()); _M_cp.reserve(_M_prob.size());
std::partial_sum(_M_prob.begin(), _M_prob.end(), std::partial_sum(_M_prob.begin(), _M_prob.end(),
@ -2955,8 +2955,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const double __sum = std::accumulate(_M_den.begin(), const double __sum = std::accumulate(_M_den.begin(),
_M_den.end(), 0.0); _M_den.end(), 0.0);
__detail::__transform(_M_den.begin(), _M_den.end(), _M_den.begin(), __detail::__normalize(_M_den.begin(), _M_den.end(), _M_den.begin(),
std::bind2nd(std::divides<double>(), __sum)); __sum);
_M_cp.reserve(_M_den.size()); _M_cp.reserve(_M_den.size());
std::partial_sum(_M_den.begin(), _M_den.end(), std::partial_sum(_M_den.begin(), _M_den.end(),
@ -3189,14 +3189,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} }
// Now normalize the densities... // Now normalize the densities...
__detail::__transform(_M_den.begin(), _M_den.end(), _M_den.begin(), __detail::__normalize(_M_den.begin(), _M_den.end(), _M_den.begin(),
std::bind2nd(std::divides<double>(), __sum)); __sum);
// ... and partial sums... // ... and partial sums...
__detail::__transform(_M_cp.begin(), _M_cp.end(), _M_cp.begin(), __detail::__normalize(_M_cp.begin(), _M_cp.end(), _M_cp.begin(), __sum);
std::bind2nd(std::divides<double>(), __sum));
// ... and slopes. // ... and slopes.
__detail::__transform(_M_m.begin(), _M_m.end(), _M_m.begin(), __detail::__normalize(_M_m.begin(), _M_m.end(), _M_m.begin(), __sum);
std::bind2nd(std::divides<double>(), __sum));
// Make sure the last cumulative probablility is one. // Make sure the last cumulative probablility is one.
_M_cp[_M_cp.size() - 1] = 1.0; _M_cp[_M_cp.size() - 1] = 1.0;
} }