All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DenseSubmatrix.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_DENSESUBMATRIX_H_
36 #define _BLAZE_MATH_DENSESUBMATRIX_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
50 #include <blaze/util/Random.h>
51 
52 
53 namespace blaze {
54 
55 //=================================================================================================
56 //
57 // RAND SPECIALIZATION
58 //
59 //=================================================================================================
60 
61 //*************************************************************************************************
68 template< typename MT // Type of the dense matrix
69  , bool AF // Alignment flag
70  , bool SO > // Storage order
71 class Rand< DenseSubmatrix<MT,AF,SO> >
72 {
73  public:
74  //**Randomize functions*************************************************************************
77  inline void randomize( DenseSubmatrix<MT,AF,SO>& submatrix ) const;
78 
79  template< typename Arg >
80  inline void randomize( DenseSubmatrix<MT,AF,SO>& submatrix, const Arg& min, const Arg& max ) const;
82  //**********************************************************************************************
83 };
85 //*************************************************************************************************
86 
87 
88 //*************************************************************************************************
95 template< typename MT // Type of the dense matrix
96  , bool AF // Alignment flag
97  , bool SO > // Storage order
98 inline void Rand< DenseSubmatrix<MT,AF,SO> >::randomize( DenseSubmatrix<MT,AF,SO>& submatrix ) const
99 {
100  using blaze::randomize;
101 
102  if( SO == rowMajor ) {
103  for( size_t i=0UL; i<submatrix.rows(); ++i ) {
104  for( size_t j=0UL; j<submatrix.columns(); ++j ) {
105  randomize( submatrix(i,j) );
106  }
107  }
108  }
109  else {
110  for( size_t j=0UL; j<submatrix.columns(); ++j ) {
111  for( size_t i=0UL; i<submatrix.rows(); ++i ) {
112  randomize( submatrix(i,j) );
113  }
114  }
115  }
116 }
118 //*************************************************************************************************
119 
120 
121 //*************************************************************************************************
130 template< typename MT // Type of the dense matrix
131  , bool AF // Alignment flag
132  , bool SO > // Storage order
133 template< typename Arg > // Min/max argument type
134 inline void Rand< DenseSubmatrix<MT,AF,SO> >::randomize( DenseSubmatrix<MT,AF,SO>& submatrix,
135  const Arg& min, const Arg& max ) const
136 {
137  using blaze::randomize;
138 
139  if( SO == rowMajor ) {
140  for( size_t i=0UL; i<submatrix.rows(); ++i ) {
141  for( size_t j=0UL; j<submatrix.columns(); ++j ) {
142  randomize( submatrix(i,j), min, max );
143  }
144  }
145  }
146  else {
147  for( size_t j=0UL; j<submatrix.columns(); ++j ) {
148  for( size_t i=0UL; i<submatrix.rows(); ++i ) {
149  randomize( submatrix(i,j), min, max );
150  }
151  }
152  }
153 }
155 //*************************************************************************************************
156 
157 } // namespace blaze
158 
159 #endif
Header file for all restructuring submatrix functions.
void randomize(T &value)
Randomization of a given variable.
Definition: Random.h:1043
Header file for the sparse matrix SMP implementation.
Implementation of a random number generator.
Header file for all restructuring subvector functions.
Header file for the DenseSubmatrix class template.
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 dense matrix SMP implementation.
Header file for the DenseSubvector class template.
SubmatrixExprTrait< MT, unaligned >::Type submatrix(Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:136
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
Header file for the SparseSubmatrix class template.