35 #ifndef _BLAZE_MATH_STRICTLYUPPERMATRIX_H_ 36 #define _BLAZE_MATH_STRICTLYUPPERMATRIX_H_ 83 class Rand< StrictlyUpperMatrix<MT,SO,DF> >
89 inline const StrictlyUpperMatrix<MT,SO,DF>
generate()
const;
90 inline const StrictlyUpperMatrix<MT,SO,DF>
generate(
size_t n )
const;
91 inline const StrictlyUpperMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const;
93 template<
typename Arg >
94 inline const StrictlyUpperMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const;
96 template<
typename Arg >
97 inline const StrictlyUpperMatrix<MT,SO,DF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const;
99 template<
typename Arg >
100 inline const StrictlyUpperMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros,
101 const Arg&
min,
const Arg&
max )
const;
108 inline void randomize( StrictlyUpperMatrix<MT,SO,DF>& matrix )
const;
109 inline void randomize( StrictlyUpperMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const;
110 inline void randomize( StrictlyUpperMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const;
112 template<
typename Arg >
113 inline void randomize( StrictlyUpperMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const;
115 template<
typename Arg >
116 inline void randomize( StrictlyUpperMatrix<MT,false,DF>& matrix,
size_t nonzeros,
117 const Arg&
min,
const Arg&
max )
const;
119 template<
typename Arg >
120 inline void randomize( StrictlyUpperMatrix<MT,true,DF>& matrix,
size_t nonzeros,
121 const Arg&
min,
const Arg&
max )
const;
132 template<
typename Arg >
133 inline void randomize( StrictlyUpperMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max,
TrueType )
const;
135 template<
typename Arg >
150 template<
typename MT
153 inline const StrictlyUpperMatrix<MT,SO,DF> Rand< StrictlyUpperMatrix<MT,SO,DF> >::generate()
const 157 StrictlyUpperMatrix<MT,SO,DF> matrix;
172 template<
typename MT
175 inline const StrictlyUpperMatrix<MT,SO,DF>
176 Rand< StrictlyUpperMatrix<MT,SO,DF> >::generate(
size_t n )
const 180 StrictlyUpperMatrix<MT,SO,DF> matrix( n );
197 template<
typename MT
200 inline const StrictlyUpperMatrix<MT,SO,DF>
201 Rand< StrictlyUpperMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros )
const 206 if( nonzeros > StrictlyUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
210 StrictlyUpperMatrix<MT,SO,DF> matrix( n );
227 template<
typename MT
230 template<
typename Arg >
231 inline const StrictlyUpperMatrix<MT,SO,DF>
232 Rand< StrictlyUpperMatrix<MT,SO,DF> >::generate(
const Arg&
min,
const Arg&
max )
const 236 StrictlyUpperMatrix<MT,SO,DF> matrix;
253 template<
typename MT
256 template<
typename Arg >
257 inline const StrictlyUpperMatrix<MT,SO,DF>
258 Rand< StrictlyUpperMatrix<MT,SO,DF> >::generate(
size_t n,
const Arg&
min,
const Arg&
max )
const 262 StrictlyUpperMatrix<MT,SO,DF> matrix( n );
281 template<
typename MT
284 template<
typename Arg >
285 inline const StrictlyUpperMatrix<MT,SO,DF>
286 Rand< StrictlyUpperMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros,
287 const Arg&
min,
const Arg&
max )
const 292 if( nonzeros > StrictlyUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
296 StrictlyUpperMatrix<MT,SO,DF> matrix( n );
312 template<
typename MT
315 inline void Rand< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<MT,SO,DF>& matrix )
const 317 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
330 template<
typename MT
333 inline void Rand< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<MT,SO,DF>& matrix,
TrueType )
const 337 using ET = ElementType_t<MT>;
339 const size_t n( matrix.rows() );
341 for(
size_t i=0UL; i<n; ++i ) {
342 for(
size_t j=i+1UL; j<n; ++j ) {
343 matrix(i,j) = rand<ET>();
358 template<
typename MT
361 inline void Rand< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<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< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const 393 using ET = ElementType_t<MT>;
395 const size_t n( matrix.rows() );
397 if( nonzeros > StrictlyUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
401 if( n == 0UL || n == 1UL )
return;
404 matrix.reserve( nonzeros );
406 std::vector<size_t> dist( n-1UL );
408 for(
size_t nz=0UL; nz<nonzeros; ) {
409 const size_t index = rand<size_t>( 0UL, n-2UL );
410 if( dist[index] == n - index - 1UL )
continue;
415 for(
size_t i=0UL; i<n-1UL; ++i ) {
416 const Indices indices( i+1UL, n-1UL, dist[i] );
417 for(
size_t j : indices ) {
418 matrix.append( i, j, rand<ET>() );
420 matrix.finalize( i );
423 matrix.finalize( n-1UL );
438 template<
typename MT
441 inline void Rand< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const 445 using ET = ElementType_t<MT>;
447 const size_t n( matrix.rows() );
449 if( nonzeros > StrictlyUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
453 if( n == 0UL || n == 1UL )
return;
456 matrix.reserve( nonzeros );
457 matrix.finalize( 0UL );
459 std::vector<size_t> dist( n );
461 for(
size_t nz=0UL; nz<nonzeros; ) {
462 const size_t index = rand<size_t>( 1UL, n-1UL );
463 if( dist[index] == index )
continue;
468 for(
size_t j=1UL; j<n; ++j ) {
469 const Indices indices( 0UL, j-1UL, dist[j] );
470 for(
size_t i : indices ) {
471 matrix.append( i, j, rand<ET>() );
473 matrix.finalize( j );
489 template<
typename MT
492 template<
typename Arg >
493 inline void Rand< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<MT,SO,DF>& matrix,
494 const Arg&
min,
const Arg&
max )
const 511 template<
typename MT
514 template<
typename Arg >
515 inline void Rand< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<MT,SO,DF>& matrix,
520 using ET = ElementType_t<MT>;
522 const size_t n( matrix.rows() );
524 for(
size_t i=0UL; i<n; ++i ) {
525 for(
size_t j=i+1UL; j<n; ++j ) {
526 matrix(i,j) = rand<ET>(
min,
max );
543 template<
typename MT
546 template<
typename Arg >
547 inline void Rand< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<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< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<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 > StrictlyUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
592 if( n == 0UL || n == 1UL )
return;
595 matrix.reserve( nonzeros );
597 std::vector<size_t> dist( n-1UL );
599 for(
size_t nz=0UL; nz<nonzeros; ) {
600 const size_t index = rand<size_t>( 0UL, n-2UL );
601 if( dist[index] == n - index - 1UL )
continue;
606 for(
size_t i=0UL; i<n-1UL; ++i ) {
607 const Indices indices( i+1UL, n-1UL, dist[i] );
608 for(
size_t j : indices ) {
609 matrix.append( i, j, rand<ET>(
min,
max ) );
611 matrix.finalize( i );
614 matrix.finalize( n-1UL );
631 template<
typename MT
634 template<
typename Arg >
635 inline void Rand< StrictlyUpperMatrix<MT,SO,DF> >
::randomize( StrictlyUpperMatrix<MT,true,DF>& matrix,
636 size_t nonzeros,
const Arg&
min,
const Arg&
max )
const 640 using ET = ElementType_t<MT>;
642 const size_t n( matrix.rows() );
644 if( nonzeros > StrictlyUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
648 if( n == 0UL || n == 1UL )
return;
651 matrix.reserve( nonzeros );
652 matrix.finalize( 0UL );
654 std::vector<size_t> dist( n );
656 for(
size_t nz=0UL; nz<nonzeros; ) {
657 const size_t index = rand<size_t>( 1UL, n-1UL );
658 if( dist[index] == index )
continue;
663 for(
size_t j=1UL; j<n; ++j ) {
664 const Indices indices( 0UL, j-1UL, dist[j] );
665 for(
size_t i : indices ) {
666 matrix.append( i, j, rand<ET>(
min,
max ) );
668 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: 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.
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: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 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:1179
Header file for the IsDenseMatrix type trait.
Header file for the implementation of a 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
#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.