Subject: Re: [boost] [random] new threefry random engine
From: Thijs van den Berg (thijs_at_[hidden])
Date: 2014-04-29 17:28:56
> now on github:
Ive also been working on a design and it will take another week before its good enough. It has similarities and differences (which is to be expected since we havent aligned). In short:
* a random_function concept which is a functor with operator()(input&,output&) or operator()(input&,output&,key&). Ive considered returning a container but I prefer this.
template <std::size_t InputSize>
// type info
void operator()(input_type& _i, output_type& _o)
_sha1.process_bytes(_i, input_traits::size );
boost::uuids::detail::sha1 _sha1; // I found this inside boost!
* the input output are random access containers with acompanying traits that allow other components to store and interface with these input output. The traits are element type, number of elements and number of bits used per element. E.g. a uint_least32_t v. Non of these container are stored inside the random function.
template <typename RandomFunction>
typedef ... value_type; // the type of the elements in the input container
typedef... type; // the input container type
static const std::size_t size = ...; // the number of elements in the input container
static const std::size_t bits = ...; // the number of bits used from each element in the input container
* a generic counter_engine that turns a random_function into a random_engine using a counter. It has a template argument random_function and it stores and manipular a counter of type random_function::input and/or random_function::key and extract random Uint;s from the output buffer.
sha1_random_function<64>, // do a sha1 hash on a 64 bytes input buffer (256 bit)
boost::uint_least32_t, // return type of the random engine
32, // 32 random bits in the return type elements
32 // 32 bit seed
* it doesnt need to end with a counter_engine, other types of random engines adapters that do input manipulators besides a counter can be added.
My focus is mainly the counter_engine adaptor (which is finished), the random_function concept and its containers+traits. I have unfortunately limited time right now but I will analyse our designs and come back with ideas and feedback.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk