35 #ifndef _BLAZE_MATH_DIAGONALMATRIX_H_ 36 #define _BLAZE_MATH_DIAGONALMATRIX_H_ 77 class Rand< DiagonalMatrix<MT,SO,DF> >
83 inline const DiagonalMatrix<MT,SO,DF>
generate()
const;
84 inline const DiagonalMatrix<MT,SO,DF>
generate(
size_t n )
const;
85 inline const DiagonalMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const;
87 template<
typename Arg >
88 inline const DiagonalMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const;
90 template<
typename Arg >
91 inline const DiagonalMatrix<MT,SO,DF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const;
93 template<
typename Arg >
94 inline const DiagonalMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros,
95 const Arg&
min,
const Arg&
max )
const;
102 inline void randomize( DiagonalMatrix<MT,SO,DF>& matrix )
const;
103 inline void randomize( DiagonalMatrix<MT,SO,DF>& matrix,
size_t nonzeros )
const;
105 template<
typename Arg >
106 inline void randomize( DiagonalMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const;
108 template<
typename Arg >
109 inline void randomize( DiagonalMatrix<MT,SO,DF>& matrix,
size_t nonzeros,
110 const Arg&
min,
const Arg&
max )
const;
121 template<
typename Arg >
124 template<
typename Arg >
139 template<
typename MT
142 inline const DiagonalMatrix<MT,SO,DF> Rand< DiagonalMatrix<MT,SO,DF> >::generate()
const 146 DiagonalMatrix<MT,SO,DF> matrix;
161 template<
typename MT
164 inline const DiagonalMatrix<MT,SO,DF>
165 Rand< DiagonalMatrix<MT,SO,DF> >::generate(
size_t n )
const 169 DiagonalMatrix<MT,SO,DF> matrix( n );
186 template<
typename MT
189 inline const DiagonalMatrix<MT,SO,DF>
190 Rand< DiagonalMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros )
const 199 DiagonalMatrix<MT,SO,DF> matrix( n );
216 template<
typename MT
219 template<
typename Arg >
220 inline const DiagonalMatrix<MT,SO,DF>
221 Rand< DiagonalMatrix<MT,SO,DF> >::generate(
const Arg&
min,
const Arg&
max )
const 225 DiagonalMatrix<MT,SO,DF> matrix;
242 template<
typename MT
245 template<
typename Arg >
246 inline const DiagonalMatrix<MT,SO,DF>
247 Rand< DiagonalMatrix<MT,SO,DF> >::generate(
size_t n,
const Arg&
min,
const Arg&
max )
const 251 DiagonalMatrix<MT,SO,DF> matrix( n );
270 template<
typename MT
273 template<
typename Arg >
274 inline const DiagonalMatrix<MT,SO,DF>
275 Rand< DiagonalMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros,
276 const Arg&
min,
const Arg&
max )
const 281 if( nonzeros > DiagonalMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
285 DiagonalMatrix<MT,SO,DF> matrix( n );
301 template<
typename MT
304 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix )
const 306 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
319 template<
typename MT
322 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
TrueType )
const 326 using ET = ElementType_t<MT>;
328 const size_t n( matrix.rows() );
330 for(
size_t i=0UL; i<n; ++i ) {
331 matrix(i,i) = rand<ET>();
345 template<
typename MT
348 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
FalseType )
const 352 const size_t n( matrix.rows() );
354 if( n == 0UL )
return;
356 const size_t nonzeros( rand<size_t>( 1UL, n ) );
373 template<
typename MT
376 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
size_t nonzeros )
const 380 using ET = ElementType_t<MT>;
382 const size_t n( matrix.rows() );
388 if( n == 0UL )
return;
391 matrix.reserve( nonzeros );
393 Indices indices( 0UL, n-1UL, nonzeros );
396 for(
size_t index : indices ) {
397 for( ; i<index; ++i )
398 matrix.finalize( i );
399 matrix.append( i, i, rand<ET>() );
403 matrix.finalize( i );
419 template<
typename MT
422 template<
typename Arg >
423 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
424 const Arg&
min,
const Arg&
max )
const 441 template<
typename MT
444 template<
typename Arg >
445 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
450 using ET = ElementType_t<MT>;
452 const size_t n( matrix.rows() );
454 for(
size_t i=0UL; i<n; ++i ) {
455 matrix(i,i) = rand<ET>(
min,
max );
471 template<
typename MT
474 template<
typename Arg >
475 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
480 const size_t n( matrix.rows() );
482 if( n == 0UL )
return;
484 const size_t nonzeros( rand<size_t>( 1UL, n ) );
503 template<
typename MT
506 template<
typename Arg >
507 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
508 size_t nonzeros,
const Arg&
min,
const Arg&
max )
const 512 using ET = ElementType_t<MT>;
514 const size_t n( matrix.rows() );
520 if( n == 0UL )
return;
523 matrix.reserve( nonzeros );
525 Indices indices( 0UL, n-1UL, nonzeros );
528 for(
size_t index : indices ) {
529 for( ; i<index; ++i )
530 matrix.finalize( i );
531 matrix.append( i, i, rand<ET>(
min,
max ) );
535 matrix.finalize( i );
557 template<
typename MT
560 void makeSymmetric( DiagonalMatrix<MT,SO,DF>& matrix )
562 const size_t n( matrix.rows() );
566 for(
size_t i=0UL; i<n; ++i ) {
567 matrix(i,i) = rand< ElementType_t<MT> >();
585 template<
typename MT
589 void makeSymmetric( DiagonalMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
591 using Type = ElementType_t<MT>;
593 const size_t n( matrix.rows() );
597 for(
size_t i=0UL; i<n; ++i ) {
598 matrix(i,i) = rand<Type>(
min,
max );
614 template<
typename MT
617 void makeHermitian( DiagonalMatrix<MT,SO,DF>& matrix )
619 using Type = UnderlyingBuiltin_t< ElementType_t<MT> >;
621 const size_t n( matrix.rows() );
625 for(
size_t i=0UL; i<n; ++i ) {
626 matrix(i,i) = rand<Type>();
644 template<
typename MT
648 void makeHermitian( DiagonalMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
650 using Type = UnderlyingBuiltin_t< ElementType_t<MT> >;
652 const size_t n( matrix.rows() );
656 for(
size_t i=0UL; i<n; ++i ) {
657 matrix(i,i) = rand<Type>(
min,
max );
673 template<
typename MT
676 void makePositiveDefinite( DiagonalMatrix<MT,SO,DF>& matrix )
678 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: IntegralConstant.h:121
#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.
#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:595
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: IntegralConstant.h:132
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:1162
Header file for the exception macros of the math module.
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:1198
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:1406
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:1328
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 IntegralConstant class template.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression,...
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