/* { dg-do compile } */
|
/* { dg-do compile } */
|
/* { dg-options "-O2" } */
|
/* { dg-options "-O2" } */
|
|
|
namespace std
|
namespace std
|
{
|
{
|
template < class _T1, class _T2 > struct pair
|
template < class _T1, class _T2 > struct pair
|
{
|
{
|
};
|
};
|
}
|
}
|
extern "C"
|
extern "C"
|
{
|
{
|
extern "C"
|
extern "C"
|
{
|
{
|
typedef int int32_t __attribute__ ((__mode__ (__SI__)));
|
typedef int int32_t __attribute__ ((__mode__ (__SI__)));
|
struct _pthread_fastlock
|
struct _pthread_fastlock
|
{
|
{
|
}
|
}
|
pthread_mutexattr_t;
|
pthread_mutexattr_t;
|
}
|
}
|
}
|
}
|
namespace std
|
namespace std
|
{
|
{
|
struct __numeric_limits_base
|
struct __numeric_limits_base
|
{
|
{
|
};
|
};
|
template < typename _Tp >
|
template < typename _Tp >
|
struct numeric_limits:public __numeric_limits_base
|
struct numeric_limits:public __numeric_limits_base
|
{
|
{
|
static const bool is_integer = true;
|
static const bool is_integer = true;
|
};
|
};
|
};
|
};
|
typedef unsigned int uint32_t;
|
typedef unsigned int uint32_t;
|
namespace std
|
namespace std
|
{
|
{
|
template < typename _Alloc > class allocator;
|
template < typename _Alloc > class allocator;
|
template < class _CharT > struct char_traits;
|
template < class _CharT > struct char_traits;
|
template < typename _CharT, typename _Traits =
|
template < typename _CharT, typename _Traits =
|
char_traits < _CharT >, typename _Alloc =
|
char_traits < _CharT >, typename _Alloc =
|
allocator < _CharT > >class basic_string;
|
allocator < _CharT > >class basic_string;
|
typedef basic_string < char >string;
|
typedef basic_string < char >string;
|
}
|
}
|
namespace __gnu_cxx
|
namespace __gnu_cxx
|
{
|
{
|
template < typename _Tp > class new_allocator
|
template < typename _Tp > class new_allocator
|
{
|
{
|
};
|
};
|
}
|
}
|
namespace std
|
namespace std
|
{
|
{
|
template < typename _Tp > class allocator:public __gnu_cxx::new_allocator <
|
template < typename _Tp > class allocator:public __gnu_cxx::new_allocator <
|
_Tp >
|
_Tp >
|
{
|
{
|
};
|
};
|
template < typename _CharT, typename _Traits,
|
template < typename _CharT, typename _Traits,
|
typename _Alloc > class basic_string
|
typename _Alloc > class basic_string
|
{
|
{
|
public:inline basic_string ();
|
public:inline basic_string ();
|
basic_string (const _CharT * __s, const _Alloc & __a = _Alloc ());
|
basic_string (const _CharT * __s, const _Alloc & __a = _Alloc ());
|
};
|
};
|
}
|
}
|
namespace boost
|
namespace boost
|
{
|
{
|
template < class T > class integer_traits:public std::numeric_limits < T >
|
template < class T > class integer_traits:public std::numeric_limits < T >
|
{
|
{
|
};
|
};
|
namespace detail
|
namespace detail
|
{
|
{
|
template < class T, T min_val, T max_val > class integer_traits_base
|
template < class T, T min_val, T max_val > class integer_traits_base
|
{
|
{
|
};
|
};
|
}
|
}
|
template <> class integer_traits < int >:public std::numeric_limits < int >,
|
template <> class integer_traits < int >:public std::numeric_limits < int >,
|
public detail::integer_traits_base < int, (-2147483647 - 1), 2147483647 >
|
public detail::integer_traits_base < int, (-2147483647 - 1), 2147483647 >
|
{
|
{
|
};
|
};
|
namespace random
|
namespace random
|
{
|
{
|
template < class IntType, IntType m > class const_mod
|
template < class IntType, IntType m > class const_mod
|
{
|
{
|
public:static IntType add (IntType x, IntType c)
|
public:static IntType add (IntType x, IntType c)
|
{
|
{
|
}
|
}
|
static IntType mult (IntType a, IntType x)
|
static IntType mult (IntType a, IntType x)
|
{
|
{
|
return mult_schrage (a, x);
|
return mult_schrage (a, x);
|
}
|
}
|
static IntType mult_add (IntType a, IntType x, IntType c)
|
static IntType mult_add (IntType a, IntType x, IntType c)
|
{
|
{
|
return add (mult (a, x), c);
|
return add (mult (a, x), c);
|
}
|
}
|
static IntType mult_schrage (IntType a, IntType value)
|
static IntType mult_schrage (IntType a, IntType value)
|
{
|
{
|
for (;;)
|
for (;;)
|
{
|
{
|
if (value > 0)
|
if (value > 0)
|
break;
|
break;
|
value += m;
|
value += m;
|
}
|
}
|
}
|
}
|
};
|
};
|
template < class IntType, IntType a, IntType c, IntType m,
|
template < class IntType, IntType a, IntType c, IntType m,
|
IntType val > class linear_congruential
|
IntType val > class linear_congruential
|
{
|
{
|
public:typedef IntType result_type;
|
public:typedef IntType result_type;
|
static const IntType modulus = m;
|
static const IntType modulus = m;
|
explicit linear_congruential (IntType x0 = 1):_modulus (modulus),
|
explicit linear_congruential (IntType x0 = 1):_modulus (modulus),
|
_x (_modulus ? (x0 % _modulus) :
|
_x (_modulus ? (x0 % _modulus) :
|
x0)
|
x0)
|
{
|
{
|
}
|
}
|
IntType operator () ()
|
IntType operator () ()
|
{
|
{
|
_x = const_mod < IntType, m >::mult_add (a, _x, c);
|
_x = const_mod < IntType, m >::mult_add (a, _x, c);
|
}
|
}
|
private:IntType _modulus;
|
private:IntType _modulus;
|
IntType _x;
|
IntType _x;
|
};
|
};
|
}
|
}
|
typedef random::linear_congruential < int32_t, 16807, 0, 2147483647,
|
typedef random::linear_congruential < int32_t, 16807, 0, 2147483647,
|
1043618065 > minstd_rand0;
|
1043618065 > minstd_rand0;
|
namespace random
|
namespace random
|
{
|
{
|
namespace detail
|
namespace detail
|
{
|
{
|
template < class T > struct ptr_helper
|
template < class T > struct ptr_helper
|
{
|
{
|
typedef T value_type;
|
typedef T value_type;
|
typedef T & reference_type;
|
typedef T & reference_type;
|
typedef const T & rvalue_type;
|
typedef const T & rvalue_type;
|
static reference_type ref (T & r)
|
static reference_type ref (T & r)
|
{
|
{
|
}
|
}
|
};
|
};
|
template < class T > struct ptr_helper
|
template < class T > struct ptr_helper
|
{
|
{
|
typedef T value_type;
|
typedef T value_type;
|
typedef T & rvalue_type;
|
typedef T & rvalue_type;
|
};
|
};
|
}
|
}
|
}
|
}
|
template < class UniformRandomNumberGenerator, class RealType =
|
template < class UniformRandomNumberGenerator, class RealType =
|
double >class uniform_01
|
double >class uniform_01
|
{
|
{
|
public:typedef UniformRandomNumberGenerator base_type;
|
public:typedef UniformRandomNumberGenerator base_type;
|
typedef RealType result_type;
|
typedef RealType result_type;
|
explicit uniform_01 (base_type rng):_rng (rng),
|
explicit uniform_01 (base_type rng):_rng (rng),
|
_factor (result_type (1) /
|
_factor (result_type (1) /
|
(result_type ((_rng.max) () - (_rng.min) ()) +
|
(result_type ((_rng.max) () - (_rng.min) ()) +
|
result_type (std::numeric_limits <
|
result_type (std::numeric_limits <
|
base_result >::is_integer ? 1 : 0)))
|
base_result >::is_integer ? 1 : 0)))
|
{
|
{
|
}
|
}
|
result_type operator () ()
|
result_type operator () ()
|
{
|
{
|
return result_type (_rng () - (_rng.min) ()) * _factor;
|
return result_type (_rng () - (_rng.min) ()) * _factor;
|
}
|
}
|
private:typedef typename base_type::result_type base_result;
|
private:typedef typename base_type::result_type base_result;
|
base_type _rng;
|
base_type _rng;
|
result_type _factor;
|
result_type _factor;
|
};
|
};
|
namespace random
|
namespace random
|
{
|
{
|
namespace detail
|
namespace detail
|
{
|
{
|
template < class UniformRandomNumberGenerator >
|
template < class UniformRandomNumberGenerator >
|
class pass_through_engine
|
class pass_through_engine
|
{
|
{
|
private:typedef ptr_helper < UniformRandomNumberGenerator >
|
private:typedef ptr_helper < UniformRandomNumberGenerator >
|
helper_type;
|
helper_type;
|
public:typedef typename helper_type::value_type base_type;
|
public:typedef typename helper_type::value_type base_type;
|
typedef typename base_type::result_type result_type;
|
typedef typename base_type::result_type result_type;
|
explicit pass_through_engine (UniformRandomNumberGenerator
|
explicit pass_through_engine (UniformRandomNumberGenerator
|
rng):_rng (static_cast <
|
rng):_rng (static_cast <
|
typename helper_type::
|
typename helper_type::
|
rvalue_type > (rng))
|
rvalue_type > (rng))
|
{
|
{
|
}
|
}
|
result_type min () const
|
result_type min () const
|
{
|
{
|
}
|
}
|
result_type max () const
|
result_type max () const
|
{
|
{
|
}
|
}
|
base_type & base ()
|
base_type & base ()
|
{
|
{
|
}
|
}
|
result_type operator () ()
|
result_type operator () ()
|
{
|
{
|
return base ()();
|
return base ()();
|
}
|
}
|
private:UniformRandomNumberGenerator _rng;
|
private:UniformRandomNumberGenerator _rng;
|
};
|
};
|
}
|
}
|
template < class RealType, int w, unsigned int p,
|
template < class RealType, int w, unsigned int p,
|
unsigned int q > class lagged_fibonacci_01
|
unsigned int q > class lagged_fibonacci_01
|
{
|
{
|
public:typedef RealType result_type;
|
public:typedef RealType result_type;
|
static const unsigned int long_lag = p;
|
static const unsigned int long_lag = p;
|
lagged_fibonacci_01 ()
|
lagged_fibonacci_01 ()
|
{
|
{
|
seed ();
|
seed ();
|
}
|
}
|
public:void seed (uint32_t value = 331u)
|
public:void seed (uint32_t value = 331u)
|
{
|
{
|
minstd_rand0 intgen (value);
|
minstd_rand0 intgen (value);
|
seed (intgen);
|
seed (intgen);
|
}
|
}
|
template < class Generator > void seed (Generator & gen)
|
template < class Generator > void seed (Generator & gen)
|
{
|
{
|
typedef detail::pass_through_engine < Generator & >ref_gen;
|
typedef detail::pass_through_engine < Generator & >ref_gen;
|
uniform_01 < ref_gen, RealType > gen01 =
|
uniform_01 < ref_gen, RealType > gen01 =
|
uniform_01 < ref_gen, RealType > (ref_gen (gen));
|
uniform_01 < ref_gen, RealType > (ref_gen (gen));
|
for (unsigned int j = 0; j < long_lag; ++j)
|
for (unsigned int j = 0; j < long_lag; ++j)
|
x[j] = gen01 ();
|
x[j] = gen01 ();
|
}
|
}
|
RealType x[long_lag];
|
RealType x[long_lag];
|
};
|
};
|
}
|
}
|
typedef random::lagged_fibonacci_01 < double, 48, 607,
|
typedef random::lagged_fibonacci_01 < double, 48, 607,
|
273 > lagged_fibonacci607;
|
273 > lagged_fibonacci607;
|
namespace random
|
namespace random
|
{
|
{
|
namespace detail
|
namespace detail
|
{
|
{
|
template < bool have_int, bool want_int > struct engine_helper;
|
template < bool have_int, bool want_int > struct engine_helper;
|
template <> struct engine_helper
|
template <> struct engine_helper
|
{
|
{
|
template < class Engine, class DistInputType > struct impl
|
template < class Engine, class DistInputType > struct impl
|
{
|
{
|
typedef pass_through_engine < Engine > type;
|
typedef pass_through_engine < Engine > type;
|
};
|
};
|
};
|
};
|
}
|
}
|
}
|
}
|
template < class Engine, class Distribution > class variate_generator
|
template < class Engine, class Distribution > class variate_generator
|
{
|
{
|
private:typedef random::detail::pass_through_engine < Engine >
|
private:typedef random::detail::pass_through_engine < Engine >
|
decorated_engine;
|
decorated_engine;
|
public:typedef typename decorated_engine::base_type engine_value_type;
|
public:typedef typename decorated_engine::base_type engine_value_type;
|
typedef Distribution distribution_type;
|
typedef Distribution distribution_type;
|
variate_generator (Engine e, Distribution d):_eng (decorated_engine (e)),
|
variate_generator (Engine e, Distribution d):_eng (decorated_engine (e)),
|
_dist (d)
|
_dist (d)
|
{
|
{
|
}
|
}
|
private:enum
|
private:enum
|
{
|
{
|
have_int =
|
have_int =
|
std::numeric_limits <
|
std::numeric_limits <
|
typename decorated_engine::result_type >::is_integer, want_int =
|
typename decorated_engine::result_type >::is_integer, want_int =
|
std::numeric_limits < typename Distribution::input_type >::is_integer
|
std::numeric_limits < typename Distribution::input_type >::is_integer
|
};
|
};
|
typedef typename random::detail::engine_helper < have_int,
|
typedef typename random::detail::engine_helper < have_int,
|
want_int >::template impl < decorated_engine,
|
want_int >::template impl < decorated_engine,
|
typename Distribution::input_type >::type internal_engine_type;
|
typename Distribution::input_type >::type internal_engine_type;
|
internal_engine_type _eng;
|
internal_engine_type _eng;
|
distribution_type _dist;
|
distribution_type _dist;
|
};
|
};
|
template < class RealType = double >class uniform_real
|
template < class RealType = double >class uniform_real
|
{
|
{
|
public:typedef RealType input_type;
|
public:typedef RealType input_type;
|
};
|
};
|
}
|
}
|
namespace alps
|
namespace alps
|
{
|
{
|
class BufferedRandomNumberGeneratorBase
|
class BufferedRandomNumberGeneratorBase
|
{
|
{
|
};
|
};
|
template < class RNG >
|
template < class RNG >
|
class BufferedRandomNumberGenerator:public
|
class BufferedRandomNumberGenerator:public
|
BufferedRandomNumberGeneratorBase
|
BufferedRandomNumberGeneratorBase
|
{
|
{
|
public: BufferedRandomNumberGenerator ():rng_ (), gen_ (rng_,
|
public: BufferedRandomNumberGenerator ():rng_ (), gen_ (rng_,
|
boost::
|
boost::
|
uniform_real <> ())
|
uniform_real <> ())
|
{
|
{
|
}
|
}
|
protected: RNG rng_;
|
protected: RNG rng_;
|
boost::variate_generator < RNG &, boost::uniform_real <> >gen_;
|
boost::variate_generator < RNG &, boost::uniform_real <> >gen_;
|
};
|
};
|
}
|
}
|
namespace boost
|
namespace boost
|
{
|
{
|
namespace detail
|
namespace detail
|
{
|
{
|
class sp_counted_base
|
class sp_counted_base
|
{
|
{
|
};
|
};
|
class shared_count
|
class shared_count
|
{
|
{
|
private:sp_counted_base * pi_;
|
private:sp_counted_base * pi_;
|
public:shared_count ():pi_ (0)
|
public:shared_count ():pi_ (0)
|
{
|
{
|
}
|
}
|
template < class Y > explicit shared_count (Y * p):pi_ (0)
|
template < class Y > explicit shared_count (Y * p):pi_ (0)
|
{
|
{
|
}
|
}
|
};
|
};
|
}
|
}
|
template < class T > class shared_ptr
|
template < class T > class shared_ptr
|
{
|
{
|
public:typedef T element_type;
|
public:typedef T element_type;
|
template < class Y > explicit shared_ptr (Y * p):px (p), pn (p)
|
template < class Y > explicit shared_ptr (Y * p):px (p), pn (p)
|
{
|
{
|
}
|
}
|
T *px;
|
T *px;
|
detail::shared_count pn;
|
detail::shared_count pn;
|
};
|
};
|
}
|
}
|
namespace std
|
namespace std
|
{
|
{
|
template < typename _Key, typename _Tp, typename _Compare =
|
template < typename _Key, typename _Tp, typename _Compare =
|
std::allocator < std::pair < const _Key, _Tp > > > class map
|
std::allocator < std::pair < const _Key, _Tp > > > class map
|
{
|
{
|
public:typedef _Key key_type;
|
public:typedef _Key key_type;
|
typedef _Tp mapped_type;
|
typedef _Tp mapped_type;
|
mapped_type & operator[] (const key_type & __k)
|
mapped_type & operator[] (const key_type & __k)
|
{
|
{
|
}
|
}
|
};
|
};
|
}
|
}
|
namespace alps
|
namespace alps
|
{
|
{
|
namespace detail
|
namespace detail
|
{
|
{
|
template < class BASE > class abstract_creator
|
template < class BASE > class abstract_creator
|
{
|
{
|
public:typedef BASE base_type;
|
public:typedef BASE base_type;
|
virtual base_type *create () const = 0;
|
virtual base_type *create () const = 0;
|
};
|
};
|
template < class BASE,
|
template < class BASE,
|
class T > class creator:public abstract_creator < BASE >
|
class T > class creator:public abstract_creator < BASE >
|
{
|
{
|
public:typedef BASE base_type;
|
public:typedef BASE base_type;
|
base_type *create () const
|
base_type *create () const
|
{
|
{
|
return new T ();
|
return new T ();
|
}
|
}
|
};
|
};
|
}
|
}
|
template < class KEY, class BASE > class factory
|
template < class KEY, class BASE > class factory
|
{
|
{
|
public:typedef BASE base_type;
|
public:typedef BASE base_type;
|
typedef KEY key_type;
|
typedef KEY key_type;
|
typedef boost::shared_ptr < detail::abstract_creator < base_type >
|
typedef boost::shared_ptr < detail::abstract_creator < base_type >
|
>pointer_type;
|
>pointer_type;
|
template < class T > bool register_type (key_type k)
|
template < class T > bool register_type (key_type k)
|
{
|
{
|
creators_[k] = pointer_type (new detail::creator < BASE, T > ());
|
creators_[k] = pointer_type (new detail::creator < BASE, T > ());
|
}
|
}
|
private:typedef std::map < key_type, pointer_type > map_type;
|
private:typedef std::map < key_type, pointer_type > map_type;
|
map_type creators_;
|
map_type creators_;
|
};
|
};
|
class RNGFactory:public factory < std::string,
|
class RNGFactory:public factory < std::string,
|
BufferedRandomNumberGeneratorBase >
|
BufferedRandomNumberGeneratorBase >
|
{
|
{
|
public:RNGFactory ();
|
public:RNGFactory ();
|
};
|
};
|
}
|
}
|
alps::RNGFactory::RNGFactory ()
|
alps::RNGFactory::RNGFactory ()
|
{
|
{
|
register_type < BufferedRandomNumberGenerator < boost::lagged_fibonacci607 >
|
register_type < BufferedRandomNumberGenerator < boost::lagged_fibonacci607 >
|
>("lagged_fibonacci607");
|
>("lagged_fibonacci607");
|
}
|
}
|
|
|