35 #ifndef _BLAZE_UTIL_RANDOM_H_ 36 #define _BLAZE_UTIL_RANDOM_H_ 130 template<
typename T >
133 template<
typename T,
typename... Args >
134 inline T
rand( Args&&... args );
136 template<
typename T >
139 template<
typename T,
typename... Args >
140 inline void randomize( T&& value, Args&&... args );
144 inline void setSeed( uint32_t seed );
169 template<
typename Type >
184 template<
typename T >
friend class Rand;
220 template<
typename T >
251 template<
typename T >
272 template<
typename T >
276 std::uniform_int_distribution<T> dist(
min,
max );
291 template<
typename T >
312 template<
typename T >
315 value = generate(
min,
max );
351 inline void randomize(
float& value )
const;
370 std::uniform_real_distribution<float> dist( 0.0, 1.0 );
393 std::uniform_real_distribution<float> dist(
min,
max );
433 value = generate(
min,
max );
470 inline void randomize(
double& value )
const;
489 std::uniform_real_distribution<double> dist( 0.0, 1.0 );
512 std::uniform_real_distribution<double> dist(
min,
max );
552 value = generate(
min,
max );
575 class Rand<long double>
581 inline long double generate()
const;
582 inline long double generate(
long double min,
long double max )
const;
589 inline void randomize(
long double& value )
const;
590 inline void randomize(
long double& value,
long double min,
long double max )
const;
608 std::uniform_real_distribution<long double> dist( 0.0, 1.0 );
631 std::uniform_real_distribution<long double> dist(
min,
max );
671 value = generate(
min,
max );
692 template<
typename T >
693 class Rand< complex<T> >
699 inline const complex<T>
generate()
const;
700 inline const complex<T>
generate(
const T&
min,
const T&
max )
const;
701 inline const complex<T>
generate(
const T& realmin,
const T& realmax,
702 const T& imagmin,
const T& imagmax )
const;
709 inline void randomize( complex<T>& value )
const;
710 inline void randomize( complex<T>& value,
const T&
min,
const T&
max )
const;
711 inline void randomize( complex<T>& value,
const T& realmin,
const T& realmax,
712 const T& imagmin,
const T& imagmax )
const;
729 template<
typename T >
730 inline const complex<T> Rand< complex<T> >::generate()
const 733 return complex<T>( tmp.generate(), tmp.generate() );
753 template<
typename T >
754 inline const complex<T> Rand< complex<T> >::generate(
const T&
min,
const T&
max )
const 757 return complex<T>( tmp.generate(
min,
max ), tmp.generate(
min,
max ) );
780 template<
typename T >
781 inline const complex<T> Rand< complex<T> >::generate(
const T& realmin,
const T& realmax,
782 const T& imagmin,
const T& imagmax )
const 785 return complex<T>( tmp.generate( realmin, realmax ), tmp.generate( imagmin, imagmax ) );
801 template<
typename T >
802 inline void Rand< complex<T> >
::randomize( complex<T>& value )
const 825 template<
typename T >
826 inline void Rand< complex<T> >
::randomize( complex<T>& value,
const T&
min,
const T&
max )
const 828 value = generate(
min,
max );
853 template<
typename T >
854 inline void Rand< complex<T> >
::randomize( complex<T>& value,
const T& realmin,
const T& realmax,
855 const T& imagmin,
const T& imagmax )
const 857 value = generate( realmin, realmax, imagmin, imagmax );
885 template<
typename T >
889 return tmp.generate();
905 inline T
rand( Args&&... args )
908 return tmp.generate( std::forward<Args>( args )... );
928 template<
typename T >
932 tmp.randomize( std::forward<T>( value ) );
952 tmp.randomize( std::forward<T>( value ), std::forward<Args>( args )... );
965 static const uint32_t seed = static_cast<uint32_t>( std::time(0) );
uint32_t getSeed()
Returns the current seed of the random number generator.
Definition: Random.h:977
Header file for basic type definitions.
Header file for the RemoveCV type trait.
Header file for the RemoveCVRef type trait.
void randomize(T &&value)
Randomization of a given variable.
Definition: Random.h:929
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:963
void randomize(T &value) const
Randomization of the given variable with a new value in the range .
Definition: Random.h:292
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1162
void setSeed(uint32_t seed)
Setting the seed of the random number generator.
Definition: Random.h:994
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1198
T rand()
Random number function.
Definition: Random.h:886
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:221
Random number generator.The Random class encapsulates the initialization of the given random number g...
Definition: Random.h:170
static uint32_t seed_
The current seed for the variate generator.
Definition: Random.h:177
static Type rng_
The mersenne twister variate generator.
Definition: Random.h:178
T generate() const
Generation of a random value in the range .
Definition: Random.h:252
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,...
Definition: Assert.h:101