35 #ifndef _BLAZE_MATH_HERMITIANMATRIX_H_ 36 #define _BLAZE_MATH_HERMITIANMATRIX_H_ 81 class Rand< HermitianMatrix<MT,SO,DF> >
87 inline const HermitianMatrix<MT,SO,DF>
generate()
const;
88 inline const HermitianMatrix<MT,SO,DF>
generate(
size_t n )
const;
89 inline const HermitianMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const;
91 template<
typename Arg >
92 inline const HermitianMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const;
94 template<
typename Arg >
95 inline const HermitianMatrix<MT,SO,DF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const;
97 template<
typename Arg >
98 inline const HermitianMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros,
99 const Arg&
min,
const Arg&
max )
const;
106 inline void randomize( HermitianMatrix<MT,SO,DF>& matrix )
const;
107 inline void randomize( HermitianMatrix<MT,SO,DF>& matrix,
size_t nonzeros )
const;
109 template<
typename Arg >
110 inline void randomize( HermitianMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const;
112 template<
typename Arg >
113 inline void randomize( HermitianMatrix<MT,SO,DF>& matrix,
size_t nonzeros,
114 const Arg&
min,
const Arg&
max )
const;
125 template<
typename Arg >
128 template<
typename Arg >
143 template<
typename MT
146 inline const HermitianMatrix<MT,SO,DF> Rand< HermitianMatrix<MT,SO,DF> >::generate()
const 150 HermitianMatrix<MT,SO,DF> matrix;
165 template<
typename MT
168 inline const HermitianMatrix<MT,SO,DF>
169 Rand< HermitianMatrix<MT,SO,DF> >::generate(
size_t n )
const 173 HermitianMatrix<MT,SO,DF> matrix( n );
190 template<
typename MT
193 inline const HermitianMatrix<MT,SO,DF>
194 Rand< HermitianMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros )
const 200 throw std::invalid_argument(
"Invalid number of non-zero elements" );
202 HermitianMatrix<MT,SO,DF> matrix( n );
219 template<
typename MT
222 template<
typename Arg >
223 inline const HermitianMatrix<MT,SO,DF>
224 Rand< HermitianMatrix<MT,SO,DF> >::generate(
const Arg&
min,
const Arg&
max )
const 228 HermitianMatrix<MT,SO,DF> matrix;
245 template<
typename MT
248 template<
typename Arg >
249 inline const HermitianMatrix<MT,SO,DF>
250 Rand< HermitianMatrix<MT,SO,DF> >::generate(
size_t n,
const Arg&
min,
const Arg&
max )
const 254 HermitianMatrix<MT,SO,DF> matrix( n );
273 template<
typename MT
276 template<
typename Arg >
277 inline const HermitianMatrix<MT,SO,DF>
278 Rand< HermitianMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros,
279 const Arg&
min,
const Arg&
max )
const 285 throw std::invalid_argument(
"Invalid number of non-zero elements" );
287 HermitianMatrix<MT,SO,DF> matrix( n );
303 template<
typename MT
306 inline void Rand< HermitianMatrix<MT,SO,DF> >
::randomize( HermitianMatrix<MT,SO,DF>& matrix )
const 308 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
321 template<
typename MT
324 inline void Rand< HermitianMatrix<MT,SO,DF> >
::randomize( HermitianMatrix<MT,SO,DF>& matrix,
TrueType )
const 328 using ET = ElementType_t<MT>;
329 using BT = UnderlyingBuiltin_t<ET>;
331 const size_t n( matrix.rows() );
333 for(
size_t i=0UL; i<n; ++i ) {
334 for(
size_t j=0UL; j<i; ++j ) {
335 matrix(i,j) = rand<ET>();
337 matrix(i,i) = rand<BT>();
351 template<
typename MT
354 inline void Rand< HermitianMatrix<MT,SO,DF> >
::randomize( HermitianMatrix<MT,SO,DF>& matrix,
FalseType )
const 358 const size_t n( matrix.rows() );
360 if( n == 0UL )
return;
362 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.5*n*n ) ) );
379 template<
typename MT
382 inline void Rand< HermitianMatrix<MT,SO,DF> >
::randomize( HermitianMatrix<MT,SO,DF>& matrix,
size_t nonzeros )
const 386 using ET = ElementType_t<MT>;
387 using BT = UnderlyingBuiltin_t<ET>;
389 const size_t n( matrix.rows() );
392 throw std::invalid_argument(
"Invalid number of non-zero elements" );
394 if( n == 0UL )
return;
397 matrix.reserve( nonzeros );
399 while( matrix.nonZeros() < nonzeros )
401 const size_t row ( rand<size_t>( 0UL, n-1UL ) );
402 const size_t column( rand<size_t>( 0UL, n-1UL ) );
423 template<
typename MT
426 template<
typename Arg >
427 inline void Rand< HermitianMatrix<MT,SO,DF> >
::randomize( HermitianMatrix<MT,SO,DF>& matrix,
428 const Arg&
min,
const Arg&
max )
const 445 template<
typename MT
448 template<
typename Arg >
449 inline void Rand< HermitianMatrix<MT,SO,DF> >
::randomize( HermitianMatrix<MT,SO,DF>& matrix,
454 using ET = ElementType_t<MT>;
455 using BT = UnderlyingBuiltin_t<ET>;
457 const size_t n( matrix.rows() );
459 for(
size_t i=0UL; i<n; ++i ) {
460 for(
size_t j=0UL; j<i; ++j ) {
461 matrix(i,j) = rand<ET>(
min,
max );
479 template<
typename MT
482 template<
typename Arg >
483 inline void Rand< HermitianMatrix<MT,SO,DF> >
::randomize( HermitianMatrix<MT,SO,DF>& matrix,
488 const size_t n( matrix.rows() );
490 if( n == 0UL )
return;
492 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.5*n*n ) ) );
511 template<
typename MT
514 template<
typename Arg >
515 inline void Rand< HermitianMatrix<MT,SO,DF> >
::randomize( HermitianMatrix<MT,SO,DF>& matrix,
516 size_t nonzeros,
const Arg&
min,
const Arg&
max )
const 520 using ET = ElementType_t<MT>;
521 using BT = UnderlyingBuiltin_t<ET>;
523 const size_t n( matrix.rows() );
526 throw std::invalid_argument(
"Invalid number of non-zero elements" );
528 if( n == 0UL )
return;
531 matrix.reserve( nonzeros );
533 while( matrix.nonZeros() < nonzeros )
535 const size_t row ( rand<size_t>( 0UL, n-1UL ) );
536 const size_t column( rand<size_t>( 0UL, n-1UL ) );
563 template<
typename MT
566 void makeSymmetric( HermitianMatrix<MT,SO,DF>& matrix )
568 using BT = UnderlyingBuiltin_t< ElementType_t<MT> >;
570 const size_t n( matrix.rows() );
572 for(
size_t i=0UL; i<n; ++i ) {
573 for(
size_t j=0UL; j<=i; ++j ) {
574 matrix(i,j) = rand<BT>();
593 template<
typename MT
597 void makeSymmetric( HermitianMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
599 using BT = UnderlyingBuiltin_t< ElementType_t<MT> >;
601 const size_t n( matrix.rows() );
603 for(
size_t i=0UL; i<n; ++i ) {
604 for(
size_t j=0UL; j<=i; ++j ) {
622 template<
typename MT
625 void makeHermitian( HermitianMatrix<MT,SO,DF>& matrix )
644 template<
typename MT
648 void makeHermitian( HermitianMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
665 template<
typename MT
668 void makePositiveDefinite( HermitianMatrix<MT,SO,DF>& matrix )
672 using BT = UnderlyingBuiltin_t< ElementType_t<MT> >;
674 const size_t n( matrix.rows() );
679 for(
size_t i=0UL; i<n; ++i ) {
680 matrix(i,i) += BT(n);
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
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Header file for basic type definitions.
Header file for the FalseType type/value trait base class.
decltype(auto) real(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the real part of each single element of dm.
Definition: DMatMapExpr.h:1392
#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
Header file for the implementation of a Hermitian matrix adaptor.
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 UnderlyingBuiltin type trait.
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
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 run time assertion macros.
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
#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 isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:539
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 diagonal matrix adaptor.
Header file for the real shim.
#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.