This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
The discard member function of the mersenne_twister_engine class is unnecessarily inefficient. It currently discard elements one-by-one. It is possible to discard with higher granularity by discarding the entire internal buffer. The attached patch implements this. To avoid duplication a new internal member function is introduced which generates a new set of bits for the internal buffer. The operator() is changed to use it. 2012-08-22 Ulrich Drepper <drepper@gmail.com> * include/bits/random.h (mersenne_twister_engine): Don't inline discard here. New member function _M_gen_rand. * include/bits/random.tcc (mersenne_twister_engine<>::_M_gen_rand): New function. Extracted from operator(). (mersenne_twister_engine<>::discard): New implementation which skips in large steps. (mersenne_twister_engine<>::operator()): Use _M_gen_rand.
Attachment:
d-mersenne-discard
Description: Binary data
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |