35 #ifndef _BLAZE_MATH_STRICTLYLOWERMATRIX_H_ 36 #define _BLAZE_MATH_STRICTLYLOWERMATRIX_H_ 82 class Rand< StrictlyLowerMatrix<MT,SO,DF> >
88 inline const StrictlyLowerMatrix<MT,SO,DF>
generate()
const;
89 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
size_t n )
const;
90 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const;
92 template<
typename Arg >
93 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const;
95 template<
typename Arg >
96 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const;
98 template<
typename Arg >
99 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros,
100 const Arg&
min,
const Arg&
max )
const;
107 inline void randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix )
const;
108 inline void randomize( StrictlyLowerMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const;
109 inline void randomize( StrictlyLowerMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const;
111 template<
typename Arg >
112 inline void randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const;
114 template<
typename Arg >
115 inline void randomize( StrictlyLowerMatrix<MT,false,DF>& matrix,
size_t nonzeros,
116 const Arg&
min,
const Arg&
max )
const;
118 template<
typename Arg >
119 inline void randomize( StrictlyLowerMatrix<MT,true,DF>& matrix,
size_t nonzeros,
120 const Arg&
min,
const Arg&
max )
const;
131 template<
typename Arg >
132 inline void randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max,
TrueType )
const;
134 template<
typename Arg >
149 template<
typename MT
152 inline const StrictlyLowerMatrix<MT,SO,DF> Rand< StrictlyLowerMatrix<MT,SO,DF> >
::generate()
const 156 StrictlyLowerMatrix<MT,SO,DF> matrix;
171 template<
typename MT
174 inline const StrictlyLowerMatrix<MT,SO,DF>
175 Rand< StrictlyLowerMatrix<MT,SO,DF> >
::generate(
size_t n )
const 179 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
196 template<
typename MT
199 inline const StrictlyLowerMatrix<MT,SO,DF>
200 Rand< StrictlyLowerMatrix<MT,SO,DF> >
::generate(
size_t n,
size_t nonzeros )
const 205 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
209 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
226 template<
typename MT
229 template<
typename Arg >
230 inline const StrictlyLowerMatrix<MT,SO,DF>
231 Rand< StrictlyLowerMatrix<MT,SO,DF> >
::generate(
const Arg&
min,
const Arg&
max )
const 235 StrictlyLowerMatrix<MT,SO,DF> matrix;
252 template<
typename MT
255 template<
typename Arg >
256 inline const StrictlyLowerMatrix<MT,SO,DF>
257 Rand< StrictlyLowerMatrix<MT,SO,DF> >
::generate(
size_t n,
const Arg&
min,
const Arg&
max )
const 261 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
280 template<
typename MT
283 template<
typename Arg >
284 inline const StrictlyLowerMatrix<MT,SO,DF>
285 Rand< StrictlyLowerMatrix<MT,SO,DF> >
::generate(
size_t n,
size_t nonzeros,
286 const Arg&
min,
const Arg&
max )
const 291 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
295 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
311 template<
typename MT
314 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix )
const 316 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
329 template<
typename MT
332 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
TrueType )
const 336 using ET = ElementType_<MT>;
338 const size_t n( matrix.rows() );
340 for(
size_t i=1UL; i<n; ++i ) {
341 for(
size_t j=0UL; j<i; ++j ) {
342 matrix(i,j) = rand<ET>();
357 template<
typename MT
360 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
FalseType )
const 364 const size_t n( matrix.rows() );
366 if( n == 0UL || n == 1UL )
return;
368 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.2*n*n ) ) );
385 template<
typename MT
388 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const 392 using ET = ElementType_<MT>;
394 const size_t n( matrix.rows() );
396 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
400 if( n == 0UL || n == 1UL )
return;
403 matrix.reserve( nonzeros );
404 matrix.finalize( 0UL );
406 std::vector<size_t> dist( n );
408 for(
size_t nz=0UL; nz<nonzeros; ) {
409 const size_t index = rand<size_t>( 1UL, n-1UL );
410 if( dist[index] == index )
continue;
415 for(
size_t i=1UL; i<n; ++i ) {
416 const Indices indices( 0UL, i-1UL, dist[i] );
417 for(
size_t j : indices ) {
418 matrix.append( i, j, rand<ET>() );
420 matrix.finalize( i );
436 template<
typename MT
439 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const 443 using ET = ElementType_<MT>;
445 const size_t n( matrix.rows() );
447 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
451 if( n == 0UL || n == 1UL )
return;
454 matrix.reserve( nonzeros );
456 std::vector<size_t> dist( n-1UL );
458 for(
size_t nz=0UL; nz<nonzeros; ) {
459 const size_t index = rand<size_t>( 0UL, n-2UL );
460 if( dist[index] == n - index - 1UL )
continue;
465 for(
size_t j=0UL; j<n-1UL; ++j ) {
466 const Indices indices( j+1UL, n-1UL, dist[j] );
467 for(
size_t i : indices ) {
468 matrix.append( i, j, rand<ET>() );
470 matrix.finalize( j );
473 matrix.finalize( n-1UL );
488 template<
typename MT
491 template<
typename Arg >
492 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
493 const Arg& min,
const Arg& max )
const 495 randomize( matrix, min, max,
typename IsDenseMatrix<MT>::Type() );
510 template<
typename MT
513 template<
typename Arg >
514 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
515 const Arg& min,
const Arg& max,
TrueType )
const 519 using ET = ElementType_<MT>;
521 const size_t n( matrix.rows() );
523 for(
size_t i=1UL; i<n; ++i ) {
524 for(
size_t j=0UL; j<i; ++j ) {
525 matrix(i,j) = rand<ET>(
min,
max );
542 template<
typename MT
545 template<
typename Arg >
546 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
547 const Arg& min,
const Arg& max,
FalseType )
const 551 const size_t n( matrix.rows() );
553 if( n == 0UL || n == 1UL )
return;
555 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.2*n*n ) ) );
574 template<
typename MT
577 template<
typename Arg >
578 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,false,DF>& matrix,
579 size_t nonzeros,
const Arg& min,
const Arg& max )
const 583 using ET = ElementType_<MT>;
585 const size_t n( matrix.rows() );
587 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
591 if( n == 0UL || n == 1UL )
return;
594 matrix.reserve( nonzeros );
595 matrix.finalize( 0UL );
597 std::vector<size_t> dist( n );
599 for(
size_t nz=0UL; nz<nonzeros; ) {
600 const size_t index = rand<size_t>( 1UL, n-1UL );
601 if( dist[index] == index )
continue;
606 for(
size_t i=1UL; i<n; ++i ) {
607 const Indices indices( 0UL, i-1UL, dist[i] );
608 for(
size_t j : indices ) {
609 matrix.append( i, j, rand<ET>( min, max ) );
611 matrix.finalize( i );
629 template<
typename MT
632 template<
typename Arg >
633 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,true,DF>& matrix,
634 size_t nonzeros,
const Arg& min,
const Arg& max )
const 638 using ET = ElementType_<MT>;
640 const size_t n( matrix.rows() );
642 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
646 if( n == 0UL || n == 1UL )
return;
649 matrix.reserve( nonzeros );
651 std::vector<size_t> dist( n-1UL );
653 for(
size_t nz=0UL; nz<nonzeros; ) {
654 const size_t index = rand<size_t>( 0UL, n-2UL );
655 if( dist[index] == n - index - 1UL )
continue;
660 for(
size_t j=0UL; j<n-1UL; ++j ) {
661 const Indices indices( j+1UL, n-1UL, dist[j] );
662 for(
size_t i : indices ) {
663 matrix.append( i, j, rand<ET>( min, max ) );
665 matrix.finalize( j );
668 matrix.finalize( n-1UL );
BoolConstant< false > FalseType
Type/value traits base class.The FalseType class is used as base class for type traits and value trai...
Definition: FalseType.h:61
#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.
Header file for basic type definitions.
Header file for the FalseType type/value trait base class.
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type...
Definition: DenseMatrix.h:61
Constraint on the data type.
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:1903
Implementation of a random number generator.
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1950
Constraint on the data type.
Constraint on the data type.
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
Header file for all basic SparseMatrix functionality.
Header file for the implementation of a lower unitriangular matrix adaptor.
Header file for the complete StrictlyUpperMatrix implementation.
Header file for the exception macros of the math module.
Header file for the IsDenseMatrix type trait.
Header file for the implementation of a lower matrix adaptor.
Header file for the Indices class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_RESIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is resizable, i.e. has a 'resize' member fu...
Definition: Resizable.h:81
T generate() const
Generation of a random value in the range .
Definition: Random.h:252
Header file for all basic DenseMatrix functionality.
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not resizable, i.e. does not have a 'res...
Definition: Resizable.h:61
Header file for the implementation of a strictly lower triangular matrix adaptor. ...
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61
Header file for the TrueType type/value trait base class.