35 #ifndef _BLAZE_MATH_SYMMETRICMATRIX_H_
36 #define _BLAZE_MATH_SYMMETRICMATRIX_H_
77 class Rand< SymmetricMatrix<MT,SO,DF,NF> >
83 inline const SymmetricMatrix<MT,SO,DF,NF>
generate()
const;
84 inline const SymmetricMatrix<MT,SO,DF,NF>
generate(
size_t n )
const;
85 inline const SymmetricMatrix<MT,SO,DF,NF>
generate(
size_t n,
size_t nonzeros )
const;
87 template<
typename Arg >
88 inline const SymmetricMatrix<MT,SO,DF,NF>
generate(
const Arg&
min,
const Arg&
max )
const;
90 template<
typename Arg >
91 inline const SymmetricMatrix<MT,SO,DF,NF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const;
93 template<
typename Arg >
94 inline const SymmetricMatrix<MT,SO,DF,NF>
generate(
size_t n,
size_t nonzeros,
95 const Arg&
min,
const Arg&
max )
const;
102 inline void randomize( SymmetricMatrix<MT,SO,DF,NF>& matrix )
const;
103 inline void randomize( SymmetricMatrix<MT,SO,DF,NF>& matrix,
size_t nonzeros )
const;
105 template<
typename Arg >
106 inline void randomize( SymmetricMatrix<MT,SO,DF,NF>& matrix,
const Arg&
min,
const Arg&
max )
const;
108 template<
typename Arg >
109 inline void randomize( SymmetricMatrix<MT,SO,DF,NF>& matrix,
size_t nonzeros,
110 const Arg&
min,
const Arg&
max )
const;
121 template<
typename Arg >
124 template<
typename Arg >
139 template<
typename MT
143 inline const SymmetricMatrix<MT,SO,DF,NF> Rand< SymmetricMatrix<MT,SO,DF,NF> >::generate()
const
147 SymmetricMatrix<MT,SO,DF,NF> matrix;
162 template<
typename MT
166 inline const SymmetricMatrix<MT,SO,DF,NF>
167 Rand< SymmetricMatrix<MT,SO,DF,NF> >::generate(
size_t n )
const
171 SymmetricMatrix<MT,SO,DF,NF> matrix( n );
188 template<
typename MT
192 inline const SymmetricMatrix<MT,SO,DF,NF>
193 Rand< SymmetricMatrix<MT,SO,DF,NF> >::generate(
size_t n,
size_t nonzeros )
const
199 throw std::invalid_argument(
"Invalid number of non-zero elements" );
201 SymmetricMatrix<MT,SO,DF,NF> matrix( n );
218 template<
typename MT
222 template<
typename Arg >
223 inline const SymmetricMatrix<MT,SO,DF,NF>
224 Rand< SymmetricMatrix<MT,SO,DF,NF> >::generate(
const Arg&
min,
const Arg&
max )
const
228 SymmetricMatrix<MT,SO,DF,NF> matrix;
245 template<
typename MT
249 template<
typename Arg >
250 inline const SymmetricMatrix<MT,SO,DF,NF>
251 Rand< SymmetricMatrix<MT,SO,DF,NF> >::generate(
size_t n,
const Arg&
min,
const Arg&
max )
const
255 SymmetricMatrix<MT,SO,DF,NF> matrix( n );
274 template<
typename MT
278 template<
typename Arg >
279 inline const SymmetricMatrix<MT,SO,DF,NF>
280 Rand< SymmetricMatrix<MT,SO,DF,NF> >::generate(
size_t n,
size_t nonzeros,
281 const Arg&
min,
const Arg&
max )
const
287 throw std::invalid_argument(
"Invalid number of non-zero elements" );
289 SymmetricMatrix<MT,SO,DF,NF> matrix( n );
305 template<
typename MT
309 inline void Rand< SymmetricMatrix<MT,SO,DF,NF> >
::randomize( SymmetricMatrix<MT,SO,DF,NF>& matrix )
const
311 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
324 template<
typename MT
328 inline void Rand< SymmetricMatrix<MT,SO,DF,NF> >
::randomize( SymmetricMatrix<MT,SO,DF,NF>& matrix,
TrueType )
const
334 const size_t n( matrix.rows() );
336 for(
size_t i=0UL; i<n; ++i ) {
337 for(
size_t j=0UL; j<=i; ++j ) {
338 matrix(i,j) = rand<ET>();
353 template<
typename MT
357 inline void Rand< SymmetricMatrix<MT,SO,DF,NF> >
::randomize( SymmetricMatrix<MT,SO,DF,NF>& matrix,
FalseType )
const
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 ) ) );
370 matrix.reserve( nonzeros );
372 while( matrix.nonZeros() < nonzeros ) {
373 matrix( rand<size_t>( 0UL, n-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ET>();
389 template<
typename MT
393 inline void Rand< SymmetricMatrix<MT,SO,DF,NF> >
::randomize( SymmetricMatrix<MT,SO,DF,NF>& matrix,
size_t nonzeros )
const
399 const size_t n( matrix.rows() );
402 throw std::invalid_argument(
"Invalid number of non-zero elements" );
404 if( n == 0UL )
return;
407 matrix.reserve( nonzeros );
409 while( matrix.nonZeros() < nonzeros ) {
410 matrix( rand<size_t>( 0UL, n-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ET>();
426 template<
typename MT
430 template<
typename Arg >
431 inline void Rand< SymmetricMatrix<MT,SO,DF,NF> >
::randomize( SymmetricMatrix<MT,SO,DF,NF>& matrix,
432 const Arg& min,
const Arg& max )
const
434 randomize( matrix, min, max,
typename IsDenseMatrix<MT>::Type() );
449 template<
typename MT
453 template<
typename Arg >
454 inline void Rand< SymmetricMatrix<MT,SO,DF,NF> >
::randomize( SymmetricMatrix<MT,SO,DF,NF>& matrix,
455 const Arg& min,
const Arg& max,
TrueType )
const
461 const size_t n( matrix.rows() );
463 for(
size_t i=0UL; i<n; ++i ) {
464 for(
size_t j=0UL; j<=i; ++j ) {
465 matrix(i,j) = rand<ET>(
min,
max );
482 template<
typename MT
486 template<
typename Arg >
487 inline void Rand< SymmetricMatrix<MT,SO,DF,NF> >
::randomize( SymmetricMatrix<MT,SO,DF,NF>& matrix,
488 const Arg& min,
const Arg& max,
FalseType )
const
494 const size_t n( matrix.rows() );
496 if( n == 0UL )
return;
498 const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.5*n*n ) ) );
501 matrix.reserve( nonzeros );
503 while( matrix.nonZeros() < nonzeros ) {
504 matrix( rand<size_t>( 0UL, n-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ET>(
min,
max );
522 template<
typename MT
526 template<
typename Arg >
527 inline void Rand< SymmetricMatrix<MT,SO,DF,NF> >
::randomize( SymmetricMatrix<MT,SO,DF,NF>& matrix,
528 size_t nonzeros,
const Arg& min,
const Arg& max )
const
534 const size_t n( matrix.rows() );
537 throw std::invalid_argument(
"Invalid number of non-zero elements" );
539 if( n == 0UL )
return;
542 matrix.reserve( nonzeros );
544 while( matrix.nonZeros() < nonzeros ) {
545 matrix( rand<size_t>( 0UL, n-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ET>(
min,
max );
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:994
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:79
void randomize(T &value)
Randomization of a given variable.
Definition: Random.h:1043
Constraint on the data type.
Implementation of a random number generator.
Constraint on the data type.
Constraint on the data type.
Header file for the implementation of a symmetric matrix adaptor.
Header file for all basic SparseMatrix functionality.
void randomize(T &value) const
Randomization of the given variable with a new value in the range .
Definition: Random.h:262
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:947
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2476
Header file for the IsDenseMatrix type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_RESIZABLE(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:118
T generate() const
Generation of a random value in the range .
Definition: Random.h:222
Header file for all basic DenseMatrix functionality.
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE(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:79
boost::false_type 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 basic type definitions.
boost::true_type TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.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:79
Header file for the TrueType type/value trait base class.