20 #include "detail/tbb/iterators.h" 21 #include "detail/Engine.hpp" 22 #include "detail/functors/EngineCaller.hpp" 27 typedef detail::philox philox;
29 typedef detail::threefry threefry;
31 typedef detail::squares3_128 squares3_128;
33 typedef detail::squares4_128 squares4_128;
35 typedef detail::squares3_64 squares3_64;
37 typedef detail::squares4_64 squares4_64;
39 #if RANDOM_ITERATOR_R123_USE_AES_NI 40 typedef detail::ars ars;
107 template <
typename DistibutionType,
typename EngineType>
109 typedef detail::EngineCaller<DistibutionType, EngineType> caller_type;
110 typedef random_iterator_tbb::counting_iterator<typename EngineType::advance_type>
114 typedef EngineType engine_type;
115 typedef typename engine_type::state_type state_type;
116 typedef typename engine_type::seed_type seed_type;
117 typedef typename engine_type::advance_type advance_type;
118 typedef typename engine_type::init_type init_type;
120 typedef DistibutionType distribution_type;
121 typedef typename distribution_type::result_type result_type;
123 typedef random_iterator_tbb::transform_iterator<caller_type, counting_iterator>
135 Stream(distribution_type
const& distribution, seed_type seed, uint32_t stream = 0)
136 : distribution_(distribution)
137 , engine_(seed, stream)
146 Stream(Stream<DistibutionType, EngineType>
const& other)
147 : distribution_(other.getDistribution())
148 , engine_(other.getEngine())
149 , seed_(other.getSeed())
150 , stream_(other.getStream()) {}
156 inline iterator begin()
const {
158 counting_iterator first(0);
159 caller_type caller(distribution_, seed_, stream_);
161 return iterator(first, caller);
168 inline iterator end()
const {
170 counting_iterator last(std::numeric_limits<advance_type>::max());
171 caller_type caller(distribution_, seed_, stream_);
173 return iterator(last, caller);
182 inline result_type operator[](advance_type n)
const {
184 caller_type caller(distribution_, seed_, stream_);
195 inline result_type operator()(
void) {
return distribution_(engine_); }
202 inline distribution_type getDistribution()
const {
return distribution_; }
209 inline void setDistribution(distribution_type dist) { distribution_ = dist; }
216 inline engine_type getEngine()
const {
return engine_; }
223 inline void setEngine(engine_type engine) { engine_ = engine; }
230 inline const seed_type& getSeed()
const {
return seed_; }
237 inline void setSeed(
const seed_type& seed) { seed_ = seed; }
244 inline uint32_t getStream()
const {
return stream_; }
251 inline void setStream(uint32_t stream) { stream_ = stream; }
254 std::ostream& os,
const Stream<DistibutionType, EngineType>& be) {
255 return os <<
"engine: " << be.getEngine() <<
" stream: " << be.getStream()
256 <<
" distribution: " << be.getDistribution();
260 distribution_type distribution_;
274 template <
typename DistibutionType,
typename EngineType>
275 Stream<DistibutionType, EngineType> make_stream(DistibutionType
const& dist,
276 EngineType eng, uint32_t stream) {
278 return Stream<DistibutionType, EngineType>(dist, eng.getSeed(), stream);
std::ostream & operator<<(std::ostream &, corsika::Code)
Code output operator.