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>
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 ) ) );
238 template<
typename Type
240 inline void Rand< CompressedVector<Type,TF> >
::randomize( CompressedVector<Type,TF>& vector,
size_t nonzeros )
const 242 const size_t size( vector.size() );
244 if( nonzeros > size ) {
248 if( size == 0UL )
return;
251 vector.reserve( nonzeros );
253 const Indices indices( 0UL, vector.size()-1UL, nonzeros );
255 for(
size_t index : indices ) {
256 vector.append( index, rand<Type>() );
272 template<
typename Type
274 template<
typename Arg >
275 inline void Rand< CompressedVector<Type,TF> >
::randomize( CompressedVector<Type,TF>& vector,
276 const Arg& min,
const Arg& max )
const 278 const size_t size( vector.size() );
280 if( size == 0UL )
return;
282 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.5*size ) ) );
301 template<
typename Type
303 template<
typename Arg >
304 inline void Rand< CompressedVector<Type,TF> >
::randomize( CompressedVector<Type,TF>& vector,
305 size_t nonzeros,
const Arg& min,
const Arg& max )
const 307 const size_t size( vector.size() );
309 if( nonzeros > size ) {
313 if( size == 0UL )
return;
316 vector.reserve( nonzeros );
318 const Indices indices( 0UL, vector.size()-1UL, nonzeros );
320 for(
size_t index : indices ) {
321 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:265
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.
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:1809
void randomize(T &value) const
Randomization of the given variable with a new value in the range .
Definition: Random.h:290
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
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:250
Header file for the complete CompressedMatrix implementation.
Header file for all basic SparseVector functionality.