35 #ifndef _BLAZE_UTIL_RANDOM_H_ 36 #define _BLAZE_UTIL_RANDOM_H_ 128 template<
typename T >
131 template<
typename T,
typename... Args >
132 inline T
rand( Args&&... args );
134 template<
typename T >
137 template<
typename T,
typename... Args >
138 inline void randomize( T& value, Args&&... args );
142 inline void setSeed( uint32_t seed );
167 template<
typename Type >
181 template<
typename T >
friend class Rand;
217 template<
typename T >
224 inline T generate()
const;
225 inline T generate( T
min, T
max )
const;
233 inline void randomize( T& value, T min, T max )
const;
248 template<
typename T >
269 template<
typename T >
273 std::uniform_int_distribution<T> dist( min, max );
288 template<
typename T >
309 template<
typename T >
312 value = generate( min, max );
340 inline float generate()
const;
341 inline float generate(
float min,
float max )
const;
348 inline void randomize(
float& value )
const;
349 inline void randomize(
float& value,
float min,
float max )
const;
367 std::uniform_real_distribution<float> dist( 0.0, 1.0 );
390 std::uniform_real_distribution<float> dist( min, max );
430 value = generate( min, max );
459 inline double generate()
const;
460 inline double generate(
double min,
double max )
const;
467 inline void randomize(
double& value )
const;
468 inline void randomize(
double& value,
double min,
double max )
const;
486 std::uniform_real_distribution<double> dist( 0.0, 1.0 );
509 std::uniform_real_distribution<double> dist( min, max );
549 value = generate( min, max );
572 class Rand<long double>
578 inline long double generate()
const;
579 inline long double generate(
long double min,
long double max )
const;
586 inline void randomize(
long double& value )
const;
587 inline void randomize(
long double& value,
long double min,
long double max )
const;
605 std::uniform_real_distribution<long double> dist( 0.0, 1.0 );
628 std::uniform_real_distribution<long double> dist( min, max );
668 value = generate( min, max );
689 template<
typename T >
690 class Rand< complex<T> >
696 inline const complex<T> generate()
const;
697 inline const complex<T> generate(
const T& min,
const T& max )
const;
698 inline const complex<T> generate(
const T& realmin,
const T& realmax,
699 const T& imagmin,
const T& imagmax )
const;
706 inline void randomize( complex<T>& value )
const;
707 inline void randomize( complex<T>& value,
const T& min,
const T& max )
const;
708 inline void randomize( complex<T>& value,
const T& realmin,
const T& realmax,
709 const T& imagmin,
const T& imagmax )
const;
726 template<
typename T >
750 template<
typename T >
751 inline const complex<T>
Rand< complex<T> >::generate(
const T& min,
const T& max )
const 777 template<
typename T >
778 inline const complex<T>
Rand< complex<T> >::generate(
const T& realmin,
const T& realmax,
779 const T& imagmin,
const T& imagmax )
const 782 return complex<T>( tmp.
generate( realmin, realmax ), tmp.
generate( imagmin, imagmax ) );
798 template<
typename T >
822 template<
typename T >
825 value = generate( min, max );
850 template<
typename T >
852 const T& imagmin,
const T& imagmax )
const 854 value = generate( realmin, realmax, imagmin, imagmax );
882 template<
typename T >
902 inline T
rand( Args&&... args )
905 return tmp.
generate( std::forward<Args>( args )... );
925 template<
typename T >
949 tmp.
randomize( value, std::forward<Args>( args )... );
uint32_t getSeed()
Returns the current seed of the random number generator.
Definition: Random.h:974
Header file for basic type definitions.
void randomize(T &value)
Randomization of a given variable.
Definition: Random.h:926
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1755
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1802
32-bit unsigned integer type of the Blaze library.
Header file for the random number generator used in the Blaze library.
uint32_t defaultSeed()
Returns the default random seed.
Definition: Random.h:960
void randomize(T &value) const
Randomization of the given variable with a new value in the range .
Definition: Random.h:289
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
void setSeed(uint32_t seed)
Setting the seed of the random number generator.
Definition: Random.h:991
T rand()
Random number function.
Definition: Random.h:883
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:218
Random number generator.The Random class encapsulates the initialization of the given random number g...
Definition: Random.h:168
static uint32_t seed_
The current seed for the variate generator.
Definition: Random.h:174
static Type rng_
The mersenne twister variate generator.
Definition: Random.h:175
T generate() const
Generation of a random value in the range .
Definition: Random.h:249
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