All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DynamicMatrix.h
Go to the documentation of this file.
1 //=================================================================================================
20 //=================================================================================================
21 
22 #ifndef _BLAZE_MATH_DYNAMICMATRIX_H_
23 #define _BLAZE_MATH_DYNAMICMATRIX_H_
24 
25 
26 //*************************************************************************************************
27 // Includes
28 //*************************************************************************************************
29 
31 #include <blaze/math/DenseMatrix.h>
33 #include <blaze/system/Precision.h>
34 #include <blaze/util/Random.h>
35 
36 
37 namespace blaze {
38 
39 //=================================================================================================
40 //
41 // RAND SPECIALIZATION
42 //
43 //=================================================================================================
44 
45 //*************************************************************************************************
52 template< typename Type // Data type of the matrix
53  , bool SO > // Storage order
54 class Rand< DynamicMatrix<Type,SO> >
55 {
56  public:
57  //**Generate functions**************************************************************************
60  inline const DynamicMatrix<Type,SO> generate( size_t m, size_t n ) const;
61 
62  template< typename Arg >
63  inline const DynamicMatrix<Type,SO> generate( size_t m, size_t n, const Arg& min, const Arg& max ) const;
65  //**********************************************************************************************
66 
67  //**Randomize functions*************************************************************************
70  inline void randomize( DynamicMatrix<Type,SO>& matrix ) const;
71 
72  template< typename Arg >
73  inline void randomize( DynamicMatrix<Type,SO>& matrix, const Arg& min, const Arg& max ) const;
75  //**********************************************************************************************
76 };
78 //*************************************************************************************************
79 
80 
81 //*************************************************************************************************
89 template< typename Type // Data type of the matrix
90  , bool SO > // Storage order
91 inline const DynamicMatrix<Type,SO>
92  Rand< DynamicMatrix<Type,SO> >::generate( size_t m, size_t n ) const
93 {
94  DynamicMatrix<Type,SO> matrix( m, n );
95  randomize( matrix );
96  return matrix;
97 }
99 //*************************************************************************************************
100 
101 
102 //*************************************************************************************************
112 template< typename Type // Data type of the matrix
113  , bool SO > // Storage order
114 template< typename Arg > // Min/max argument type
115 inline const DynamicMatrix<Type,SO>
116  Rand< DynamicMatrix<Type,SO> >::generate( size_t m, size_t n, const Arg& min, const Arg& max ) const
117 {
118  DynamicMatrix<Type,SO> matrix( m, n );
119  randomize( matrix, min, max );
120  return matrix;
121 }
123 //*************************************************************************************************
124 
125 
126 //*************************************************************************************************
133 template< typename Type // Data type of the matrix
134  , bool SO > // Storage order
135 inline void Rand< DynamicMatrix<Type,SO> >::randomize( DynamicMatrix<Type,SO>& matrix ) const
136 {
137  using blaze::randomize;
138 
139  const size_t m( matrix.rows() );
140  const size_t n( matrix.columns() );
141 
142  for( size_t i=0UL; i<m; ++i ) {
143  for( size_t j=0UL; j<n; ++j ) {
144  randomize( matrix(i,j) );
145  }
146  }
147 }
149 //*************************************************************************************************
150 
151 
152 //*************************************************************************************************
161 template< typename Type // Data type of the matrix
162  , bool SO > // Storage order
163 template< typename Arg > // Min/max argument type
164 inline void Rand< DynamicMatrix<Type,SO> >::randomize( DynamicMatrix<Type,SO>& matrix,
165  const Arg& min, const Arg& max ) const
166 {
167  using blaze::randomize;
168 
169  const size_t m( matrix.rows() );
170  const size_t n( matrix.columns() );
171 
172  for( size_t i=0UL; i<m; ++i ) {
173  for( size_t j=0UL; j<n; ++j ) {
174  randomize( matrix(i,j), min, max );
175  }
176  }
177 }
179 //*************************************************************************************************
180 
181 
182 
183 
184 //=================================================================================================
185 //
186 // TYPE DEFINITIONS
187 //
188 //=================================================================================================
189 
190 //*************************************************************************************************
195 //*************************************************************************************************
196 
197 
198 //*************************************************************************************************
203 //*************************************************************************************************
204 
205 
206 //*************************************************************************************************
211 //*************************************************************************************************
212 
213 } // namespace blaze
214 
215 #endif