All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DynamicMatrix.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_DYNAMICMATRIX_H_
36 #define _BLAZE_MATH_DYNAMICMATRIX_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
44 #include <blaze/math/DenseMatrix.h>
46 #include <blaze/system/Precision.h>
47 #include <blaze/util/Random.h>
48 
49 
50 namespace blaze {
51 
52 //=================================================================================================
53 //
54 // RAND SPECIALIZATION
55 //
56 //=================================================================================================
57 
58 //*************************************************************************************************
65 template< typename Type // Data type of the matrix
66  , bool SO > // Storage order
67 class Rand< DynamicMatrix<Type,SO> >
68 {
69  public:
70  //**Generate functions**************************************************************************
73  inline const DynamicMatrix<Type,SO> generate( size_t m, size_t n ) const;
74 
75  template< typename Arg >
76  inline const DynamicMatrix<Type,SO> generate( size_t m, size_t n, const Arg& min, const Arg& max ) const;
78  //**********************************************************************************************
79 
80  //**Randomize functions*************************************************************************
83  inline void randomize( DynamicMatrix<Type,SO>& matrix ) const;
84 
85  template< typename Arg >
86  inline void randomize( DynamicMatrix<Type,SO>& matrix, const Arg& min, const Arg& max ) const;
88  //**********************************************************************************************
89 };
91 //*************************************************************************************************
92 
93 
94 //*************************************************************************************************
102 template< typename Type // Data type of the matrix
103  , bool SO > // Storage order
104 inline const DynamicMatrix<Type,SO>
105  Rand< DynamicMatrix<Type,SO> >::generate( size_t m, size_t n ) const
106 {
107  DynamicMatrix<Type,SO> matrix( m, n );
108  randomize( matrix );
109  return matrix;
110 }
112 //*************************************************************************************************
113 
114 
115 //*************************************************************************************************
125 template< typename Type // Data type of the matrix
126  , bool SO > // Storage order
127 template< typename Arg > // Min/max argument type
128 inline const DynamicMatrix<Type,SO>
129  Rand< DynamicMatrix<Type,SO> >::generate( size_t m, size_t n, const Arg& min, const Arg& max ) const
130 {
131  DynamicMatrix<Type,SO> matrix( m, n );
132  randomize( matrix, min, max );
133  return matrix;
134 }
136 //*************************************************************************************************
137 
138 
139 //*************************************************************************************************
146 template< typename Type // Data type of the matrix
147  , bool SO > // Storage order
148 inline void Rand< DynamicMatrix<Type,SO> >::randomize( DynamicMatrix<Type,SO>& matrix ) const
149 {
150  using blaze::randomize;
151 
152  const size_t m( matrix.rows() );
153  const size_t n( matrix.columns() );
154 
155  for( size_t i=0UL; i<m; ++i ) {
156  for( size_t j=0UL; j<n; ++j ) {
157  randomize( matrix(i,j) );
158  }
159  }
160 }
162 //*************************************************************************************************
163 
164 
165 //*************************************************************************************************
174 template< typename Type // Data type of the matrix
175  , bool SO > // Storage order
176 template< typename Arg > // Min/max argument type
177 inline void Rand< DynamicMatrix<Type,SO> >::randomize( DynamicMatrix<Type,SO>& matrix,
178  const Arg& min, const Arg& max ) const
179 {
180  using blaze::randomize;
181 
182  const size_t m( matrix.rows() );
183  const size_t n( matrix.columns() );
184 
185  for( size_t i=0UL; i<m; ++i ) {
186  for( size_t j=0UL; j<n; ++j ) {
187  randomize( matrix(i,j), min, max );
188  }
189  }
190 }
192 //*************************************************************************************************
193 
194 
195 
196 
197 //=================================================================================================
198 //
199 // TYPE DEFINITIONS
200 //
201 //=================================================================================================
202 
203 //*************************************************************************************************
208 //*************************************************************************************************
209 
210 
211 //*************************************************************************************************
216 //*************************************************************************************************
217 
218 
219 //*************************************************************************************************
224 //*************************************************************************************************
225 
226 } // namespace blaze
227 
228 #endif
void randomize(T &value)
Randomization of a given variable.
Definition: Random.h:1043
Implementation of a random number generator.
Efficient implementation of a dynamic matrix.The DynamicMatrix class template is the representation ...
Definition: DynamicMatrix.h:176
DynamicMatrix< double, false > MatMxNd
MxN double precision matrix.
Definition: DynamicMatrix.h:215
Header file for the floating point precision of the Blaze library.
void randomize(T &value) const
Randomization of the given variable with a new value in the range .
Definition: Random.h:262
Header file for the implementation of a dynamic MxN matrix.
DynamicMatrix< real, false > MatMxN
MxN matrix with system-specific precision.
Definition: DynamicMatrix.h:223
Header file for the complete DynamicVector implementation.
DynamicMatrix< float, false > MatMxNf
MxN single precision matrix.
Definition: DynamicMatrix.h:207
T generate() const
Generation of a random value in the range .
Definition: Random.h:222
Header file for the DenseMatrix CRTP base class.