35 #ifndef _BLAZE_MATH_COMPRESSEDVECTOR_H_
36 #define _BLAZE_MATH_COMPRESSEDVECTOR_H_
66 template<
typename Type
68 class Rand< CompressedVector<Type,TF> >
74 inline const CompressedVector<Type,TF>
generate(
size_t size )
const;
75 inline const CompressedVector<Type,TF>
generate(
size_t size,
size_t nonzeros )
const;
77 template<
typename Arg >
78 inline const CompressedVector<Type,TF>
generate(
size_t size,
const Arg&
min,
const Arg&
max )
const;
80 template<
typename Arg >
81 inline const CompressedVector<Type,TF>
generate(
size_t size,
size_t nonzeros,
const Arg&
min,
const Arg&
max )
const;
88 inline void randomize( CompressedVector<Type,TF>& vector )
const;
89 inline void randomize( CompressedVector<Type,TF>& vector,
size_t nonzeros )
const;
91 template<
typename Arg >
92 inline void randomize( CompressedVector<Type,TF>& vector,
const Arg&
min,
const Arg&
max )
const;
94 template<
typename Arg >
95 inline void randomize( CompressedVector<Type,TF>& vector,
size_t nonzeros,
const Arg&
min,
const Arg&
max )
const;
110 template<
typename Type
112 inline const CompressedVector<Type,TF>
113 Rand< CompressedVector<Type,TF> >::generate(
size_t size )
const
115 CompressedVector<Type,TF> vector( size );
133 template<
typename Type
135 inline const CompressedVector<Type,TF>
136 Rand< CompressedVector<Type,TF> >::generate(
size_t size,
size_t nonzeros )
const
138 if( nonzeros > size )
139 throw std::invalid_argument(
"Invalid number of non-zero elements" );
141 CompressedVector<Type,TF> vector( size, nonzeros );
159 template<
typename Type
161 template<
typename Arg >
162 inline const CompressedVector<Type,TF>
163 Rand< CompressedVector<Type,TF> >::generate(
size_t size,
const Arg&
min,
const Arg&
max )
const
165 CompressedVector<Type,TF> vector( size );
185 template<
typename Type
187 template<
typename Arg >
188 inline const CompressedVector<Type,TF>
189 Rand< CompressedVector<Type,TF> >::generate(
size_t size,
size_t nonzeros,
const Arg&
min,
const Arg&
max )
const
191 if( nonzeros > size )
192 throw std::invalid_argument(
"Invalid number of non-zero elements" );
194 CompressedVector<Type,TF> vector( size, nonzeros );
210 template<
typename Type
212 inline void Rand< CompressedVector<Type,TF> >
::randomize( CompressedVector<Type,TF>& vector )
const
214 const size_t size( vector.size() );
216 if( size == 0UL )
return;
218 const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.5*size ) ) );
221 vector.reserve( nonzeros );
223 while( vector.nonZeros() < nonzeros ) {
224 vector[ rand<size_t>( 0UL, size-1UL ) ] = rand<Type>();
240 template<
typename Type
242 inline void Rand< CompressedVector<Type,TF> >
::randomize( CompressedVector<Type,TF>& vector,
size_t nonzeros )
const
244 const size_t size( vector.size() );
246 if( nonzeros > size )
247 throw std::invalid_argument(
"Invalid number of non-zero elements" );
249 if( size == 0UL )
return;
252 vector.reserve( nonzeros );
254 while( vector.nonZeros() < nonzeros ) {
255 vector[ rand<size_t>( 0UL, size-1UL ) ] = rand<Type>();
271 template<
typename Type
273 template<
typename Arg >
274 inline void Rand< CompressedVector<Type,TF> >
::randomize( CompressedVector<Type,TF>& vector,
275 const Arg& min,
const Arg& max )
const
277 const size_t size( vector.size() );
279 if( size == 0UL )
return;
281 const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.5*size ) ) );
284 vector.reserve( nonzeros );
286 while( vector.nonZeros() < nonzeros ) {
287 vector[ rand<size_t>( 0UL, size-1UL ) ] = rand<Type>( min, max );
305 template<
typename Type
307 template<
typename Arg >
308 inline void Rand< CompressedVector<Type,TF> >
::randomize( CompressedVector<Type,TF>& vector,
309 size_t nonzeros,
const Arg& min,
const Arg& max )
const
311 const size_t size( vector.size() );
313 if( nonzeros > size )
314 throw std::invalid_argument(
"Invalid number of non-zero elements" );
316 if( size == 0UL )
return;
319 vector.reserve( nonzeros );
321 while( vector.nonZeros() < nonzeros ) {
322 vector[ rand<size_t>( 0UL, size-1UL ) ] = rand<Type>( min, max );
Header file for the implementation of a fixed-size vector.
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1649
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:264
void randomize(T &value)
Randomization of a given variable.
Definition: Random.h:1043
CompressedVector< float, false > CVecNf
Compressed single precision vector.
Definition: CompressedVector.h:341
Implementation of a random number generator.
Implementation of an arbitrarily sized compressed vector.
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:262
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1602
CompressedVector< real, false > CVecN
Compressed vector with system-specific precision.
Definition: CompressedVector.h:357
CompressedVector< double, false > CVecNd
Compressed double precision vector.
Definition: CompressedVector.h:349
T generate() const
Generation of a random value in the range .
Definition: Random.h:222
Header file for the complete CompressedMatrix implementation.
Header file for all basic SparseVector functionality.
Efficient implementation of an arbitrary sized sparse vector.The CompressedVector class is the repres...
Definition: CompressedVector.h:188