35 #ifndef _BLAZE_MATH_STRICTLYUPPERMATRIX_H_ 36 #define _BLAZE_MATH_STRICTLYUPPERMATRIX_H_ 82 class Rand< StrictlyUpperMatrix<MT,SO,DF> >
88 inline const StrictlyUpperMatrix<MT,SO,DF>
generate()
const;
89 inline const StrictlyUpperMatrix<MT,SO,DF>
generate(
size_t n )
const;
90 inline const StrictlyUpperMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const;
92 template<
typename Arg >
93 inline const StrictlyUpperMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const;
95 template<
typename Arg >
96 inline const StrictlyUpperMatrix<MT,SO,DF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const;
98 template<
typename Arg >
99 inline const StrictlyUpperMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros,
100 const Arg&
min,
const Arg&
max )
const;
107 inline void randomize( StrictlyUpperMatrix<MT,SO,DF>& matrix )
const;
108 inline void randomize( StrictlyUpperMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const;
109 inline void randomize( StrictlyUpperMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const;
111 template<
typename Arg >
112 inline void randomize( StrictlyUpperMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const;
114 template<
typename Arg >
115 inline void randomize( StrictlyUpperMatrix<MT,false,DF>& matrix,
size_t nonzeros,
116 const Arg&
min,
const Arg&
max )
const;
118 template<
typename Arg >
119 inline void randomize( StrictlyUpperMatrix<MT,true,DF>& matrix,
size_t nonzeros,
120 const Arg&
min,
const Arg&
max )
const;
131 template<
typename Arg >
132 inline void randomize( StrictlyUpperMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max,
TrueType )
const;
134 template<
typename Arg >
149 template<
typename MT
152 inline const StrictlyUpperMatrix<MT,SO,DF> Rand< StrictlyUpperMatrix<MT,SO,DF> >::generate()
const 156 StrictlyUpperMatrix<MT,SO,DF> matrix;
171 template<
typename MT
174 inline const StrictlyUpperMatrix<MT,SO,DF>
175 Rand< StrictlyUpperMatrix<MT,SO,DF> >::generate(
size_t n )
const 179 StrictlyUpperMatrix<MT,SO,DF> matrix( n );
196 template<
typename MT
199 inline const StrictlyUpperMatrix<MT,SO,DF>
200 Rand< StrictlyUpperMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros )
const 205 if( nonzeros > StrictlyUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
209 StrictlyUpperMatrix<MT,SO,DF> matrix( n );
226 template<
typename MT
229 template<
typename Arg >
230 inline const StrictlyUpperMatrix<MT,SO,DF>
231 Rand< StrictlyUpperMatrix<MT,SO,DF> >::generate(
const Arg&
min,
const Arg&
max )
const 235 StrictlyUpperMatrix<MT,SO,DF> matrix;
252 template<
typename MT
255 template<
typename Arg >
256 inline const StrictlyUpperMatrix<MT,SO,DF>
257 Rand< StrictlyUpperMatrix<MT,SO,DF> >::generate(
size_t n,
const Arg&
min,
const Arg&
max )
const 261 StrictlyUpperMatrix<MT,SO,DF> matrix( n );
280 template<
typename MT
283 template<
typename Arg >
284 inline const StrictlyUpperMatrix<MT,SO,DF>
285 Rand< StrictlyUpperMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros,
286 const Arg&
min,
const Arg&
max )
const 291 if( nonzeros > StrictlyUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
295 StrictlyUpperMatrix<MT,SO,DF> matrix( n );
311 template<
typename MT
314 inline void Rand< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<MT,SO,DF>& matrix )
const 316 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
329 template<
typename MT
332 inline void Rand< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<MT,SO,DF>& matrix,
TrueType )
const 336 using ET = ElementType_t<MT>;
338 const size_t n( matrix.rows() );
340 for(
size_t i=0UL; i<n; ++i ) {
341 for(
size_t j=i+1UL; j<n; ++j ) {
342 matrix(i,j) = rand<ET>();
357 template<
typename MT
360 inline void Rand< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<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< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const 392 using ET = ElementType_t<MT>;
394 const size_t n( matrix.rows() );
396 if( nonzeros > StrictlyUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
400 if( n == 0UL || n == 1UL )
return;
403 matrix.reserve( nonzeros );
405 std::vector<size_t> dist( n-1UL );
407 for(
size_t nz=0UL; nz<nonzeros; ) {
408 const size_t index = rand<size_t>( 0UL, n-2UL );
409 if( dist[index] == n - index - 1UL )
continue;
414 for(
size_t i=0UL; i<n-1UL; ++i ) {
415 const Indices indices( i+1UL, n-1UL, dist[i] );
416 for(
size_t j : indices ) {
417 matrix.append( i, j, rand<ET>() );
419 matrix.finalize( i );
422 matrix.finalize( n-1UL );
437 template<
typename MT
440 inline void Rand< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const 444 using ET = ElementType_t<MT>;
446 const size_t n( matrix.rows() );
448 if( nonzeros > StrictlyUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
452 if( n == 0UL || n == 1UL )
return;
455 matrix.reserve( nonzeros );
456 matrix.finalize( 0UL );
458 std::vector<size_t> dist( n );
460 for(
size_t nz=0UL; nz<nonzeros; ) {
461 const size_t index = rand<size_t>( 1UL, n-1UL );
462 if( dist[index] == index )
continue;
467 for(
size_t j=1UL; j<n; ++j ) {
468 const Indices indices( 0UL, j-1UL, dist[j] );
469 for(
size_t i : indices ) {
470 matrix.append( i, j, rand<ET>() );
472 matrix.finalize( j );
488 template<
typename MT
491 template<
typename Arg >
492 inline void Rand< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<MT,SO,DF>& matrix,
493 const Arg&
min,
const Arg&
max )
const 510 template<
typename MT
513 template<
typename Arg >
514 inline void Rand< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<MT,SO,DF>& matrix,
519 using ET = ElementType_t<MT>;
521 const size_t n( matrix.rows() );
523 for(
size_t i=0UL; i<n; ++i ) {
524 for(
size_t j=i+1UL; j<n; ++j ) {
525 matrix(i,j) = rand<ET>(
min,
max );
542 template<
typename MT
545 template<
typename Arg >
546 inline void Rand< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<MT,SO,DF>& matrix,
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< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<MT,false,DF>& matrix,
579 size_t nonzeros,
const Arg&
min,
const Arg&
max )
const 583 using ET = ElementType_t<MT>;
585 const size_t n( matrix.rows() );
587 if( nonzeros > StrictlyUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
591 if( n == 0UL || n == 1UL )
return;
594 matrix.reserve( nonzeros );
596 std::vector<size_t> dist( n-1UL );
598 for(
size_t nz=0UL; nz<nonzeros; ) {
599 const size_t index = rand<size_t>( 0UL, n-2UL );
600 if( dist[index] == n - index - 1UL )
continue;
605 for(
size_t i=0UL; i<n-1UL; ++i ) {
606 const Indices indices( i+1UL, n-1UL, dist[i] );
607 for(
size_t j : indices ) {
608 matrix.append( i, j, rand<ET>(
min,
max ) );
610 matrix.finalize( i );
613 matrix.finalize( n-1UL );
630 template<
typename MT
633 template<
typename Arg >
634 inline void Rand< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<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 > StrictlyUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
647 if( n == 0UL || n == 1UL )
return;
650 matrix.reserve( nonzeros );
651 matrix.finalize( 0UL );
653 std::vector<size_t> dist( n );
655 for(
size_t nz=0UL; nz<nonzeros; ) {
656 const size_t index = rand<size_t>( 1UL, n-1UL );
657 if( dist[index] == index )
continue;
662 for(
size_t j=1UL; j<n; ++j ) {
663 const Indices indices( 0UL, j-1UL, dist[j] );
664 for(
size_t i : indices ) {
665 matrix.append( i, j, rand<ET>(
min,
max ) );
667 matrix.finalize( j );
BoolConstant< false > FalseType
Type/value traits base class.The FalseType class is used as base class for type traits and value trai...
Definition: IntegralConstant.h:121
#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 complete StrictlyLowerMatrix implementation.
#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:1240
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: IntegralConstant.h:132
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:1162
Header file for the implementation of a strictly upper triangular matrix adaptor.
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 IsDenseMatrix type trait.
Header file for the implementation of an upper 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.
Header file for the implementation of a upper unitriangular matrix adaptor.
#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 IntegralConstant class template.
#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.