35#ifndef _BLAZE_MATH_SYMMETRICMATRIX_H_
36#define _BLAZE_MATH_SYMMETRICMATRIX_H_
91 inline const SymmetricMatrix<MT,SO,DF,SF>
generate()
const
95 SymmetricMatrix<MT,SO,DF,SF> matrix;
107 inline const SymmetricMatrix<MT,SO,DF,SF>
generate(
size_t n )
const
111 SymmetricMatrix<MT,SO,DF,SF> matrix( n );
125 inline const SymmetricMatrix<MT,SO,DF,SF>
generate(
size_t n,
size_t nonzeros )
const
130 if( nonzeros > n*n ) {
134 SymmetricMatrix<MT,SO,DF,SF> matrix( n );
148 template<
typename Arg >
149 inline const SymmetricMatrix<MT,SO,DF,SF>
generate(
const Arg&
min,
const Arg&
max )
const
153 SymmetricMatrix<MT,SO,DF,SF> matrix;
167 template<
typename Arg >
168 inline const SymmetricMatrix<MT,SO,DF,SF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const
172 SymmetricMatrix<MT,SO,DF,SF> matrix( n );
188 template<
typename Arg >
189 inline const SymmetricMatrix<MT,SO,DF,SF>
190 generate(
size_t n,
size_t nonzeros,
const Arg&
min,
const Arg&
max )
const
195 if( nonzeros > n*n ) {
199 SymmetricMatrix<MT,SO,DF,SF> matrix( n );
212 inline void randomize( SymmetricMatrix<MT,SO,DF,SF>& matrix )
const
214 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
226 inline void randomize( SymmetricMatrix<MT,SO,DF,SF>& matrix,
size_t nonzeros )
const
230 using ET = ElementType_t<MT>;
232 const size_t n( matrix.rows() );
234 if( nonzeros > n*n ) {
238 if( n == 0UL )
return;
241 matrix.reserve( nonzeros+1UL );
243 while( matrix.nonZeros() < nonzeros ) {
257 template<
typename Arg >
258 inline void randomize( SymmetricMatrix<MT,SO,DF,SF>& matrix,
259 const Arg&
min,
const Arg&
max )
const
275 template<
typename Arg >
276 inline void randomize( SymmetricMatrix<MT,SO,DF,SF>& matrix,
277 size_t nonzeros,
const Arg&
min,
const Arg&
max )
const
281 using ET = ElementType_t<MT>;
283 const size_t n( matrix.rows() );
285 if( nonzeros > n*n ) {
289 if( n == 0UL )
return;
291 std::vector<size_t> dist( n );
292 std::vector<bool> structure( n*n );
295 while( nz < nonzeros )
300 if( structure[
row*n+col] )
continue;
303 structure[
row*n+col] =
true;
308 structure[col*n+
row] =
true;
314 matrix.reserve( nz );
316 for(
size_t i=0UL; i<n; ++i ) {
317 matrix.reserve( i, dist[i] );
320 for(
size_t i=0UL; i<n; ++i ) {
321 for(
size_t j=i; j<n; ++j ) {
322 if( structure[i*n+j] ) {
341 using ET = ElementType_t<MT>;
343 const size_t n( matrix.rows() );
345 for(
size_t i=0UL; i<n; ++i ) {
346 for(
size_t j=0UL; j<=i; ++j ) {
363 const size_t n( matrix.rows() );
365 if( n == 0UL )
return;
367 const size_t nonzeros(
rand<size_t>( 1UL, std::ceil( 0.5*n*n ) ) );
381 template<
typename Arg >
382 inline void randomize( SymmetricMatrix<MT,SO,DF,SF>& matrix,
387 using ET = ElementType_t<MT>;
389 const size_t n( matrix.rows() );
391 for(
size_t i=0UL; i<n; ++i ) {
392 for(
size_t j=0UL; j<=i; ++j ) {
407 template<
typename Arg >
408 inline void randomize( SymmetricMatrix<MT,SO,DF,SF>& matrix,
413 const size_t n( matrix.rows() );
415 if( n == 0UL )
return;
417 const size_t nonzeros(
rand<size_t>( 1UL, std::ceil( 0.5*n*n ) ) );
494 const size_t n( matrix.rows() );
496 for(
size_t i=0UL; i<n; ++i ) {
497 for(
size_t j=0UL; j<=i; ++j ) {
527 const size_t n( matrix.rows() );
529 for(
size_t i=0UL; i<n; ++i ) {
530 for(
size_t j=0UL; j<=i; ++j ) {
557 const size_t n( matrix.rows() );
559 makeHermitian( matrix );
562 for(
size_t i=0UL; i<n; ++i ) {
563 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.
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 symmetric matrix adaptor.
Default implementation of the Rand class.
Definition Random.h:230
Matrix adapter for symmetric matrices.
Definition BaseTemplate.h:614
Constraint on the data type.
Constraint on the data type.
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 isHermitian(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is Hermitian.
Definition DenseMatrix.h:1534
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
#define BLAZE_CONSTRAINT_MUST_BE_SCALAR_TYPE(T)
Constraint on the data type.
Definition Scalar.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.