Blaze  3.6
UniformMatrix.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_UNIFORMMATRIX_H_
36 #define _BLAZE_MATH_UNIFORMMATRIX_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
44 #include <blaze/math/DenseMatrix.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 matrix
65  , bool SO > // Storage order
66 class Rand< UniformMatrix<Type,SO> >
67 {
68  public:
69  //**Generate functions**************************************************************************
72  inline const UniformMatrix<Type,SO> generate( size_t m, size_t n ) const;
73 
74  template< typename Arg >
75  inline const UniformMatrix<Type,SO> generate( size_t m, size_t n, const Arg& min, const Arg& max ) const;
77  //**********************************************************************************************
78 
79  //**Randomize functions*************************************************************************
82  inline void randomize( UniformMatrix<Type,SO>& matrix ) const;
83 
84  template< typename Arg >
85  inline void randomize( UniformMatrix<Type,SO>& matrix, const Arg& min, const Arg& max ) const;
87  //**********************************************************************************************
88 };
90 //*************************************************************************************************
91 
92 
93 //*************************************************************************************************
101 template< typename Type // Data type of the matrix
102  , bool SO > // Storage order
103 inline const UniformMatrix<Type,SO>
104  Rand< UniformMatrix<Type,SO> >::generate( size_t m, size_t n ) const
105 {
106  UniformMatrix<Type,SO> matrix( m, n );
107  randomize( matrix );
108  return matrix;
109 }
111 //*************************************************************************************************
112 
113 
114 //*************************************************************************************************
124 template< typename Type // Data type of the matrix
125  , bool SO > // Storage order
126 template< typename Arg > // Min/max argument type
127 inline const UniformMatrix<Type,SO>
128  Rand< UniformMatrix<Type,SO> >::generate( size_t m, size_t n, const Arg& min, const Arg& max ) const
129 {
130  UniformMatrix<Type,SO> matrix( m, n );
131  randomize( matrix, min, max );
132  return matrix;
133 }
135 //*************************************************************************************************
136 
137 
138 //*************************************************************************************************
145 template< typename Type // Data type of the matrix
146  , bool SO > // Storage order
147 inline void Rand< UniformMatrix<Type,SO> >::randomize( UniformMatrix<Type,SO>& matrix ) const
148 {
149  matrix = rand<Type>();
150 }
152 //*************************************************************************************************
153 
154 
155 //*************************************************************************************************
164 template< typename Type // Data type of the matrix
165  , bool SO > // Storage order
166 template< typename Arg > // Min/max argument type
167 inline void Rand< UniformMatrix<Type,SO> >::randomize( UniformMatrix<Type,SO>& matrix,
168  const Arg& min, const Arg& max ) const
169 {
170  matrix = rand<Type>( min, max );
171 }
173 //*************************************************************************************************
174 
175 } // namespace blaze
176 
177 #endif
Header file for basic type definitions.
void randomize(T &&value)
Randomization of a given variable.
Definition: Random.h:929
Implementation of a random number generator.
Header file for the implementation of a uniform matrix.
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
T generate() const
Generation of a random value in the range .
Definition: Random.h:252
Header file for all basic DenseMatrix functionality.