1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
6 template < class _T1, class _T2 > struct pair
14 typedef int int32_t __attribute__ ((__mode__ (__SI__)));
15 struct _pthread_fastlock
23 struct __numeric_limits_base
26 template < typename _Tp >
27 struct numeric_limits:public __numeric_limits_base
29 static const bool is_integer = true;
32 typedef unsigned int uint32_t;
35 template < typename _Alloc > class allocator;
36 template < class _CharT > struct char_traits;
37 template < typename _CharT, typename _Traits =
38 char_traits < _CharT >, typename _Alloc =
39 allocator < _CharT > >class basic_string;
40 typedef basic_string < char >string;
44 template < typename _Tp > class new_allocator
50 template < typename _Tp > class allocator:public __gnu_cxx::new_allocator <
54 template < typename _CharT, typename _Traits,
55 typename _Alloc > class basic_string
57 public:inline basic_string ();
58 basic_string (const _CharT * __s, const _Alloc & __a = _Alloc ());
63 template < class T > class integer_traits:public std::numeric_limits < T >
68 template < class T, T min_val, T max_val > class integer_traits_base
72 template <> class integer_traits < int >:public std::numeric_limits < int >,
73 public detail::integer_traits_base < int, (-2147483647 - 1), 2147483647 >
78 template < class IntType, IntType m > class const_mod
80 public:static IntType add (IntType x, IntType c)
83 static IntType mult (IntType a, IntType x)
85 return mult_schrage (a, x);
87 static IntType mult_add (IntType a, IntType x, IntType c)
89 return add (mult (a, x), c);
91 static IntType mult_schrage (IntType a, IntType value)
101 template < class IntType, IntType a, IntType c, IntType m,
102 IntType val > class linear_congruential
104 public:typedef IntType result_type;
105 static const IntType modulus = m;
106 explicit linear_congruential (IntType x0 = 1):_modulus (modulus),
107 _x (_modulus ? (x0 % _modulus) :
111 IntType operator () ()
113 _x = const_mod < IntType, m >::mult_add (a, _x, c);
115 private:IntType _modulus;
119 typedef random::linear_congruential < int32_t, 16807, 0, 2147483647,
120 1043618065 > minstd_rand0;
125 template < class T > struct ptr_helper
127 typedef T value_type;
128 typedef T & reference_type;
129 typedef const T & rvalue_type;
130 static reference_type ref (T & r)
134 template < class T > struct ptr_helper <T & >
136 typedef T value_type;
137 typedef T & rvalue_type;
141 template < class UniformRandomNumberGenerator, class RealType =
142 double >class uniform_01
144 public:typedef UniformRandomNumberGenerator base_type;
145 typedef RealType result_type;
146 explicit uniform_01 (base_type rng):_rng (rng),
147 _factor (result_type (1) /
148 (result_type ((_rng.max) () - (_rng.min) ()) +
149 result_type (std::numeric_limits <
150 base_result >::is_integer ? 1 : 0)))
153 result_type operator () ()
155 return result_type (_rng () - (_rng.min) ()) * _factor;
157 private:typedef typename base_type::result_type base_result;
165 template < class UniformRandomNumberGenerator >
166 class pass_through_engine
168 private:typedef ptr_helper < UniformRandomNumberGenerator >
170 public:typedef typename helper_type::value_type base_type;
171 typedef typename base_type::result_type result_type;
172 explicit pass_through_engine (UniformRandomNumberGenerator
173 rng):_rng (static_cast <
174 typename helper_type::
178 result_type min () const
181 result_type max () const
187 result_type operator () ()
191 private:UniformRandomNumberGenerator _rng;
194 template < class RealType, int w, unsigned int p,
195 unsigned int q > class lagged_fibonacci_01
197 public:typedef RealType result_type;
198 static const unsigned int long_lag = p;
199 lagged_fibonacci_01 ()
203 public:void seed (uint32_t value = 331u)
205 minstd_rand0 intgen (value);
208 template < class Generator > void seed (Generator & gen)
210 typedef detail::pass_through_engine < Generator & >ref_gen;
211 uniform_01 < ref_gen, RealType > gen01 =
212 uniform_01 < ref_gen, RealType > (ref_gen (gen));
213 for (unsigned int j = 0; j < long_lag; ++j)
216 RealType x[long_lag];
219 typedef random::lagged_fibonacci_01 < double, 48, 607,
220 273 > lagged_fibonacci607;
225 template < bool have_int, bool want_int > struct engine_helper;
226 template <> struct engine_helper <true, true >
228 template < class Engine, class DistInputType > struct impl
230 typedef pass_through_engine < Engine > type;
235 template < class Engine, class Distribution > class variate_generator
237 private:typedef random::detail::pass_through_engine < Engine >
239 public:typedef typename decorated_engine::base_type engine_value_type;
240 typedef Distribution distribution_type;
241 variate_generator (Engine e, Distribution d):_eng (decorated_engine (e)),
248 std::numeric_limits <
249 typename decorated_engine::result_type >::is_integer, want_int =
250 std::numeric_limits < typename Distribution::input_type >::is_integer
252 typedef typename random::detail::engine_helper < have_int,
253 want_int >::template impl < decorated_engine,
254 typename Distribution::input_type >::type internal_engine_type;
255 internal_engine_type _eng;
256 distribution_type _dist;
258 template < class RealType = double >class uniform_real
260 public:typedef RealType input_type;
265 class BufferedRandomNumberGeneratorBase
268 template < class RNG >
269 class BufferedRandomNumberGenerator:public
270 BufferedRandomNumberGeneratorBase
272 public: BufferedRandomNumberGenerator ():rng_ (), gen_ (rng_,
278 boost::variate_generator < RNG &, boost::uniform_real <> >gen_;
285 class sp_counted_base
290 private:sp_counted_base * pi_;
291 public:shared_count ():pi_ (0)
294 template < class Y > explicit shared_count (Y * p):pi_ (0)
299 template < class T > class shared_ptr
301 public:typedef T element_type;
302 template < class Y > explicit shared_ptr (Y * p):px (p), pn (p)
306 detail::shared_count pn;
311 template < typename _Key, typename _Tp, typename _Compare =
312 std::allocator < std::pair < const _Key, _Tp > > > class map
314 public:typedef _Key key_type;
315 typedef _Tp mapped_type;
316 mapped_type & operator[] (const key_type & __k)
325 template < class BASE > class abstract_creator
327 public:typedef BASE base_type;
328 virtual base_type *create () const = 0;
330 template < class BASE,
331 class T > class creator:public abstract_creator < BASE >
333 public:typedef BASE base_type;
334 base_type *create () const
340 template < class KEY, class BASE > class factory
342 public:typedef BASE base_type;
343 typedef KEY key_type;
344 typedef boost::shared_ptr < detail::abstract_creator < base_type >
346 template < class T > bool register_type (key_type k)
348 creators_[k] = pointer_type (new detail::creator < BASE, T > ());
350 private:typedef std::map < key_type, pointer_type > map_type;
353 class RNGFactory:public factory < std::string,
354 BufferedRandomNumberGeneratorBase >
356 public:RNGFactory ();
359 alps::RNGFactory::RNGFactory ()
361 register_type < BufferedRandomNumberGenerator < boost::lagged_fibonacci607 >
362 >("lagged_fibonacci607");