35 #ifndef _BLAZE_MATH_STRICTLYLOWERMATRIX_H_ 36 #define _BLAZE_MATH_STRICTLYLOWERMATRIX_H_ 83 class Rand< StrictlyLowerMatrix<MT,SO,DF> >
89 inline const StrictlyLowerMatrix<MT,SO,DF>
generate()
const;
90 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
size_t n )
const;
91 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const;
93 template<
typename Arg >
94 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const;
96 template<
typename Arg >
97 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const;
99 template<
typename Arg >
100 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros,
101 const Arg&
min,
const Arg&
max )
const;
108 inline void randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix )
const;
109 inline void randomize( StrictlyLowerMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const;
110 inline void randomize( StrictlyLowerMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const;
112 template<
typename Arg >
113 inline void randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const;
115 template<
typename Arg >
116 inline void randomize( StrictlyLowerMatrix<MT,false,DF>& matrix,
size_t nonzeros,
117 const Arg&
min,
const Arg&
max )
const;
119 template<
typename Arg >
120 inline void randomize( StrictlyLowerMatrix<MT,true,DF>& matrix,
size_t nonzeros,
121 const Arg&
min,
const Arg&
max )
const;
132 template<
typename Arg >
133 inline void randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max,
TrueType )
const;
135 template<
typename Arg >
150 template<
typename MT
153 inline const StrictlyLowerMatrix<MT,SO,DF> Rand< StrictlyLowerMatrix<MT,SO,DF> >::generate()
const 157 StrictlyLowerMatrix<MT,SO,DF> matrix;
172 template<
typename MT
175 inline const StrictlyLowerMatrix<MT,SO,DF>
176 Rand< StrictlyLowerMatrix<MT,SO,DF> >::generate(
size_t n )
const 180 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
197 template<
typename MT
200 inline const StrictlyLowerMatrix<MT,SO,DF>
201 Rand< StrictlyLowerMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros )
const 206 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
210 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
227 template<
typename MT
230 template<
typename Arg >
231 inline const StrictlyLowerMatrix<MT,SO,DF>
232 Rand< StrictlyLowerMatrix<MT,SO,DF> >::generate(
const Arg&
min,
const Arg&
max )
const 236 StrictlyLowerMatrix<MT,SO,DF> matrix;
253 template<
typename MT
256 template<
typename Arg >
257 inline const StrictlyLowerMatrix<MT,SO,DF>
258 Rand< StrictlyLowerMatrix<MT,SO,DF> >::generate(
size_t n,
const Arg&
min,
const Arg&
max )
const 262 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
281 template<
typename MT
284 template<
typename Arg >
285 inline const StrictlyLowerMatrix<MT,SO,DF>
286 Rand< StrictlyLowerMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros,
287 const Arg&
min,
const Arg&
max )
const 292 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
296 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
312 template<
typename MT
315 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix )
const 317 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
330 template<
typename MT
333 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
TrueType )
const 337 using ET = ElementType_t<MT>;
339 const size_t n( matrix.rows() );
341 for(
size_t i=1UL; i<n; ++i ) {
342 for(
size_t j=0UL; j<i; ++j ) {
343 matrix(i,j) = rand<ET>();
358 template<
typename MT
361 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
FalseType )
const 365 const size_t n( matrix.rows() );
367 if( n == 0UL || n == 1UL )
return;
369 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.2*n*n ) ) );
386 template<
typename MT
389 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const 393 using ET = ElementType_t<MT>;
395 const size_t n( matrix.rows() );
397 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
401 if( n == 0UL || n == 1UL )
return;
404 matrix.reserve( nonzeros );
405 matrix.finalize( 0UL );
407 std::vector<size_t> dist( n );
409 for(
size_t nz=0UL; nz<nonzeros; ) {
410 const size_t index = rand<size_t>( 1UL, n-1UL );
411 if( dist[index] == index )
continue;
416 for(
size_t i=1UL; i<n; ++i ) {
417 const Indices indices( 0UL, i-1UL, dist[i] );
418 for(
size_t j : indices ) {
419 matrix.append( i, j, rand<ET>() );
421 matrix.finalize( i );
437 template<
typename MT
440 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const 444 using ET = ElementType_t<MT>;
446 const size_t n( matrix.rows() );
448 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
452 if( n == 0UL || n == 1UL )
return;
455 matrix.reserve( nonzeros );
457 std::vector<size_t> dist( n-1UL );
459 for(
size_t nz=0UL; nz<nonzeros; ) {
460 const size_t index = rand<size_t>( 0UL, n-2UL );
461 if( dist[index] == n - index - 1UL )
continue;
466 for(
size_t j=0UL; j<n-1UL; ++j ) {
467 const Indices indices( j+1UL, n-1UL, dist[j] );
468 for(
size_t i : indices ) {
469 matrix.append( i, j, rand<ET>() );
471 matrix.finalize( j );
474 matrix.finalize( n-1UL );
489 template<
typename MT
492 template<
typename Arg >
493 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
494 const Arg&
min,
const Arg&
max )
const 511 template<
typename MT
514 template<
typename Arg >
515 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
520 using ET = ElementType_t<MT>;
522 const size_t n( matrix.rows() );
524 for(
size_t i=1UL; i<n; ++i ) {
525 for(
size_t j=0UL; j<i; ++j ) {
526 matrix(i,j) = rand<ET>(
min,
max );
543 template<
typename MT
546 template<
typename Arg >
547 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
552 const size_t n( matrix.rows() );
554 if( n == 0UL || n == 1UL )
return;
556 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.2*n*n ) ) );
575 template<
typename MT
578 template<
typename Arg >
579 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,false,DF>& matrix,
580 size_t nonzeros,
const Arg&
min,
const Arg&
max )
const 584 using ET = ElementType_t<MT>;
586 const size_t n( matrix.rows() );
588 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
592 if( n == 0UL || n == 1UL )
return;
595 matrix.reserve( nonzeros );
596 matrix.finalize( 0UL );
598 std::vector<size_t> dist( n );
600 for(
size_t nz=0UL; nz<nonzeros; ) {
601 const size_t index = rand<size_t>( 1UL, n-1UL );
602 if( dist[index] == index )
continue;
607 for(
size_t i=1UL; i<n; ++i ) {
608 const Indices indices( 0UL, i-1UL, dist[i] );
609 for(
size_t j : indices ) {
610 matrix.append( i, j, rand<ET>(
min,
max ) );
612 matrix.finalize( i );
630 template<
typename MT
633 template<
typename Arg >
634 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,true,DF>& matrix,
635 size_t nonzeros,
const Arg&
min,
const Arg&
max )
const 639 using ET = ElementType_t<MT>;
641 const size_t n( matrix.rows() );
643 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
647 if( n == 0UL || n == 1UL )
return;
650 matrix.reserve( nonzeros );
652 std::vector<size_t> dist( n-1UL );
654 for(
size_t nz=0UL; nz<nonzeros; ) {
655 const size_t index = rand<size_t>( 0UL, n-2UL );
656 if( dist[index] == n - index - 1UL )
continue;
661 for(
size_t j=0UL; j<n-1UL; ++j ) {
662 const Indices indices( j+1UL, n-1UL, dist[j] );
663 for(
size_t i : indices ) {
664 matrix.append( i, j, rand<ET>(
min,
max ) );
666 matrix.finalize( j );
669 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:1239
void randomize(T &&value)
Randomization of a given variable.
Definition: Random.h:929
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
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.
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:1147
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.
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:1179
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 complete ZeroMatrix implementation.
Header file for the TrueType type/value trait base class.