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 typedef ElementType_<MT> ET;
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 typedef ElementType_<MT> ET;
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
426 randomize( matrix, min, max,
typename IsDenseMatrix<MT>::Type() );
441 template<
typename MT
444 template<
typename Arg >
445 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
446 const Arg& min,
const Arg& max,
TrueType )
const
450 typedef ElementType_<MT> ET;
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,
476 const Arg& min,
const Arg& max,
FalseType )
const
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 typedef ElementType_<MT> ET;
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_<MT> >();
585 template<
typename MT
589 void makeSymmetric( DiagonalMatrix<MT,SO,DF>& matrix,
const Arg& min,
const Arg& max )
591 typedef ElementType_<MT> Type;
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 typedef UnderlyingBuiltin_< ElementType_<MT> > Type;
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 typedef UnderlyingBuiltin_< ElementType_<MT> > Type;
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: 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 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
void randomize(T &value)
Randomization of a given variable.
Definition: Random.h:926
Constraint on the data type.
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:689
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1669
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:1716
Constraint on the data type.
Constraint on the data type.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
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:289
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(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
T generate() const
Generation of a random value in the range .
Definition: Random.h:249
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:61
Header file for the implementation of a diagonal matrix adaptor.
bool isHermitian(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is Hermitian.
Definition: DenseMatrix.h:759
#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.