35 #ifndef _BLAZE_MATH_DENSESUBVECTOR_H_ 36 #define _BLAZE_MATH_DENSESUBVECTOR_H_ 70 class Rand< Subvector<VT,AF,TF,true> >
78 template<
typename Arg >
97 inline void Rand< Subvector<VT,AF,TF,true> >
::randomize( Subvector<VT,AF,TF,true>&
subvector )
const 101 for(
size_t i=0UL; i<subvector.size(); ++i ) {
118 template<
typename VT
121 template<
typename Arg >
122 inline void Rand< Subvector<VT,AF,TF,true> >
::randomize( Subvector<VT,AF,TF,true>& subvector,
123 const Arg&
min,
const Arg&
max )
const 127 for(
size_t i=0UL; i<subvector.size(); ++i ) {
150 template<
typename VT
153 class Rand< Subvector<VT,AF,TF,false> >
159 inline void randomize( Subvector<VT,AF,TF,false>& subvector )
const;
160 inline void randomize( Subvector<VT,AF,TF,false>& subvector,
size_t nonzeros )
const;
162 template<
typename Arg >
163 inline void randomize( Subvector<VT,AF,TF,false>& subvector,
const Arg& min,
const Arg& max )
const;
165 template<
typename Arg >
166 inline void randomize( Subvector<VT,AF,TF,false>& subvector,
size_t nonzeros,
const Arg& min,
const Arg& max )
const;
181 template<
typename VT
184 inline void Rand< Subvector<VT,AF,TF,false> >
::randomize( Subvector<VT,AF,TF,false>& subvector )
const 186 using ElementType = ElementType_< Subvector<VT,AF,TF,false> >;
188 const size_t size( subvector.size() );
190 if(
size == 0UL )
return;
192 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.5*
size ) ) );
195 subvector.reserve( nonzeros );
197 while( subvector.nonZeros() < nonzeros ) {
198 subvector[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>();
214 template<
typename VT
217 inline void Rand< Subvector<VT,AF,TF,false> >
::randomize( Subvector<VT,AF,TF,false>& subvector,
size_t nonzeros )
const 219 using ElementType = ElementType_< Subvector<VT,AF,TF,false> >;
221 const size_t size( subvector.size() );
223 if( nonzeros >
size ) {
227 if(
size == 0UL )
return;
230 subvector.reserve( nonzeros );
232 while( subvector.nonZeros() < nonzeros ) {
233 subvector[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>();
249 template<
typename VT
252 template<
typename Arg >
253 inline void Rand< Subvector<VT,AF,TF,false> >
::randomize( Subvector<VT,AF,TF,false>& subvector,
254 const Arg& min,
const Arg& max )
const 256 using ElementType = ElementType_< Subvector<VT,AF,TF,false> >;
258 const size_t size( subvector.size() );
260 if(
size == 0UL )
return;
262 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.5*
size ) ) );
265 subvector.reserve( nonzeros );
267 while( subvector.nonZeros() < nonzeros ) {
268 subvector[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>( min, max );
286 template<
typename VT
289 template<
typename Arg >
290 inline void Rand< Subvector<VT,AF,TF,false> >
::randomize( Subvector<VT,AF,TF,false>& subvector,
291 size_t nonzeros,
const Arg& min,
const Arg& max )
const 293 using ElementType = ElementType_< Subvector<VT,AF,TF,false> >;
295 const size_t size( subvector.size() );
297 if( nonzeros >
size ) {
301 if(
size == 0UL )
return;
304 subvector.reserve( nonzeros );
306 while( subvector.nonZeros() < nonzeros ) {
307 subvector[ rand<size_t>( 0UL,
size-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.
Subvector< VT, AF > 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:322
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:265
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
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
Header file for the dense vector SMP implementation.
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 exception macros of the math module.
Header file for the sparse vector SMP implementation.