35 #ifndef _BLAZE_MATH_SPARSECOLUMN_H_
36 #define _BLAZE_MATH_SPARSECOLUMN_H_
68 class Rand< SparseColumn<MT,SO> >
75 inline void randomize( SparseColumn<MT,SO>&
column,
size_t nonzeros )
const;
77 template<
typename Arg >
80 template<
typename Arg >
81 inline void randomize( SparseColumn<MT,SO>&
column,
size_t nonzeros,
const Arg&
min,
const Arg&
max )
const;
98 inline void Rand< SparseColumn<MT,SO> >
::randomize( SparseColumn<MT,SO>&
column )
const
102 const size_t size( column.size() );
104 if(
size == 0UL )
return;
106 const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.5*
size ) ) );
109 column.reserve( nonzeros );
111 while( column.nonZeros() < nonzeros ) {
112 column[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>();
128 template<
typename MT
130 inline void Rand< SparseColumn<MT,SO> >
::randomize( SparseColumn<MT,SO>& column,
size_t nonzeros )
const
134 const size_t size( column.size() );
136 if( nonzeros >
size ) {
140 if(
size == 0UL )
return;
143 column.reserve( nonzeros );
145 while( column.nonZeros() < nonzeros ) {
146 column[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>();
162 template<
typename MT
164 template<
typename Arg >
165 inline void Rand< SparseColumn<MT,SO> >
::randomize( SparseColumn<MT,SO>& column,
166 const Arg&
min,
const Arg&
max )
const
170 const size_t size( column.size() );
172 if(
size == 0UL )
return;
174 const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.5*
size ) ) );
177 column.reserve( nonzeros );
179 while( column.nonZeros() < nonzeros ) {
180 column[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>( min, max );
198 template<
typename MT
200 template<
typename Arg >
201 inline void Rand< SparseColumn<MT,SO> >
::randomize( SparseColumn<MT,SO>& column,
size_t nonzeros,
202 const Arg& min,
const Arg& max )
const
206 const size_t size( column.size() );
208 if( nonzeros >
size ) {
212 if(
size == 0UL )
return;
215 column.reserve( nonzeros );
217 while( column.nonZeros() < nonzeros ) {
218 column[ 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 exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1729
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:252
void randomize(T &value)
Randomization of a given variable.
Definition: Random.h:1041
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename ColumnExprTrait< MT >::Type >::Type column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:107
Implementation of a random number generator.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
void randomize(T &value) const
Randomization of the given variable with a new value in the range .
Definition: Random.h:260
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1682
Header file for the SparseColumn class template.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
Header file for all restructuring column functions.
Header file for the SparseRow class template.
Header file for exception macros.
Header file for all restructuring row functions.