Blaze  3.6
UniformVector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_UNIFORMVECTOR_H_
36 #define _BLAZE_MATH_UNIFORMVECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
44 #include <blaze/math/DenseVector.h>
45 #include <blaze/util/Random.h>
46 #include <blaze/util/Types.h>
47 
48 
49 namespace blaze {
50 
51 //=================================================================================================
52 //
53 // RAND SPECIALIZATION
54 //
55 //=================================================================================================
56 
57 //*************************************************************************************************
64 template< typename Type // Data type of the vector
65  , bool TF > // Transpose flag
66 class Rand< UniformVector<Type,TF> >
67 {
68  public:
69  //**Generate functions**************************************************************************
72  inline const UniformVector<Type,TF> generate( size_t n ) const;
73 
74  template< typename Arg >
75  inline const UniformVector<Type,TF> generate( size_t n, const Arg& min, const Arg& max ) const;
77  //**********************************************************************************************
78 
79  //**Randomize functions*************************************************************************
82  inline void randomize( UniformVector<Type,TF>& vector ) const;
83 
84  template< typename Arg >
85  inline void randomize( UniformVector<Type,TF>& vector, const Arg& min, const Arg& max ) const;
87  //**********************************************************************************************
88 };
90 //*************************************************************************************************
91 
92 
93 //*************************************************************************************************
100 template< typename Type // Data type of the vector
101  , bool TF > // Transpose flag
102 inline const UniformVector<Type,TF> Rand< UniformVector<Type,TF> >::generate( size_t n ) const
103 {
104  UniformVector<Type,TF> vector( n );
105  randomize( vector );
106  return vector;
107 }
109 //*************************************************************************************************
110 
111 
112 //*************************************************************************************************
121 template< typename Type // Data type of the vector
122  , bool TF > // Transpose flag
123 template< typename Arg > // Min/max argument type
124 inline const UniformVector<Type,TF>
125  Rand< UniformVector<Type,TF> >::generate( size_t n, const Arg& min, const Arg& max ) const
126 {
127  UniformVector<Type,TF> vector( n );
128  randomize( vector, min, max );
129  return vector;
130 }
132 //*************************************************************************************************
133 
134 
135 //*************************************************************************************************
142 template< typename Type // Data type of the vector
143  , bool TF > // Transpose flag
144 inline void Rand< UniformVector<Type,TF> >::randomize( UniformVector<Type,TF>& vector ) const
145 {
146  vector = rand<Type>();
147 }
149 //*************************************************************************************************
150 
151 
152 //*************************************************************************************************
161 template< typename Type // Data type of the vector
162  , bool TF > // Transpose flag
163 template< typename Arg > // Min/max argument type
164 inline void Rand< UniformVector<Type,TF> >::randomize( UniformVector<Type,TF>& vector,
165  const Arg& min, const Arg& max ) const
166 {
167  vector = rand<Type>( min, max );
168 }
170 //*************************************************************************************************
171 
172 } // namespace blaze
173 
174 #endif
Header file for basic type definitions.
Header file for the implementation of a uniform vector.
void randomize(T &&value)
Randomization of a given variable.
Definition: Random.h:929
Implementation of a random number generator.
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
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
Header file for all basic DenseVector functionality.
T generate() const
Generation of a random value in the range .
Definition: Random.h:252