35 #ifndef _BLAZE_MATH_SPARSESUBVECTOR_H_
36 #define _BLAZE_MATH_SPARSESUBVECTOR_H_
70 class Rand< SparseSubvector<VT,AF,TF> >
79 template<
typename Arg >
82 template<
typename Arg >
83 inline void randomize( SparseSubvector<VT,AF,TF>&
subvector,
size_t nonzeros,
const Arg&
min,
const Arg&
max )
const;
101 inline void Rand< SparseSubvector<VT,AF,TF> >
::randomize( SparseSubvector<VT,AF,TF>&
subvector )
const
105 const size_t size( subvector.size() );
107 if(
size == 0UL )
return;
109 const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.5*
size ) ) );
112 subvector.reserve( nonzeros );
114 while( subvector.nonZeros() < nonzeros ) {
115 subvector[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>();
131 template<
typename VT
134 inline void Rand< SparseSubvector<VT,AF,TF> >
::randomize( SparseSubvector<VT,AF,TF>& subvector,
size_t nonzeros )
const
138 const size_t size( subvector.size() );
140 if( nonzeros >
size ) {
144 if(
size == 0UL )
return;
147 subvector.reserve( nonzeros );
149 while( subvector.nonZeros() < nonzeros ) {
150 subvector[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>();
166 template<
typename VT
169 template<
typename Arg >
170 inline void Rand< SparseSubvector<VT,AF,TF> >
::randomize( SparseSubvector<VT,AF,TF>& subvector,
171 const Arg&
min,
const Arg&
max )
const
175 const size_t size( subvector.size() );
177 if(
size == 0UL )
return;
179 const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.5*
size ) ) );
182 subvector.reserve( nonzeros );
184 while( subvector.nonZeros() < nonzeros ) {
185 subvector[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>( min, max );
203 template<
typename VT
206 template<
typename Arg >
207 inline void Rand< SparseSubvector<VT,AF,TF> >
::randomize( SparseSubvector<VT,AF,TF>& subvector,
208 size_t nonzeros,
const Arg& min,
const Arg& max )
const
212 const size_t size( subvector.size() );
214 if( nonzeros >
size ) {
218 if(
size == 0UL )
return;
221 subvector.reserve( nonzeros );
223 while( subvector.nonZeros() < nonzeros ) {
224 subvector[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>( min, max );
Header file for all restructuring submatrix functions.
#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
Implementation of a random number generator.
Header file for all restructuring subvector functions.
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 SparseSubvector class template.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
SubvectorExprTrait< VT, unaligned >::Type subvector(Vector< VT, TF > &vector, size_t index, size_t size)
Creating a view on a specific subvector of the given vector.
Definition: Subvector.h:143
Header file for the DenseSubvector class template.
Header file for the SparseSubmatrix class template.
Header file for exception macros.