35 #ifndef _BLAZE_MATH_ELEMENTS_H_ 36 #define _BLAZE_MATH_ELEMENTS_H_ 73 class Rand< Elements<VT,TF,true,CEAs...> >
79 template<
typename ET >
82 template<
typename ET,
typename Arg >
101 template<
typename ET >
106 using ElementsType = RemoveReference_<ET>;
111 for(
size_t i=0UL; i<
elements.size(); ++i ) {
128 template<
typename VT
131 template<
typename ET
137 using ElementsType = RemoveReference_<ET>;
142 for(
size_t i=0UL; i<
elements.size(); ++i ) {
165 template<
typename VT
168 class Rand< Elements<VT,TF,false,CEAs...> >
174 template<
typename ET >
177 template<
typename ET >
180 template<
typename ET,
typename Arg >
183 template<
typename ET,
typename Arg >
184 inline void randomize( ET&&
elements,
size_t nonzeros,
const Arg& min,
const Arg& max )
const;
199 template<
typename VT
202 template<
typename ET >
205 using ElementsType = RemoveReference_<ET>;
213 if(
size == 0UL )
return;
215 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.5*
size ) ) );
220 while(
elements.nonZeros() < nonzeros ) {
221 elements[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>();
237 template<
typename VT
240 template<
typename ET >
241 inline void Rand< Elements<VT,TF,
false,CEAs...> >
::randomize( ET&&
elements,
size_t nonzeros )
const 243 using ElementsType = RemoveReference_<ET>;
251 if( nonzeros >
size ) {
255 if(
size == 0UL )
return;
260 while(
elements.nonZeros() < nonzeros ) {
261 elements[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>();
277 template<
typename VT
280 template<
typename ET
283 const Arg& min,
const Arg& max )
const 285 using ElementsType = RemoveReference_<ET>;
293 if(
size == 0UL )
return;
295 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.5*
size ) ) );
300 while(
elements.nonZeros() < nonzeros ) {
301 elements[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>( min, max );
319 template<
typename VT
322 template<
typename ET
324 inline void Rand< Elements<VT,TF,
false,CEAs...> >
::randomize( ET&&
elements,
size_t nonzeros,
325 const Arg& min,
const Arg& max )
const 327 using ElementsType = RemoveReference_<ET>;
335 if( nonzeros >
size ) {
339 if(
size == 0UL )
return;
344 while(
elements.nonZeros() < nonzeros ) {
345 elements[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>( min, max );
#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
Header file for auxiliary alias declarations.
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
#define BLAZE_CONSTRAINT_MUST_BE_ELEMENTS_TYPE(T)
Constraint on the data type.In case the given data type T is not an element selection (i...
Definition: Elements.h:61
void randomize(T &&value)
Randomization of a given variable.
Definition: Random.h:929
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1903
Constraint on the data type.
Implementation of a random number generator.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1950
void randomize(T &value) const
Randomization of the given variable with a new value in the range .
Definition: Random.h:292
Header file for the dense vector SMP implementation.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3079
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional vector type...
Definition: SparseVector.h:61
decltype(auto) elements(Vector< VT, TF > &vector, REAs... args)
Creating a view on a selection of elements of the given vector.
Definition: Elements.h:134
Constraint on the data type.
Header file for the exception macros of the math module.
Constraint on the data type.
Header file for the RemoveReference type trait.
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:61
Header file for the implementation of the Elements view.
Header file for the sparse vector SMP implementation.