35 #ifndef _BLAZE_MATH_ROW_H_ 36 #define _BLAZE_MATH_ROW_H_ 75 class Rand< Row<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< Row<MT,SO,
true,SF,CRAs...> >
::randomize( RT&&
row )
const 109 using RowType = RemoveReference_t<RT>;
114 for(
size_t i=0UL; i<
row.size(); ++i ) {
131 template<
typename MT
135 template<
typename RT
137 inline void Rand< Row<MT,SO,
true,SF,CRAs...> >
::randomize( RT&&
row,
const Arg&
min,
const Arg&
max )
const 141 using RowType = RemoveReference_t<RT>;
146 for(
size_t i=0UL; i<
row.size(); ++i ) {
169 template<
typename MT
173 class Rand< Row<MT,SO,false,SF,CRAs...> >
179 template<
typename RT >
182 template<
typename RT >
183 inline void randomize( RT&&
row,
size_t nonzeros )
const;
185 template<
typename RT,
typename Arg >
188 template<
typename RT,
typename Arg >
189 inline void randomize( RT&&
row,
size_t nonzeros,
const Arg&
min,
const Arg&
max )
const;
204 template<
typename MT
208 template<
typename RT >
209 inline void Rand< Row<MT,SO,
false,SF,CRAs...> >
::randomize( RT&&
row )
const 211 using RowType = RemoveReference_t<RT>;
212 using ElementType = ElementType_t<RowType>;
217 const size_t size(
row.size() );
219 if(
size == 0UL )
return;
221 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.5*
size ) ) );
224 row.reserve( nonzeros );
226 while(
row.nonZeros() < nonzeros ) {
227 row[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>();
243 template<
typename MT
247 template<
typename RT >
248 inline void Rand< Row<MT,SO,
false,SF,CRAs...> >
::randomize( RT&&
row,
size_t nonzeros )
const 250 using RowType = RemoveReference_t<RT>;
251 using ElementType = ElementType_t<RowType>;
256 const size_t size(
row.size() );
258 if( nonzeros >
size ) {
262 if(
size == 0UL )
return;
265 row.reserve( nonzeros );
267 while(
row.nonZeros() < nonzeros ) {
268 row[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>();
284 template<
typename MT
288 template<
typename RT
290 inline void Rand< Row<MT,SO,
false,SF,CRAs...> >
::randomize( RT&&
row,
const Arg&
min,
const Arg&
max )
const 292 using RowType = RemoveReference_t<RT>;
293 using ElementType = ElementType_t<RowType>;
298 const size_t size(
row.size() );
300 if(
size == 0UL )
return;
302 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.5*
size ) ) );
305 row.reserve( nonzeros );
307 while(
row.nonZeros() < nonzeros ) {
308 row[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>(
min,
max );
326 template<
typename MT
330 template<
typename RT
332 inline void Rand< Row<MT,SO,
false,SF,CRAs...> >
::randomize( RT&&
row,
size_t nonzeros,
333 const Arg&
min,
const Arg&
max )
const 335 using RowType = RemoveReference_t<RT>;
336 using ElementType = ElementType_t<RowType>;
341 const size_t size(
row.size() );
343 if( nonzeros >
size ) {
347 if(
size == 0UL )
return;
350 row.reserve( nonzeros );
352 while(
row.nonZeros() < nonzeros ) {
353 row[ rand<size_t>( 0UL,
size-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.
#define BLAZE_CONSTRAINT_MUST_BE_ROW_TYPE(T)
Constraint on the data type.In case the given data type T is not a row type (i.e. a dense or sparse r...
Definition: Row.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
void randomize(T &&value)
Randomization of a given variable.
Definition: Random.h:929
Implementation of a random number generator.
void randomize(T &value) const
Randomization of the given variable with a new value in the range .
Definition: Random.h:292
Header file for the dense vector SMP implementation.
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
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional vector type,...
Definition: SparseVector.h:61
Constraint on the data type.
Constraint on the data type.
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
Constraint on the data type.
Header file for the implementation of the Column view.
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
Header file for the RemoveReference type trait.
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type,...
Definition: DenseVector.h:61
Header file for the sparse vector SMP implementation.
Header file for the implementation of the Row view.