35 #ifndef _BLAZE_MATH_ROWS_H_ 36 #define _BLAZE_MATH_ROWS_H_ 75 class Rand< Rows<MT,SO,true,SF,CRAs...> >
81 template<
typename RT >
84 template<
typename RT,
typename Arg >
100 template<
typename MT
104 template<
typename RT >
105 inline void Rand< Rows<MT,SO,
true,SF,CRAs...> >
::randomize( RT&&
rows )
const 109 using RowsType = RemoveReference_t<RT>;
115 for(
size_t i=0UL; i<
rows.rows(); ++i ) {
116 for(
size_t j=0UL; j<
rows.columns(); ++j ) {
122 for(
size_t j=0UL; j<
rows.columns(); ++j ) {
123 for(
size_t i=0UL; i<
rows.rows(); ++i ) {
142 template<
typename MT
146 template<
typename RT
149 const Arg&
min,
const Arg&
max )
const 153 using RowsType = RemoveReference_t<RT>;
159 for(
size_t i=0UL; i<
rows.rows(); ++i ) {
160 for(
size_t j=0UL; j<
rows.columns(); ++j ) {
166 for(
size_t j=0UL; j<
rows.columns(); ++j ) {
167 for(
size_t i=0UL; i<
rows.rows(); ++i ) {
192 template<
typename MT
196 class Rand< Rows<MT,SO,false,SF,CRAs...> >
202 template<
typename RT >
205 template<
typename RT >
208 template<
typename RT,
typename Arg >
211 template<
typename RT,
typename Arg >
227 template<
typename MT
231 template<
typename RT >
232 inline void Rand< Rows<MT,SO,
false,SF,CRAs...> >
::randomize( RT&&
rows )
const 234 using RowsType = RemoveReference_t<RT>;
235 using ElementType = ElementType_t<RowsType>;
240 const size_t m(
rows.rows() );
241 const size_t n(
rows.columns() );
243 if( m == 0UL || n == 0UL )
return;
245 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.5*m*n ) ) );
248 rows.reserve( nonzeros );
250 while(
rows.nonZeros() < nonzeros ) {
251 rows( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ElementType>();
267 template<
typename MT
271 template<
typename RT >
272 inline void Rand< Rows<MT,SO,
false,SF,CRAs...> >
::randomize( RT&&
rows,
size_t nonzeros )
const 274 using RowsType = RemoveReference_t<RT>;
275 using ElementType = ElementType_t<RowsType>;
280 const size_t m(
rows.rows() );
281 const size_t n(
rows.columns() );
283 if( nonzeros > m*n ) {
287 if( m == 0UL || n == 0UL )
return;
290 rows.reserve( nonzeros );
292 while(
rows.nonZeros() < nonzeros ) {
293 rows( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ElementType>();
309 template<
typename MT
313 template<
typename RT
315 inline void Rand< Rows<MT,SO,
false,SF,CRAs...> >
::randomize( RT&&
rows,
316 const Arg&
min,
const Arg&
max )
const 318 using RowsType = RemoveReference_t<RT>;
319 using ElementType = ElementType_t<RowsType>;
324 const size_t m(
rows.rows() );
325 const size_t n(
rows.columns() );
327 if( m == 0UL || n == 0UL )
return;
329 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.5*m*n ) ) );
332 rows.reserve( nonzeros );
334 while(
rows.nonZeros() < nonzeros ) {
335 rows( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ElementType>(
min,
max );
353 template<
typename MT
357 template<
typename RT
359 inline void Rand< Rows<MT,SO,
false,SF,CRAs...> >
::randomize( RT&&
rows,
size_t nonzeros,
360 const Arg&
min,
const Arg&
max )
const 362 using RowsType = RemoveReference_t<RT>;
363 using ElementType = ElementType_t<RowsType>;
368 const size_t m(
rows.rows() );
369 const size_t n(
rows.columns() );
371 if( nonzeros > m*n ) {
375 if( m == 0UL || n == 0UL )
return;
378 rows.reserve( nonzeros );
380 while(
rows.nonZeros() < nonzeros ) {
381 rows( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ElementType>(
min,
max );
#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.
Header file for the implementation of the Rows view.
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type,...
Definition: DenseMatrix.h:61
decltype(auto) ceil(const DenseMatrix< MT, SO > &dm)
Applies the ceil() function to each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1240
Header file for the sparse matrix SMP implementation.
void randomize(T &&value)
Randomization of a given variable.
Definition: Random.h:929
Implementation of a random number generator.
Constraint on the data type.
Constraint on the data type.
void randomize(T &value) const
Randomization of the given variable with a new value in the range .
Definition: Random.h:292
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1162
Header file for the dense matrix SMP implementation.
Header file for the exception macros of the math module.
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1198
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
Header file for the RemoveReference type trait.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_ROWS_TYPE(T)
Constraint on the data type.In case the given data type T is not a row selection (i....
Definition: Rows.h:61
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type,...
Definition: SparseMatrix.h:61
Header file for the implementation of the Columns view.