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 
48 #include <blaze/util/Random.h>
49 
50 
51 namespace blaze {
52 
53 //=================================================================================================
54 //
55 // RAND SPECIALIZATION
56 //
57 //=================================================================================================
58 
59 //*************************************************************************************************
66 template< typename MT // Type of the dense matrix
67  , bool AF // Alignment flag
68  , bool SO > // Storage order
69 class Rand< DenseSubmatrix<MT,AF,SO> >
70 {
71  public:
72  //**Randomize functions*************************************************************************
75  inline void randomize( DenseSubmatrix<MT,AF,SO>& submatrix ) const;
76 
77  template< typename Arg >
78  inline void randomize( DenseSubmatrix<MT,AF,SO>& submatrix, const Arg& min, const Arg& max ) const;
80  //**********************************************************************************************
81 };
83 //*************************************************************************************************
84 
85 
86 //*************************************************************************************************
93 template< typename MT // Type of the dense matrix
94  , bool AF // Alignment flag
95  , bool SO > // Storage order
96 inline void Rand< DenseSubmatrix<MT,AF,SO> >::randomize( DenseSubmatrix<MT,AF,SO>& submatrix ) const
97 {
98  using blaze::randomize;
99 
100  if( SO == rowMajor ) {
101  for( size_t i=0UL; i<submatrix.rows(); ++i ) {
102  for( size_t j=0UL; j<submatrix.columns(); ++j ) {
103  randomize( submatrix(i,j) );
104  }
105  }
106  }
107  else {
108  for( size_t j=0UL; j<submatrix.columns(); ++j ) {
109  for( size_t i=0UL; i<submatrix.rows(); ++i ) {
110  randomize( submatrix(i,j) );
111  }
112  }
113  }
114 }
116 //*************************************************************************************************
117 
118 
119 //*************************************************************************************************
128 template< typename MT // Type of the dense matrix
129  , bool AF // Alignment flag
130  , bool SO > // Storage order
131 template< typename Arg > // Min/max argument type
132 inline void Rand< DenseSubmatrix<MT,AF,SO> >::randomize( DenseSubmatrix<MT,AF,SO>& submatrix,
133  const Arg& min, const Arg& max ) const
134 {
135  using blaze::randomize;
136 
137  if( SO == rowMajor ) {
138  for( size_t i=0UL; i<submatrix.rows(); ++i ) {
139  for( size_t j=0UL; j<submatrix.columns(); ++j ) {
140  randomize( submatrix(i,j), min, max );
141  }
142  }
143  }
144  else {
145  for( size_t j=0UL; j<submatrix.columns(); ++j ) {
146  for( size_t i=0UL; i<submatrix.rows(); ++i ) {
147  randomize( submatrix(i,j), min, max );
148  }
149  }
150  }
151 }
153 //*************************************************************************************************
154 
155 } // namespace blaze
156 
157 #endif
Header file for all restructuring submatrix functions.
void randomize(T &value)
Randomization of a given variable.
Definition: Random.h:1043
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 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:134
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
Header file for the SparseSubmatrix class template.