35 #ifndef _BLAZE_MATH_SUBMATRIX_H_ 36 #define _BLAZE_MATH_SUBMATRIX_H_ 70 class Rand< Submatrix<MT,AF,SO,true> >
78 template<
typename Arg >
97 inline void Rand< Submatrix<MT,AF,SO,true> >
::randomize( Submatrix<MT,AF,SO,true>&
submatrix )
const 102 for(
size_t i=0UL; i<submatrix.rows(); ++i ) {
103 for(
size_t j=0UL; j<submatrix.columns(); ++j ) {
109 for(
size_t j=0UL; j<submatrix.columns(); ++j ) {
110 for(
size_t i=0UL; i<submatrix.rows(); ++i ) {
129 template<
typename MT
132 template<
typename Arg >
133 inline void Rand< Submatrix<MT,AF,SO,true> >
::randomize( Submatrix<MT,AF,SO,true>& submatrix,
134 const Arg&
min,
const Arg&
max )
const 139 for(
size_t i=0UL; i<submatrix.rows(); ++i ) {
140 for(
size_t j=0UL; j<submatrix.columns(); ++j ) {
146 for(
size_t j=0UL; j<submatrix.columns(); ++j ) {
147 for(
size_t i=0UL; i<submatrix.rows(); ++i ) {
172 template<
typename MT
175 class Rand< Submatrix<MT,AF,SO,false> >
181 inline void randomize( Submatrix<MT,AF,SO,false>& submatrix )
const;
182 inline void randomize( Submatrix<MT,AF,SO,false>& submatrix,
size_t nonzeros )
const;
184 template<
typename Arg >
185 inline void randomize( Submatrix<MT,AF,SO,false>& submatrix,
const Arg& min,
const Arg& max )
const;
187 template<
typename Arg >
188 inline void randomize( Submatrix<MT,AF,SO,false>& submatrix,
size_t nonzeros,
189 const Arg& min,
const Arg& max )
const;
204 template<
typename MT
207 inline void Rand< Submatrix<MT,AF,SO,false> >
::randomize( Submatrix<MT,AF,SO,false>& submatrix )
const 209 using ElementType = ElementType_< Submatrix<MT,AF,SO,false> >;
211 const size_t m( submatrix.rows() );
212 const size_t n( submatrix.columns() );
214 if( m == 0UL || n == 0UL )
return;
216 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.5*m*n ) ) );
219 submatrix.reserve( nonzeros );
221 while( submatrix.nonZeros() < nonzeros ) {
222 submatrix( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ElementType>();
238 template<
typename MT
241 inline void Rand< Submatrix<MT,AF,SO,false> >
::randomize( Submatrix<MT,AF,SO,false>& submatrix,
size_t nonzeros )
const 243 using ElementType = ElementType_< Submatrix<MT,AF,SO,false> >;
245 const size_t m( submatrix.rows() );
246 const size_t n( submatrix.columns() );
248 if( nonzeros > m*n ) {
252 if( m == 0UL || n == 0UL )
return;
255 submatrix.reserve( nonzeros );
257 while( submatrix.nonZeros() < nonzeros ) {
258 submatrix( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ElementType>();
274 template<
typename MT
277 template<
typename Arg >
278 inline void Rand< Submatrix<MT,AF,SO,false> >
::randomize( Submatrix<MT,AF,SO,false>& submatrix,
279 const Arg& min,
const Arg& max )
const 281 using ElementType = ElementType_< Submatrix<MT,AF,SO,false> >;
283 const size_t m( submatrix.rows() );
284 const size_t n( submatrix.columns() );
286 if( m == 0UL || n == 0UL )
return;
288 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.5*m*n ) ) );
291 submatrix.reserve( nonzeros );
293 while( submatrix.nonZeros() < nonzeros ) {
294 submatrix( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ElementType>(
min,
max );
312 template<
typename MT
315 template<
typename Arg >
316 inline void Rand< Submatrix<MT,AF,SO,false> >
::randomize( Submatrix<MT,AF,SO,false>& submatrix,
317 size_t nonzeros,
const Arg& min,
const Arg& max )
const 319 using ElementType = ElementType_< Submatrix<MT,AF,SO,false> >;
321 const size_t m( submatrix.rows() );
322 const size_t n( submatrix.columns() );
324 if( nonzeros > m*n ) {
328 if( m == 0UL || n == 0UL )
return;
331 submatrix.reserve( nonzeros );
333 while( submatrix.nonZeros() < nonzeros ) {
334 submatrix( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ElementType>(
min,
max );
Header file for the implementation of the Submatrix view.
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
void randomize(T &value)
Randomization of a given variable.
Definition: Random.h:927
decltype(auto) ceil(const DenseMatrix< MT, SO > &dm)
Applies the ceil() function to each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1234
Header file for the sparse matrix SMP implementation.
Submatrix< MT, AF > 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:352
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1762
Implementation of a random number generator.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1809
Header file for the implementation of the Subvector view.
void randomize(T &value) const
Randomization of the given variable with a new value in the range .
Definition: Random.h:290
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3081
Header file for the dense matrix SMP implementation.
Header file for the exception macros of the math module.
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71