1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
3 /* { dg-additional-options "-Wno-return-type" } */
7 template < class _T1, class _T2 > struct pair
15 typedef int int32_t __attribute__ ((__mode__ (__SI__)));
16 struct _pthread_fastlock
24 struct __numeric_limits_base
27 template < typename _Tp >
28 struct numeric_limits:public __numeric_limits_base
30 static const bool is_integer = true;
33 typedef unsigned int uint32_t;
36 template < typename _Alloc > class allocator;
37 template < class _CharT > struct char_traits;
38 template < typename _CharT, typename _Traits =
39 char_traits < _CharT >, typename _Alloc =
40 allocator < _CharT > >class basic_string;
41 typedef basic_string < char >string;
45 template < typename _Tp > class new_allocator
51 template < typename _Tp > class allocator:public __gnu_cxx::new_allocator <
55 template < typename _CharT, typename _Traits,
56 typename _Alloc > class basic_string
58 public:inline basic_string ();
59 basic_string (const _CharT * __s, const _Alloc & __a = _Alloc ());
64 template < class T > class integer_traits:public std::numeric_limits < T >
69 template < class T, T min_val, T max_val > class integer_traits_base
73 template <> class integer_traits < int >:public std::numeric_limits < int >,
74 public detail::integer_traits_base < int, (-2147483647 - 1), 2147483647 >
79 template < class IntType, IntType m > class const_mod
81 public:static IntType add (IntType x, IntType c)
84 static IntType mult (IntType a, IntType x)
86 return mult_schrage (a, x);
88 static IntType mult_add (IntType a, IntType x, IntType c)
90 return add (mult (a, x), c);
92 static IntType mult_schrage (IntType a, IntType value)
102 template < class IntType, IntType a, IntType c, IntType m,
103 IntType val > class linear_congruential
105 public:typedef IntType result_type;
106 static const IntType modulus = m;
107 explicit linear_congruential (IntType x0 = 1):_modulus (modulus),
108 _x (_modulus ? (x0 % _modulus) :
112 IntType operator () ()
114 _x = const_mod < IntType, m >::mult_add (a, _x, c);
116 private:IntType _modulus;
120 typedef random::linear_congruential < int32_t, 16807, 0, 2147483647,
121 1043618065 > minstd_rand0;
126 template < class T > struct ptr_helper
128 typedef T value_type;
129 typedef T & reference_type;
130 typedef const T & rvalue_type;
131 static reference_type ref (T & r)
135 template < class T > struct ptr_helper <T & >
137 typedef T value_type;
138 typedef T & rvalue_type;
142 template < class UniformRandomNumberGenerator, class RealType =
143 double >class uniform_01
145 public:typedef UniformRandomNumberGenerator base_type;
146 typedef RealType result_type;
147 explicit uniform_01 (base_type rng):_rng (rng),
148 _factor (result_type (1) /
149 (result_type ((_rng.max) () - (_rng.min) ()) +
150 result_type (std::numeric_limits <
151 base_result >::is_integer ? 1 : 0)))
154 result_type operator () ()
156 return result_type (_rng () - (_rng.min) ()) * _factor;
158 private:typedef typename base_type::result_type base_result;
166 template < class UniformRandomNumberGenerator >
167 class pass_through_engine
169 private:typedef ptr_helper < UniformRandomNumberGenerator >
171 public:typedef typename helper_type::value_type base_type;
172 typedef typename base_type::result_type result_type;
173 explicit pass_through_engine (UniformRandomNumberGenerator
174 rng):_rng (static_cast <
175 typename helper_type::
179 result_type min () const
182 result_type max () const
188 result_type operator () ()
192 private:UniformRandomNumberGenerator _rng;
195 template < class RealType, int w, unsigned int p,
196 unsigned int q > class lagged_fibonacci_01
198 public:typedef RealType result_type;
199 static const unsigned int long_lag = p;
200 lagged_fibonacci_01 ()
204 public:void seed (uint32_t value = 331u)
206 minstd_rand0 intgen (value);
209 template < class Generator > void seed (Generator & gen)
211 typedef detail::pass_through_engine < Generator & >ref_gen;
212 uniform_01 < ref_gen, RealType > gen01 =
213 uniform_01 < ref_gen, RealType > (ref_gen (gen));
214 for (unsigned int j = 0; j < long_lag; ++j)
217 RealType x[long_lag];
220 typedef random::lagged_fibonacci_01 < double, 48, 607,
221 273 > lagged_fibonacci607;
226 template < bool have_int, bool want_int > struct engine_helper;
227 template <> struct engine_helper <true, true >
229 template < class Engine, class DistInputType > struct impl
231 typedef pass_through_engine < Engine > type;
236 template < class Engine, class Distribution > class variate_generator
238 private:typedef random::detail::pass_through_engine < Engine >
240 public:typedef typename decorated_engine::base_type engine_value_type;
241 typedef Distribution distribution_type;
242 variate_generator (Engine e, Distribution d):_eng (decorated_engine (e)),
249 std::numeric_limits <
250 typename decorated_engine::result_type >::is_integer, want_int =
251 std::numeric_limits < typename Distribution::input_type >::is_integer
253 typedef typename random::detail::engine_helper < have_int,
254 want_int >::template impl < decorated_engine,
255 typename Distribution::input_type >::type internal_engine_type;
256 internal_engine_type _eng;
257 distribution_type _dist;
259 template < class RealType = double >class uniform_real
261 public:typedef RealType input_type;
266 class BufferedRandomNumberGeneratorBase
269 template < class RNG >
270 class BufferedRandomNumberGenerator:public
271 BufferedRandomNumberGeneratorBase
273 public: BufferedRandomNumberGenerator ():rng_ (), gen_ (rng_,
279 boost::variate_generator < RNG &, boost::uniform_real <> >gen_;
286 class sp_counted_base
291 private:sp_counted_base * pi_;
292 public:shared_count ():pi_ (0)
295 template < class Y > explicit shared_count (Y * p):pi_ (0)
300 template < class T > class shared_ptr
302 public:typedef T element_type;
303 template < class Y > explicit shared_ptr (Y * p):px (p), pn (p)
307 detail::shared_count pn;
312 template < typename _Key, typename _Tp, typename _Compare =
313 std::allocator < std::pair < const _Key, _Tp > > > class map
315 public:typedef _Key key_type;
316 typedef _Tp mapped_type;
317 mapped_type & operator[] (const key_type & __k)
326 template < class BASE > class abstract_creator
328 public:typedef BASE base_type;
329 virtual base_type *create () const = 0;
331 template < class BASE,
332 class T > class creator:public abstract_creator < BASE >
334 public:typedef BASE base_type;
335 base_type *create () const
341 template < class KEY, class BASE > class factory
343 public:typedef BASE base_type;
344 typedef KEY key_type;
345 typedef boost::shared_ptr < detail::abstract_creator < base_type >
347 template < class T > bool register_type (key_type k)
349 creators_[k] = pointer_type (new detail::creator < BASE, T > ());
351 private:typedef std::map < key_type, pointer_type > map_type;
354 class RNGFactory:public factory < std::string,
355 BufferedRandomNumberGeneratorBase >
357 public:RNGFactory ();
360 alps::RNGFactory::RNGFactory ()
362 register_type < BufferedRandomNumberGenerator < boost::lagged_fibonacci607 >
363 >("lagged_fibonacci607");