From edca01478532ed72b45326fcc51bcbaa49fa227e Mon Sep 17 00:00:00 2001 From: Olivier Parcollet Date: Wed, 2 Apr 2014 20:36:54 +0200 Subject: [PATCH] rng : preview --- triqs/mc_tools/generator.hpp | 8 +++++++- triqs/mc_tools/random_generator.hpp | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/triqs/mc_tools/generator.hpp b/triqs/mc_tools/generator.hpp index 7b076139..6e29c38d 100644 --- a/triqs/mc_tools/generator.hpp +++ b/triqs/mc_tools/generator.hpp @@ -33,7 +33,13 @@ namespace boost{ buf->fill(); return *cur++; } - generator(generator const & rhs) + inline R const preview() { + if (cur == end) + buf->fill(); + return *cur; + } + + generator(generator const & rhs) : buf(new buffer (*rhs.buf)) , cur(buf->cur) diff --git a/triqs/mc_tools/random_generator.hpp b/triqs/mc_tools/random_generator.hpp index 79107f13..f3c75557 100644 --- a/triqs/mc_tools/random_generator.hpp +++ b/triqs/mc_tools/random_generator.hpp @@ -59,6 +59,9 @@ namespace mc_tools { INTEGER_OVERLOAD(size_t) #undef INTEGER_OVERLOAD + /// Returns a double in [0,1[ with flat distribution + double preview() { return gen->preview();} + /// Returns a double in [0,1[ with flat distribution double operator()() { return ((*gen)());}