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 >
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 );
348 inline void randomize(
float& value )
const;
367 std::uniform_real_distribution<float> dist( 0.0, 1.0 );
368 return dist( Random<RNG>::rng_ );
390 std::uniform_real_distribution<float> dist( min, max );
391 return dist( Random<RNG>::rng_ );
430 value = generate( min, max );
467 inline void randomize(
double& value )
const;
486 std::uniform_real_distribution<double> dist( 0.0, 1.0 );
487 return dist( Random<RNG>::rng_ );
509 std::uniform_real_distribution<double> dist( min, max );
510 return dist( Random<RNG>::rng_ );
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 );
606 return dist( Random<RNG>::rng_ );
628 std::uniform_real_distribution<long double> dist( min, max );
629 return dist( Random<RNG>::rng_ );
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 >
727 inline const complex<T> Rand< complex<T> >::generate()
const
730 return complex<T>( tmp.generate(), tmp.generate() );
750 template<
typename T >
751 inline const complex<T> Rand< complex<T> >::generate(
const T&
min,
const T&
max )
const
754 return complex<T>( tmp.generate( min, max ), tmp.generate( min, max ) );
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 >
799 inline void Rand< complex<T> >
::randomize( complex<T>& value )
const
822 template<
typename T >
823 inline void Rand< complex<T> >
::randomize( complex<T>& value,
const T& min,
const T& max )
const
825 value = generate( min, max );
850 template<
typename T >
851 inline void Rand< complex<T> >
::randomize( complex<T>& value,
const T& realmin,
const T& realmax,
852 const T& imagmin,
const T& imagmax )
const
854 value = generate( realmin, realmax, imagmin, imagmax );
882 template<
typename T >
886 return tmp.generate();
902 inline T
rand( Args&&... args )
905 return tmp.generate( std::forward<Args>( args )... );
925 template<
typename T >
929 tmp.randomize( value );
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:1669
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1716
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
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:289
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