35 #ifndef _BLAZE_MATH_COMPRESSEDVECTOR_H_
36 #define _BLAZE_MATH_COMPRESSEDVECTOR_H_
68 template<
typename Type
70 class Rand< CompressedVector<Type,TF> >
76 inline const CompressedVector<Type,TF>
generate(
size_t size )
const;
77 inline const CompressedVector<Type,TF>
generate(
size_t size,
size_t nonzeros )
const;
79 template<
typename Arg >
80 inline const CompressedVector<Type,TF>
generate(
size_t size,
const Arg&
min,
const Arg&
max )
const;
82 template<
typename Arg >
83 inline const CompressedVector<Type,TF>
generate(
size_t size,
size_t nonzeros,
const Arg&
min,
const Arg&
max )
const;
90 inline void randomize( CompressedVector<Type,TF>& vector )
const;
91 inline void randomize( CompressedVector<Type,TF>& vector,
size_t nonzeros )
const;
93 template<
typename Arg >
94 inline void randomize( CompressedVector<Type,TF>& vector,
const Arg&
min,
const Arg&
max )
const;
96 template<
typename Arg >
97 inline void randomize( CompressedVector<Type,TF>& vector,
size_t nonzeros,
const Arg&
min,
const Arg&
max )
const;
112 template<
typename Type
114 inline const CompressedVector<Type,TF>
115 Rand< CompressedVector<Type,TF> >::generate(
size_t size )
const
117 CompressedVector<Type,TF> vector( size );
135 template<
typename Type
137 inline const CompressedVector<Type,TF>
138 Rand< CompressedVector<Type,TF> >::generate(
size_t size,
size_t nonzeros )
const
140 if( nonzeros > size ) {
144 CompressedVector<Type,TF> vector( size, nonzeros );
162 template<
typename Type
164 template<
typename Arg >
165 inline const CompressedVector<Type,TF>
166 Rand< CompressedVector<Type,TF> >::generate(
size_t size,
const Arg&
min,
const Arg&
max )
const
168 CompressedVector<Type,TF> vector( size );
188 template<
typename Type
190 template<
typename Arg >
191 inline const CompressedVector<Type,TF>
192 Rand< CompressedVector<Type,TF> >::generate(
size_t size,
size_t nonzeros,
const Arg&
min,
const Arg&
max )
const
194 if( nonzeros > size ) {
198 CompressedVector<Type,TF> vector( size, nonzeros );
214 template<
typename Type
216 inline void Rand< CompressedVector<Type,TF> >
::randomize( CompressedVector<Type,TF>& vector )
const
218 const size_t size( vector.size() );
220 if( size == 0UL )
return;
222 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.5*size ) ) );
239 template<
typename Type
241 inline void Rand< CompressedVector<Type,TF> >
::randomize( CompressedVector<Type,TF>& vector,
size_t nonzeros )
const
243 const size_t size( vector.size() );
245 if( nonzeros > size ) {
249 if( size == 0UL )
return;
252 vector.reserve( nonzeros );
254 const Indices indices( 0UL, vector.size()-1UL, nonzeros );
256 for(
size_t index : indices ) {
257 vector.append( index, rand<Type>() );
273 template<
typename Type
275 template<
typename Arg >
276 inline void Rand< CompressedVector<Type,TF> >
::randomize( CompressedVector<Type,TF>& vector,
277 const Arg& min,
const Arg& max )
const
279 const size_t size( vector.size() );
281 if( size == 0UL )
return;
283 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.5*size ) ) );
302 template<
typename Type
304 template<
typename Arg >
305 inline void Rand< CompressedVector<Type,TF> >
::randomize( CompressedVector<Type,TF>& vector,
306 size_t nonzeros,
const Arg& min,
const Arg& max )
const
308 const size_t size( vector.size() );
310 if( nonzeros > size ) {
314 if( size == 0UL )
return;
317 vector.reserve( nonzeros );
319 const Indices indices( 0UL, vector.size()-1UL, nonzeros );
321 for(
size_t index : indices ) {
322 vector.append( index, rand<Type>( min, max ) );
Header file for the implementation of a fixed-size vector.
#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
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:258
void randomize(T &value)
Randomization of a given variable.
Definition: Random.h:926
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1669
Implementation of a random number generator.
Implementation of an arbitrarily sized compressed vector.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1716
Header file for the floating point precision of the Blaze library.
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:289
Header file for the exception macros of the math module.
Header file for the Indices class.
T generate() const
Generation of a random value in the range .
Definition: Random.h:249
Header file for the complete CompressedMatrix implementation.
Header file for all basic SparseVector functionality.
const DMatForEachExpr< MT, Ceil, SO > ceil(const DenseMatrix< MT, SO > &dm)
Applies the ceil() function to each single element of the dense matrix dm.
Definition: DMatForEachExpr.h:1130