35 #ifndef _BLAZE_MATH_UNIUPPERMATRIX_H_ 36 #define _BLAZE_MATH_UNIUPPERMATRIX_H_ 82 class Rand< UniUpperMatrix<MT,SO,DF> >
88 inline const UniUpperMatrix<MT,SO,DF>
generate()
const;
89 inline const UniUpperMatrix<MT,SO,DF>
generate(
size_t n )
const;
90 inline const UniUpperMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const;
92 template<
typename Arg >
93 inline const UniUpperMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const;
95 template<
typename Arg >
96 inline const UniUpperMatrix<MT,SO,DF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const;
98 template<
typename Arg >
99 inline const UniUpperMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros,
100 const Arg&
min,
const Arg&
max )
const;
107 inline void randomize( UniUpperMatrix<MT,SO,DF>& matrix )
const;
108 inline void randomize( UniUpperMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const;
109 inline void randomize( UniUpperMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const;
111 template<
typename Arg >
112 inline void randomize( UniUpperMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const;
114 template<
typename Arg >
115 inline void randomize( UniUpperMatrix<MT,false,DF>& matrix,
size_t nonzeros,
116 const Arg&
min,
const Arg&
max )
const;
118 template<
typename Arg >
119 inline void randomize( UniUpperMatrix<MT,true,DF>& matrix,
size_t nonzeros,
120 const Arg&
min,
const Arg&
max )
const;
131 template<
typename Arg >
134 template<
typename Arg >
149 template<
typename MT
152 inline const UniUpperMatrix<MT,SO,DF> Rand< UniUpperMatrix<MT,SO,DF> >
::generate()
const 156 UniUpperMatrix<MT,SO,DF> matrix;
171 template<
typename MT
174 inline const UniUpperMatrix<MT,SO,DF>
175 Rand< UniUpperMatrix<MT,SO,DF> >
::generate(
size_t n )
const 179 UniUpperMatrix<MT,SO,DF> matrix( n );
196 template<
typename MT
199 inline const UniUpperMatrix<MT,SO,DF>
200 Rand< UniUpperMatrix<MT,SO,DF> >
::generate(
size_t n,
size_t nonzeros )
const 205 if( nonzeros > UniUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
209 UniUpperMatrix<MT,SO,DF> matrix( n );
226 template<
typename MT
229 template<
typename Arg >
230 inline const UniUpperMatrix<MT,SO,DF>
231 Rand< UniUpperMatrix<MT,SO,DF> >
::generate(
const Arg&
min,
const Arg&
max )
const 235 UniUpperMatrix<MT,SO,DF> matrix;
252 template<
typename MT
255 template<
typename Arg >
256 inline const UniUpperMatrix<MT,SO,DF>
257 Rand< UniUpperMatrix<MT,SO,DF> >
::generate(
size_t n,
const Arg&
min,
const Arg&
max )
const 261 UniUpperMatrix<MT,SO,DF> matrix( n );
280 template<
typename MT
283 template<
typename Arg >
284 inline const UniUpperMatrix<MT,SO,DF>
285 Rand< UniUpperMatrix<MT,SO,DF> >
::generate(
size_t n,
size_t nonzeros,
286 const Arg&
min,
const Arg&
max )
const 291 if( nonzeros > UniUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
295 UniUpperMatrix<MT,SO,DF> matrix( n );
311 template<
typename MT
314 inline void Rand< UniUpperMatrix<MT,SO,DF> >
::randomize( UniUpperMatrix<MT,SO,DF>& matrix )
const 316 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
329 template<
typename MT
332 inline void Rand< UniUpperMatrix<MT,SO,DF> >
::randomize( UniUpperMatrix<MT,SO,DF>& matrix,
TrueType )
const 336 using ET = ElementType_<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< UniUpperMatrix<MT,SO,DF> >
::randomize( UniUpperMatrix<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< UniUpperMatrix<MT,SO,DF> >
::randomize( UniUpperMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const 392 using ET = ElementType_<MT>;
394 const size_t n( matrix.rows() );
396 if( nonzeros > UniUpperMatrix<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< UniUpperMatrix<MT,SO,DF> >
::randomize( UniUpperMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const 444 using ET = ElementType_<MT>;
446 const size_t n( matrix.rows() );
448 if( nonzeros > UniUpperMatrix<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< UniUpperMatrix<MT,SO,DF> >
::randomize( UniUpperMatrix<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< UniUpperMatrix<MT,SO,DF> >
::randomize( UniUpperMatrix<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=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< UniUpperMatrix<MT,SO,DF> >
::randomize( UniUpperMatrix<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< UniUpperMatrix<MT,SO,DF> >
::randomize( UniUpperMatrix<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 > UniUpperMatrix<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< UniUpperMatrix<MT,SO,DF> >
::randomize( UniUpperMatrix<MT,true,DF>& matrix,
635 size_t nonzeros,
const Arg& min,
const Arg& max )
const 639 using ET = ElementType_<MT>;
641 const size_t n( matrix.rows() );
643 if( nonzeros > UniUpperMatrix<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 );
689 template<
typename MT
692 void makeSymmetric( UniUpperMatrix<MT,SO,DF>& matrix )
711 template<
typename MT
715 void makeSymmetric( UniUpperMatrix<MT,SO,DF>& matrix,
const Arg& min,
const Arg& max )
719 makeSymmetric( matrix );
732 template<
typename MT
735 void makeHermitian( UniUpperMatrix<MT,SO,DF>& matrix )
754 template<
typename MT
758 void makeHermitian( UniUpperMatrix<MT,SO,DF>& matrix,
const Arg& min,
const Arg& max )
762 makeHermitian( matrix );
775 template<
typename MT
778 void makePositiveDefinite( UniUpperMatrix<MT,SO,DF>& matrix )
780 makeHermitian( matrix );
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 the complete UniLowerMatrix implementation.
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
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:588
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 strictly upper triangular matrix adaptor. ...
Header file for the exception macros of the math module.
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
bool isHermitian(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is Hermitian.
Definition: DenseMatrix.h:919
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:841
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
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#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.