35 #ifndef _BLAZE_UTIL_RANDOM_H_
36 #define _BLAZE_UTIL_RANDOM_H_
45 #include <boost/random/uniform_int.hpp>
46 #include <boost/random/uniform_real.hpp>
47 #include <boost/random/uniform_smallint.hpp>
63 template<
typename >
class Rand;
138 template<
typename Type >
152 template<
typename T >
friend class Rand;
188 template<
typename T >
219 template<
typename T >
240 template<
typename T >
244 boost::uniform_smallint<T> dist( min, max );
259 template<
typename T >
280 template<
typename T >
283 value = generate( min, max );
319 inline void randomize(
float& value )
const;
338 boost::uniform_real<float> dist( 0.0, 1.0 );
339 return dist( Random<RNG>::rng_ );
361 boost::uniform_real<float> dist( min, max );
362 return dist( Random<RNG>::rng_ );
401 value = generate( min, max );
438 inline void randomize(
double& value )
const;
457 boost::uniform_real<double> dist( 0.0, 1.0 );
458 return dist( Random<RNG>::rng_ );
480 boost::uniform_real<double> dist( min, max );
481 return dist( Random<RNG>::rng_ );
520 value = generate( min, max );
543 class Rand<long double>
549 inline long double generate()
const;
550 inline long double generate(
long double min,
long double max )
const;
557 inline void randomize(
long double& value )
const;
558 inline void randomize(
long double& value,
long double min,
long double max )
const;
576 boost::uniform_real<long double> dist( 0.0, 1.0 );
577 return dist( Random<RNG>::rng_ );
599 boost::uniform_real<long double> dist( min, max );
600 return dist( Random<RNG>::rng_ );
639 value = generate( min, max );
660 template<
typename T >
661 class Rand< complex<T> >
667 inline const complex<T>
generate()
const;
668 inline const complex<T>
generate(
const T&
min,
const T&
max )
const;
669 inline const complex<T>
generate(
const T& realmin,
const T& realmax,
670 const T& imagmin,
const T& imagmax )
const;
677 inline void randomize( complex<T>& value )
const;
678 inline void randomize( complex<T>& value,
const T&
min,
const T&
max )
const;
679 inline void randomize( complex<T>& value,
const T& realmin,
const T& realmax,
680 const T& imagmin,
const T& imagmax )
const;
697 template<
typename T >
698 inline const complex<T> Rand< complex<T> >::generate()
const
701 return complex<T>( tmp.generate(), tmp.generate() );
721 template<
typename T >
722 inline const complex<T> Rand< complex<T> >::generate(
const T&
min,
const T&
max )
const
725 return complex<T>( tmp.generate( min, max ), tmp.generate( min, max ) );
748 template<
typename T >
749 inline const complex<T> Rand< complex<T> >::generate(
const T& realmin,
const T& realmax,
750 const T& imagmin,
const T& imagmax )
const
753 return complex<T>( tmp.generate( realmin, realmax ), tmp.generate( imagmin, imagmax ) );
769 template<
typename T >
770 inline void Rand< complex<T> >
::randomize( complex<T>& value )
const
793 template<
typename T >
794 inline void Rand< complex<T> >
::randomize( complex<T>& value,
const T& min,
const T& max )
const
796 value = generate( min, max );
821 template<
typename T >
822 inline void Rand< complex<T> >
::randomize( complex<T>& value,
const T& realmin,
const T& realmax,
823 const T& imagmin,
const T& imagmax )
const
825 value = generate( realmin, realmax, imagmin, imagmax );
842 template<
typename T >
845 template<
typename T,
typename A1 >
846 inline T
rand(
const A1& a1 );
848 template<
typename T,
typename A1,
typename A2 >
849 inline T
rand(
const A1& a1,
const A2& a2 );
851 template<
typename T,
typename A1,
typename A2,
typename A3 >
852 inline T
rand(
const A1& a1,
const A2& a2,
const A3& a3 );
854 template<
typename T,
typename A1,
typename A2,
typename A3,
typename A4 >
855 inline T
rand(
const A1& a1,
const A2& a2,
const A3& a3,
const A4& a4 );
857 template<
typename T,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5 >
858 inline T
rand(
const A1& a1,
const A2& a2,
const A3& a3,
const A4& a4,
const A5& a5 );
860 template<
typename T >
863 template<
typename T,
typename A1 >
864 inline void randomize( T& value,
const A1& a1 );
866 template<
typename T,
typename A1,
typename A2 >
867 inline void randomize( T& value,
const A1& a1,
const A2& a2 );
869 template<
typename T,
typename A1,
typename A2,
typename A3 >
870 inline void randomize( T& value,
const A1& a1,
const A2& a2,
const A3& a3 );
872 template<
typename T,
typename A1,
typename A2,
typename A3,
typename A4 >
873 inline void randomize( T& value,
const A1& a1,
const A2& a2,
const A3& a3,
const A4& a4 );
875 template<
typename T,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5 >
876 inline void randomize( T& value,
const A1& a1,
const A2& a2,
const A3& a3,
const A4& a4,
const A5& a5 );
879 inline void setSeed( uint32_t seed );
898 template<
typename T >
902 return tmp.generate();
921 return tmp.generate( a1 );
939 inline T
rand(
const A1& a1,
const A2& a2 )
942 return tmp.generate( a1, a2 );
963 inline T
rand(
const A1& a1,
const A2& a2,
const A3& a3 )
966 return tmp.generate( a1, a2, a3 );
989 inline T
rand(
const A1& a1,
const A2& a2,
const A3& a3,
const A4& a4 )
992 return tmp.generate( a1, a2, a3, a4 );
1011 template<
typename T
1017 inline T
rand(
const A1& a1,
const A2& a2,
const A3& a3,
const A4& a4,
const A5& a5 )
1020 return tmp.generate( a1, a2, a3, a4, a5 );
1040 template<
typename T >
1044 tmp.randomize( value );
1059 template<
typename T
1064 tmp.randomize( value, a1 );
1081 template<
typename T
1084 inline void randomize( T& value,
const A1& a1,
const A2& a2 )
1087 tmp.randomize( value, a1, a2 );
1105 template<
typename T
1109 inline void randomize( T& value,
const A1& a1,
const A2& a2,
const A3& a3 )
1112 tmp.randomize( value, a1, a2, a3 );
1131 template<
typename T
1136 inline void randomize( T& value,
const A1& a1,
const A2& a2,
const A3& a3,
const A4& a4 )
1139 tmp.randomize( value, a1, a2, a3, a4 );
1159 template<
typename T
1165 inline void randomize( T& value,
const A1& a1,
const A2& a2,
const A3& a3,
const A4& a4,
const A5& a5 )
1168 tmp.randomize( value, a1, a2, a3, a4, a5 );
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1729
uint32_t getSeed()
Returns the current seed of the random number generator.
Definition: Random.h:1179
Header file for basic type definitions.
void randomize(T &value)
Randomization of a given variable.
Definition: Random.h:1041
32-bit unsigned integer type of the Blaze library.
Header file for the random number generator used in the Blaze library.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
void randomize(T &value) const
Randomization of the given variable with a new value in the range .
Definition: Random.h:260
void setSeed(uint32_t seed)
Setting the seed of the random number generator.
Definition: Random.h:1196
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1682
T rand()
Random number function.
Definition: Random.h:899
Header file for run time assertion macros.
Default implementation of the Rand class for integral data types.This default implementation of the R...
Definition: Random.h:63
Random number generator.The Random class encapsulates the initialization of the given random number g...
Definition: Random.h:139
static uint32_t seed_
The current seed for the variate generator.
Definition: Random.h:145
static Type rng_
The mersenne twister variate generator.
Definition: Random.h:146
T generate() const
Generation of a random value in the range .
Definition: Random.h:220
Header file for the complex data type.
Base class for non-creatable (static) classes.The NonCreatable class is intended to work as a base cl...
Definition: NonCreatable.h:65
Base class for non-creatable (static) classes.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101