35#ifndef _BLAZE_MATH_HERMITIANMATRIX_H_
36#define _BLAZE_MATH_HERMITIANMATRIX_H_
89 inline const HermitianMatrix<MT,SO,DF>
generate()
const
93 HermitianMatrix<MT,SO,DF> matrix;
105 inline const HermitianMatrix<MT,SO,DF>
generate(
size_t n )
const
109 HermitianMatrix<MT,SO,DF> matrix( n );
123 inline const HermitianMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const
128 if( nonzeros > n*n ) {
132 HermitianMatrix<MT,SO,DF> matrix( n );
146 template<
typename Arg >
147 inline const HermitianMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const
151 HermitianMatrix<MT,SO,DF> matrix;
165 template<
typename Arg >
166 inline const HermitianMatrix<MT,SO,DF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const
170 HermitianMatrix<MT,SO,DF> matrix( n );
186 template<
typename Arg >
187 inline const HermitianMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros,
188 const Arg&
min,
const Arg&
max )
const
193 if( nonzeros > n*n ) {
197 HermitianMatrix<MT,SO,DF> matrix( n );
210 inline void randomize( HermitianMatrix<MT,SO,DF>& matrix )
const
212 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
224 inline void randomize( HermitianMatrix<MT,SO,DF>& matrix,
size_t nonzeros )
const
228 using ET = ElementType_t<MT>;
231 const size_t n( matrix.rows() );
233 if( nonzeros > n*n ) {
237 if( n == 0UL )
return;
240 matrix.reserve( nonzeros );
242 while( matrix.nonZeros() < nonzeros )
263 template<
typename Arg >
264 inline void randomize( HermitianMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const
280 template<
typename Arg >
281 inline void randomize( HermitianMatrix<MT,SO,DF>& matrix,
282 size_t nonzeros,
const Arg&
min,
const Arg&
max )
const
286 using ET = ElementType_t<MT>;
289 const size_t n( matrix.rows() );
291 if( nonzeros > n*n ) {
295 if( n == 0UL )
return;
297 std::vector<size_t> dist( n );
298 std::vector<bool> structure( n*n );
301 while( nz < nonzeros )
306 if( structure[
row*n+col] )
continue;
309 structure[
row*n+col] =
true;
314 structure[col*n+
row] =
true;
320 matrix.reserve( nz );
322 for(
size_t i=0UL; i<n; ++i ) {
323 matrix.reserve( i, dist[i] );
326 for(
size_t i=0UL; i<n; ++i ) {
327 for(
size_t j=i; j<n; ++j ) {
328 if( structure[i*n+j] ) {
350 using ET = ElementType_t<MT>;
353 const size_t n( matrix.rows() );
355 for(
size_t i=0UL; i<n; ++i ) {
356 for(
size_t j=0UL; j<i; ++j ) {
374 const size_t n( matrix.rows() );
376 if( n == 0UL )
return;
378 const size_t nonzeros(
rand<size_t>( 1UL, std::ceil( 0.5*n*n ) ) );
392 template<
typename Arg >
393 inline void randomize( HermitianMatrix<MT,SO,DF>& matrix,
398 using ET = ElementType_t<MT>;
401 const size_t n( matrix.rows() );
403 for(
size_t i=0UL; i<n; ++i ) {
404 for(
size_t j=0UL; j<i; ++j ) {
420 template<
typename Arg >
421 inline void randomize( HermitianMatrix<MT,SO,DF>& matrix,
426 const size_t n( matrix.rows() );
428 if( n == 0UL )
return;
430 const size_t nonzeros(
rand<size_t>( 1UL, std::ceil( 0.5*n*n ) ) );
462 const size_t n( matrix.rows() );
464 for(
size_t i=0UL; i<n; ++i ) {
465 for(
size_t j=0UL; j<=i; ++j ) {
493 const size_t n( matrix.rows() );
495 for(
size_t i=0UL; i<n; ++i ) {
496 for(
size_t j=0UL; j<=i; ++j ) {
566 const size_t n( matrix.rows() );
571 for(
size_t i=0UL; i<n; ++i ) {
572 matrix(i,i) += BT(n);
Header file for auxiliary alias declarations.
Header file for run time assertion macros.
Header file for all basic DenseMatrix functionality.
Header file for the IntegralConstant class template.
Header file for the IsDenseMatrix type trait.
Constraint on the data type.
Header file for all basic SparseMatrix functionality.
Header file for the UnderlyingBuiltin type trait.
Header file for the implementation of a diagonal matrix adaptor.
Header file for the implementation of a Hermitian matrix adaptor.
Matrix adapter for Hermitian matrices.
Definition BaseTemplate.h:616
Default implementation of the Rand class.
Definition Random.h:230
Constraint on the data type.
Constraint on the data type.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition Column.h:137
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:1339
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:1375
decltype(auto) real(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the real part of each single element of dm.
Definition DMatMapExpr.h:1529
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition DenseMatrix.h:1456
decltype(auto) generate(size_t m, size_t n, OP op)
Generates a new dense matrix filled via the given custom binary operation.
Definition DMatGenExpr.h:675
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition DenseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_RESIZABLE_TYPE(T)
Constraint on the data type.
Definition Resizable.h:81
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition SparseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE_TYPE(T)
Constraint on the data type.
Definition Resizable.h:61
typename UnderlyingBuiltin< T >::Type UnderlyingBuiltin_t
Auxiliary alias declaration for the UnderlyingBuiltin type trait.
Definition UnderlyingBuiltin.h:117
T rand()
Random number function.
Definition Random.h:583
void randomize(T &&value)
Randomization of a given variable.
Definition Random.h:626
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition Row.h:137
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition Assert.h:101
BoolConstant< false > FalseType
Type/value traits base class.
Definition IntegralConstant.h:121
BoolConstant< true > TrueType
Type traits base class.
Definition IntegralConstant.h:132
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition Exception.h:235
Header file for the exception macros of the math module.
Header file for the real shim.
Generic wrapper for the arg() function.
Definition Arg.h:77
Implementation of a random number generator.
Header file for basic type definitions.