35 #ifndef _BLAZE_MATH_DIAGONALMATRIX_H_ 36 #define _BLAZE_MATH_DIAGONALMATRIX_H_ 78 class Rand< DiagonalMatrix<MT,SO,DF> >
84 inline const DiagonalMatrix<MT,SO,DF>
generate()
const;
85 inline const DiagonalMatrix<MT,SO,DF>
generate(
size_t n )
const;
86 inline const DiagonalMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const;
88 template<
typename Arg >
89 inline const DiagonalMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const;
91 template<
typename Arg >
92 inline const DiagonalMatrix<MT,SO,DF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const;
94 template<
typename Arg >
95 inline const DiagonalMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros,
96 const Arg&
min,
const Arg&
max )
const;
103 inline void randomize( DiagonalMatrix<MT,SO,DF>& matrix )
const;
104 inline void randomize( DiagonalMatrix<MT,SO,DF>& matrix,
size_t nonzeros )
const;
106 template<
typename Arg >
107 inline void randomize( DiagonalMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const;
109 template<
typename Arg >
110 inline void randomize( DiagonalMatrix<MT,SO,DF>& matrix,
size_t nonzeros,
111 const Arg&
min,
const Arg&
max )
const;
122 template<
typename Arg >
125 template<
typename Arg >
140 template<
typename MT
143 inline const DiagonalMatrix<MT,SO,DF> Rand< DiagonalMatrix<MT,SO,DF> >
::generate()
const 147 DiagonalMatrix<MT,SO,DF> matrix;
162 template<
typename MT
165 inline const DiagonalMatrix<MT,SO,DF>
166 Rand< DiagonalMatrix<MT,SO,DF> >
::generate(
size_t n )
const 170 DiagonalMatrix<MT,SO,DF> matrix( n );
187 template<
typename MT
190 inline const DiagonalMatrix<MT,SO,DF>
191 Rand< DiagonalMatrix<MT,SO,DF> >
::generate(
size_t n,
size_t nonzeros )
const 200 DiagonalMatrix<MT,SO,DF> matrix( n );
217 template<
typename MT
220 template<
typename Arg >
221 inline const DiagonalMatrix<MT,SO,DF>
222 Rand< DiagonalMatrix<MT,SO,DF> >
::generate(
const Arg&
min,
const Arg&
max )
const 226 DiagonalMatrix<MT,SO,DF> matrix;
243 template<
typename MT
246 template<
typename Arg >
247 inline const DiagonalMatrix<MT,SO,DF>
248 Rand< DiagonalMatrix<MT,SO,DF> >
::generate(
size_t n,
const Arg&
min,
const Arg&
max )
const 252 DiagonalMatrix<MT,SO,DF> matrix( n );
271 template<
typename MT
274 template<
typename Arg >
275 inline const DiagonalMatrix<MT,SO,DF>
276 Rand< DiagonalMatrix<MT,SO,DF> >
::generate(
size_t n,
size_t nonzeros,
277 const Arg&
min,
const Arg&
max )
const 282 if( nonzeros > DiagonalMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
286 DiagonalMatrix<MT,SO,DF> matrix( n );
302 template<
typename MT
305 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix )
const 307 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
320 template<
typename MT
323 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
TrueType )
const 327 using ET = ElementType_<MT>;
329 const size_t n( matrix.rows() );
331 for(
size_t i=0UL; i<n; ++i ) {
332 matrix(i,i) = rand<ET>();
346 template<
typename MT
349 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
FalseType )
const 353 const size_t n( matrix.rows() );
355 if( n == 0UL )
return;
357 const size_t nonzeros( rand<size_t>( 1UL, n ) );
374 template<
typename MT
377 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
size_t nonzeros )
const 381 using ET = ElementType_<MT>;
383 const size_t n( matrix.rows() );
389 if( n == 0UL )
return;
392 matrix.reserve( nonzeros );
394 Indices indices( 0UL, n-1UL, nonzeros );
397 for(
size_t index : indices ) {
398 for( ; i<index; ++i )
399 matrix.finalize( i );
400 matrix.append( i, i, rand<ET>() );
404 matrix.finalize( i );
420 template<
typename MT
423 template<
typename Arg >
424 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
425 const Arg& min,
const Arg& max )
const 427 randomize( matrix, min, max,
typename IsDenseMatrix<MT>::Type() );
442 template<
typename MT
445 template<
typename Arg >
446 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
447 const Arg& min,
const Arg& max,
TrueType )
const 451 using ET = ElementType_<MT>;
453 const size_t n( matrix.rows() );
455 for(
size_t i=0UL; i<n; ++i ) {
456 matrix(i,i) = rand<ET>(
min,
max );
472 template<
typename MT
475 template<
typename Arg >
476 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
477 const Arg& min,
const Arg& max,
FalseType )
const 481 const size_t n( matrix.rows() );
483 if( n == 0UL )
return;
485 const size_t nonzeros( rand<size_t>( 1UL, n ) );
504 template<
typename MT
507 template<
typename Arg >
508 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
509 size_t nonzeros,
const Arg& min,
const Arg& max )
const 513 using ET = ElementType_<MT>;
515 const size_t n( matrix.rows() );
521 if( n == 0UL )
return;
524 matrix.reserve( nonzeros );
526 Indices indices( 0UL, n-1UL, nonzeros );
529 for(
size_t index : indices ) {
530 for( ; i<index; ++i )
531 matrix.finalize( i );
532 matrix.append( i, i, rand<ET>( min, max ) );
536 matrix.finalize( i );
558 template<
typename MT
561 void makeSymmetric( DiagonalMatrix<MT,SO,DF>& matrix )
563 const size_t n( matrix.rows() );
567 for(
size_t i=0UL; i<n; ++i ) {
568 matrix(i,i) = rand< ElementType_<MT> >();
586 template<
typename MT
590 void makeSymmetric( DiagonalMatrix<MT,SO,DF>& matrix,
const Arg& min,
const Arg& max )
592 using Type = ElementType_<MT>;
594 const size_t n( matrix.rows() );
598 for(
size_t i=0UL; i<n; ++i ) {
599 matrix(i,i) = rand<Type>(
min,
max );
615 template<
typename MT
618 void makeHermitian( DiagonalMatrix<MT,SO,DF>& matrix )
620 using Type = UnderlyingBuiltin_< ElementType_<MT> >;
622 const size_t n( matrix.rows() );
626 for(
size_t i=0UL; i<n; ++i ) {
627 matrix(i,i) = rand<Type>();
645 template<
typename MT
649 void makeHermitian( DiagonalMatrix<MT,SO,DF>& matrix,
const Arg& min,
const Arg& max )
651 using Type = UnderlyingBuiltin_< ElementType_<MT> >;
653 const size_t n( matrix.rows() );
657 for(
size_t i=0UL; i<n; ++i ) {
658 matrix(i,i) = rand<Type>(
min,
max );
674 template<
typename MT
677 void makePositiveDefinite( DiagonalMatrix<MT,SO,DF>& matrix )
679 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 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.
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 UnderlyingBuiltin type trait.
Header file for the exception macros of the math module.
Header file for the IsDenseMatrix type trait.
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.
#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.
#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.