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
decltype(auto) ceil(const DenseMatrix< MT, SO > &dm)
Applies the ceil() function to each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1240
void randomize(T &&value)
Randomization of a given variable.
Definition: Random.h:929
Implementation of a random number generator.
Implementation of an arbitrarily sized compressed vector.
void randomize(T &value) const
Randomization of the given variable with a new value in the range .
Definition: Random.h:292
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1162
Header file for the complete ZeroVector implementation.
Header file for the exception macros of the math module.
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1198
Header file for the Indices class.
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
T generate() const
Generation of a random value in the range .
Definition: Random.h:252
Header file for the complete CompressedMatrix implementation.
Header file for all basic SparseVector functionality.