35 #ifndef _BLAZE_MATH_BAND_H_ 36 #define _BLAZE_MATH_BAND_H_ 74 class Rand< Band<MT,TF,true,MF,CBAs...> >
80 template<
typename BT >
83 template<
typename BT,
typename Arg >
102 , ptrdiff_t... CBAs >
103 template<
typename BT >
104 inline void Rand< Band<MT,TF,
true,MF,CBAs...> >
::randomize( BT&&
band )
const 108 using BandType = RemoveReference_<BT>;
113 for(
size_t i=0UL; i<
band.size(); ++i ) {
130 template<
typename MT
133 , ptrdiff_t... CBAs >
134 template<
typename BT
136 inline void Rand< Band<MT,TF,
true,MF,CBAs...> >
::randomize( BT&&
band,
const Arg&
min,
const Arg&
max )
const 140 using BandType = RemoveReference_<BT>;
145 for(
size_t i=0UL; i<
band.size(); ++i ) {
168 template<
typename MT
171 , ptrdiff_t... CBAs >
172 class Rand< Band<MT,TF,false,MF,CBAs...> >
178 template<
typename BT >
181 template<
typename BT >
184 template<
typename BT,
typename Arg >
185 inline void randomize( BT&&
band,
const Arg& min,
const Arg& max )
const;
187 template<
typename BT,
typename Arg >
188 inline void randomize( BT&&
band,
size_t nonzeros,
const Arg& min,
const Arg& max )
const;
203 template<
typename MT
206 , ptrdiff_t... CBAs >
207 template<
typename BT >
208 inline void Rand< Band<MT,TF,
false,MF,CBAs...> >
::randomize( BT&&
band )
const 210 using BandType = RemoveReference_<BT>;
218 if(
size == 0UL )
return;
220 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.5*
size ) ) );
223 band.reserve( nonzeros );
225 while(
band.nonZeros() < nonzeros ) {
226 band[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>();
242 template<
typename MT
245 , ptrdiff_t... CBAs >
246 template<
typename BT >
247 inline void Rand< Band<MT,TF,
false,MF,CBAs...> >
::randomize( BT&&
band,
size_t nonzeros )
const 249 using BandType = RemoveReference_<BT>;
257 if( nonzeros >
size ) {
261 if(
size == 0UL )
return;
264 band.reserve( nonzeros );
266 while(
band.nonZeros() < nonzeros ) {
267 band[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>();
283 template<
typename MT
286 , ptrdiff_t... CBAs >
287 template<
typename BT
289 inline void Rand< Band<MT,TF,
false,MF,CBAs...> >
::randomize( BT&&
band,
const Arg& min,
const Arg& max )
const 291 using BandType = RemoveReference_<BT>;
299 if(
size == 0UL )
return;
301 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.5*
size ) ) );
304 band.reserve( nonzeros );
306 while(
band.nonZeros() < nonzeros ) {
307 band[ rand<size_t>( 0UL,
size-1UL ) ] = rand<ElementType>( min, max );
325 template<
typename MT
328 , ptrdiff_t... CBAs >
329 template<
typename BT
331 inline void Rand< Band<MT,TF,
false,MF,CBAs...> >
::randomize( BT&&
band,
size_t nonzeros,
332 const Arg& min,
const Arg& max )
const 334 using BandType = RemoveReference_<BT>;
342 if( nonzeros >
size ) {
346 if(
size == 0UL )
return;
349 band.reserve( nonzeros );
351 while(
band.nonZeros() < nonzeros ) {
352 band[ 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
Header file for the implementation of the Band view.
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_BAND_TYPE(T)
Constraint on the data type.In case the given data type T is not a band type (i.e. a dense or sparse band), a compilation error is created.
Definition: Band.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
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
Constraint on the data type.
Header file for the exception macros of the math module.
Constraint on the data type.
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:134
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 sparse vector SMP implementation.