35 #ifndef _BLAZE_MATH_COMPRESSEDVECTOR_H_
36 #define _BLAZE_MATH_COMPRESSEDVECTOR_H_
67 template<
typename Type
69 class Rand< CompressedVector<Type,TF> >
75 inline const CompressedVector<Type,TF>
generate(
size_t size )
const;
76 inline const CompressedVector<Type,TF>
generate(
size_t size,
size_t nonzeros )
const;
78 template<
typename Arg >
79 inline const CompressedVector<Type,TF>
generate(
size_t size,
const Arg&
min,
const Arg&
max )
const;
81 template<
typename Arg >
82 inline const CompressedVector<Type,TF>
generate(
size_t size,
size_t nonzeros,
const Arg&
min,
const Arg&
max )
const;
89 inline void randomize( CompressedVector<Type,TF>& vector )
const;
90 inline void randomize( CompressedVector<Type,TF>& vector,
size_t nonzeros )
const;
92 template<
typename Arg >
93 inline void randomize( CompressedVector<Type,TF>& vector,
const Arg&
min,
const Arg&
max )
const;
95 template<
typename Arg >
96 inline void randomize( CompressedVector<Type,TF>& vector,
size_t nonzeros,
const Arg&
min,
const Arg&
max )
const;
111 template<
typename Type
113 inline const CompressedVector<Type,TF>
114 Rand< CompressedVector<Type,TF> >::generate(
size_t size )
const
116 CompressedVector<Type,TF> vector( size );
134 template<
typename Type
136 inline const CompressedVector<Type,TF>
137 Rand< CompressedVector<Type,TF> >::generate(
size_t size,
size_t nonzeros )
const
139 if( nonzeros > size ) {
143 CompressedVector<Type,TF> vector( size, nonzeros );
161 template<
typename Type
163 template<
typename Arg >
164 inline const CompressedVector<Type,TF>
165 Rand< CompressedVector<Type,TF> >::generate(
size_t size,
const Arg&
min,
const Arg&
max )
const
167 CompressedVector<Type,TF> vector( size );
187 template<
typename Type
189 template<
typename Arg >
190 inline const CompressedVector<Type,TF>
191 Rand< CompressedVector<Type,TF> >::generate(
size_t size,
size_t nonzeros,
const Arg&
min,
const Arg&
max )
const
193 if( nonzeros > size ) {
197 CompressedVector<Type,TF> vector( size, nonzeros );
213 template<
typename Type
215 inline void Rand< CompressedVector<Type,TF> >
::randomize( CompressedVector<Type,TF>& vector )
const
217 const size_t size( vector.size() );
219 if( size == 0UL )
return;
221 const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.5*size ) ) );
224 vector.reserve( nonzeros );
226 while( vector.nonZeros() < nonzeros ) {
227 vector[ rand<size_t>( 0UL, size-1UL ) ] = rand<Type>();
243 template<
typename Type
245 inline void Rand< CompressedVector<Type,TF> >
::randomize( CompressedVector<Type,TF>& vector,
size_t nonzeros )
const
247 const size_t size( vector.size() );
249 if( nonzeros > size ) {
253 if( size == 0UL )
return;
256 vector.reserve( nonzeros );
258 while( vector.nonZeros() < nonzeros ) {
259 vector[ rand<size_t>( 0UL, size-1UL ) ] = rand<Type>();
275 template<
typename Type
277 template<
typename Arg >
278 inline void Rand< CompressedVector<Type,TF> >
::randomize( CompressedVector<Type,TF>& vector,
279 const Arg& min,
const Arg& max )
const
281 const size_t size( vector.size() );
283 if( size == 0UL )
return;
285 const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.5*size ) ) );
288 vector.reserve( nonzeros );
290 while( vector.nonZeros() < nonzeros ) {
291 vector[ rand<size_t>( 0UL, size-1UL ) ] = rand<Type>( min, max );
309 template<
typename Type
311 template<
typename Arg >
312 inline void Rand< CompressedVector<Type,TF> >
::randomize( CompressedVector<Type,TF>& vector,
313 size_t nonzeros,
const Arg& min,
const Arg& max )
const
315 const size_t size( vector.size() );
317 if( nonzeros > size ) {
321 if( size == 0UL )
return;
324 vector.reserve( nonzeros );
326 while( vector.nonZeros() < nonzeros ) {
327 vector[ rand<size_t>( 0UL, size-1UL ) ] = 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 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
CompressedVector< float, false > CVecNf
Compressed single precision vector.
Definition: CompressedVector.h:346
Implementation of a random number generator.
Implementation of an arbitrarily sized compressed vector.
CompressedVector< real_t, false > CVecN
Compressed vector with system-specific precision.
Definition: CompressedVector.h:362
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:260
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1682
CompressedVector< double, false > CVecNd
Compressed double precision vector.
Definition: CompressedVector.h:354
T generate() const
Generation of a random value in the range .
Definition: Random.h:220
Header file for the complete CompressedMatrix implementation.
Header file for all basic SparseVector functionality.
Header file for exception macros.
Efficient implementation of an arbitrary sized sparse vector.The CompressedVector class is the repres...
Definition: CompressedVector.h:187