HybridMatrix.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_HYBRIDMATRIX_H_
36 #define _BLAZE_MATH_HYBRIDMATRIX_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
44 #include <blaze/math/DenseMatrix.h>
47 #include <blaze/system/Precision.h>
48 #include <blaze/util/Random.h>
49 
50 
51 namespace blaze {
52 
53 //=================================================================================================
54 //
55 // RAND SPECIALIZATION
56 //
57 //=================================================================================================
58 
59 //*************************************************************************************************
66 template< typename Type // Data type of the matrix
67  , size_t M // Number of rows
68  , size_t N // Number of columns
69  , bool SO > // Storage order
70 class Rand< HybridMatrix<Type,M,N,SO> >
71 {
72  public:
73  //**Generate functions**************************************************************************
76  inline const HybridMatrix<Type,M,N,SO> generate( size_t m, size_t n ) const;
77 
78  template< typename Arg >
79  inline const HybridMatrix<Type,M,N,SO> generate( size_t m, size_t n, const Arg& min, const Arg& max ) const;
81  //**********************************************************************************************
82 
83  //**Randomize functions*************************************************************************
86  inline void randomize( HybridMatrix<Type,M,N,SO>& matrix ) const;
87 
88  template< typename Arg >
89  inline void randomize( HybridMatrix<Type,M,N,SO>& matrix, const Arg& min, const Arg& max ) const;
91  //**********************************************************************************************
92 };
94 //*************************************************************************************************
95 
96 
97 //*************************************************************************************************
103 template< typename Type // Data type of the matrix
104  , size_t M // Number of rows
105  , size_t N // Number of columns
106  , bool SO > // Storage order
107 inline const HybridMatrix<Type,M,N,SO>
108  Rand< HybridMatrix<Type,M,N,SO> >::generate( size_t m, size_t n ) const
109 {
110  HybridMatrix<Type,M,N,SO> matrix( m, n );
111  randomize( matrix );
112  return matrix;
113 }
115 //*************************************************************************************************
116 
117 
118 //*************************************************************************************************
126 template< typename Type // Data type of the matrix
127  , size_t M // Number of rows
128  , size_t N // Number of columns
129  , bool SO > // Storage order
130 template< typename Arg > // Min/max argument type
131 inline const HybridMatrix<Type,M,N,SO>
132  Rand< HybridMatrix<Type,M,N,SO> >::generate( size_t m, size_t n, const Arg& min, const Arg& max ) const
133 {
134  HybridMatrix<Type,M,N,SO> matrix( m, n );
135  randomize( matrix, min, max );
136  return matrix;
137 }
139 //*************************************************************************************************
140 
141 
142 //*************************************************************************************************
149 template< typename Type // Data type of the matrix
150  , size_t M // Number of rows
151  , size_t N // Number of columns
152  , bool SO > // Storage order
153 inline void Rand< HybridMatrix<Type,M,N,SO> >::randomize( HybridMatrix<Type,M,N,SO>& matrix ) const
154 {
155  using blaze::randomize;
156 
157  const size_t m( matrix.rows() );
158  const size_t n( matrix.columns() );
159 
160  for( size_t i=0UL; i<m; ++i ) {
161  for( size_t j=0UL; j<n; ++j ) {
162  randomize( matrix(i,j) );
163  }
164  }
165 }
167 //*************************************************************************************************
168 
169 
170 //*************************************************************************************************
179 template< typename Type // Data type of the matrix
180  , size_t M // Number of rows
181  , size_t N // Number of columns
182  , bool SO > // Storage order
183 template< typename Arg > // Min/max argument type
184 inline void Rand< HybridMatrix<Type,M,N,SO> >::randomize( HybridMatrix<Type,M,N,SO>& matrix,
185  const Arg& min, const Arg& max ) const
186 {
187  using blaze::randomize;
188 
189  const size_t m( matrix.rows() );
190  const size_t n( matrix.columns() );
191 
192  for( size_t i=0UL; i<m; ++i ) {
193  for( size_t j=0UL; j<n; ++j ) {
194  randomize( matrix(i,j), min, max );
195  }
196  }
197 }
199 //*************************************************************************************************
200 
201 } // namespace blaze
202 
203 #endif
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1649
Header file for the complete HybridVector implementation.
void randomize(T &value)
Randomization of a given variable.
Definition: Random.h:1043
Implementation of a random number generator.
Header file for the floating point precision of the Blaze library.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
void randomize(T &value) const
Randomization of the given variable with a new value in the range .
Definition: Random.h:262
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1602
Header file for the implementation of a fixed-size matrix.
T generate() const
Generation of a random value in the range .
Definition: Random.h:222
Header file for all basic DenseMatrix functionality.
Header file for the complete StaticMatrix implementation.