35 #ifndef _BLAZE_MATH_DIAGONALMATRIX_H_
36 #define _BLAZE_MATH_DIAGONALMATRIX_H_
75 class Rand< DiagonalMatrix<MT,SO,DF> >
81 inline const DiagonalMatrix<MT,SO,DF>
generate()
const;
82 inline const DiagonalMatrix<MT,SO,DF>
generate(
size_t n )
const;
83 inline const DiagonalMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const;
85 template<
typename Arg >
86 inline const DiagonalMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const;
88 template<
typename Arg >
89 inline const DiagonalMatrix<MT,SO,DF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const;
91 template<
typename Arg >
92 inline const DiagonalMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros,
93 const Arg&
min,
const Arg&
max )
const;
100 inline void randomize( DiagonalMatrix<MT,SO,DF>& matrix )
const;
101 inline void randomize( DiagonalMatrix<MT,SO,DF>& matrix,
size_t nonzeros )
const;
103 template<
typename Arg >
104 inline void randomize( DiagonalMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const;
106 template<
typename Arg >
107 inline void randomize( DiagonalMatrix<MT,SO,DF>& matrix,
size_t nonzeros,
108 const Arg&
min,
const Arg&
max )
const;
119 template<
typename Arg >
122 template<
typename Arg >
137 template<
typename MT
140 inline const DiagonalMatrix<MT,SO,DF> Rand< DiagonalMatrix<MT,SO,DF> >::generate()
const
144 DiagonalMatrix<MT,SO,DF> matrix;
159 template<
typename MT
162 inline const DiagonalMatrix<MT,SO,DF>
163 Rand< DiagonalMatrix<MT,SO,DF> >::generate(
size_t n )
const
167 DiagonalMatrix<MT,SO,DF> matrix( n );
184 template<
typename MT
187 inline const DiagonalMatrix<MT,SO,DF>
188 Rand< DiagonalMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros )
const
197 DiagonalMatrix<MT,SO,DF> matrix( n );
214 template<
typename MT
217 template<
typename Arg >
218 inline const DiagonalMatrix<MT,SO,DF>
219 Rand< DiagonalMatrix<MT,SO,DF> >::generate(
const Arg&
min,
const Arg&
max )
const
223 DiagonalMatrix<MT,SO,DF> matrix;
240 template<
typename MT
243 template<
typename Arg >
244 inline const DiagonalMatrix<MT,SO,DF>
245 Rand< DiagonalMatrix<MT,SO,DF> >::generate(
size_t n,
const Arg&
min,
const Arg&
max )
const
249 DiagonalMatrix<MT,SO,DF> matrix( n );
268 template<
typename MT
271 template<
typename Arg >
272 inline const DiagonalMatrix<MT,SO,DF>
273 Rand< DiagonalMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros,
274 const Arg&
min,
const Arg&
max )
const
279 if( nonzeros > DiagonalMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
283 DiagonalMatrix<MT,SO,DF> matrix( n );
299 template<
typename MT
302 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix )
const
304 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
317 template<
typename MT
320 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
TrueType )
const
326 const size_t n( matrix.rows() );
328 for(
size_t i=0UL; i<n; ++i ) {
329 matrix(i,i) = rand<ET>();
343 template<
typename MT
346 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 ) );
359 matrix.reserve( nonzeros );
361 while( matrix.nonZeros() < nonzeros ) {
362 const size_t i( rand<size_t>( 0UL, n-1UL ) );
363 matrix(i,i) = rand<ET>();
379 template<
typename MT
382 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
size_t nonzeros )
const
388 const size_t n( matrix.rows() );
394 if( n == 0UL )
return;
397 matrix.reserve( nonzeros );
399 while( matrix.nonZeros() < nonzeros ) {
400 const size_t i( rand<size_t>( 0UL, n-1UL ) );
401 matrix(i,i) = rand<ET>();
417 template<
typename MT
420 template<
typename Arg >
421 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
422 const Arg& min,
const Arg& max )
const
424 randomize( matrix, min, max,
typename IsDenseMatrix<MT>::Type() );
439 template<
typename MT
442 template<
typename Arg >
443 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
444 const Arg& min,
const Arg& max,
TrueType )
const
450 const size_t n( matrix.rows() );
452 for(
size_t i=0UL; i<n; ++i ) {
453 matrix(i,i) = rand<ET>(
min,
max );
469 template<
typename MT
472 template<
typename Arg >
473 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
474 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 ) );
487 matrix.reserve( nonzeros );
489 while( matrix.nonZeros() < nonzeros ) {
490 const size_t i( rand<size_t>( 0UL, n-1UL ) );
491 matrix(i,i) = rand<ET>(
min,
max );
509 template<
typename MT
512 template<
typename Arg >
513 inline void Rand< DiagonalMatrix<MT,SO,DF> >
::randomize( DiagonalMatrix<MT,SO,DF>& matrix,
514 size_t nonzeros,
const Arg& min,
const Arg& max )
const
520 const size_t n( matrix.rows() );
526 if( n == 0UL )
return;
529 matrix.reserve( nonzeros );
531 while( matrix.nonZeros() < nonzeros ) {
532 const size_t i( rand<size_t>( 0UL, n-1UL ) );
533 matrix(i,i) = rand<ET>(
min,
max );
555 template<
typename MT
558 void makeSymmetric( DiagonalMatrix<MT,SO,DF>& matrix )
560 const size_t n( matrix.rows() );
564 for(
size_t i=0UL; i<n; ++i ) {
565 matrix(i,i) = rand<typename MT::ElementType>();
583 template<
typename MT
587 void makeSymmetric( DiagonalMatrix<MT,SO,DF>& matrix,
const Arg& min,
const Arg& max )
591 const size_t n( matrix.rows() );
595 for(
size_t i=0UL; i<n; ++i ) {
596 matrix(i,i) = rand<Type>(
min,
max );
612 template<
typename MT
615 void makeHermitian( DiagonalMatrix<MT,SO,DF>& matrix )
617 typedef typename UnderlyingBuiltin<typename MT::ElementType>::Type Type;
619 const size_t n( matrix.rows() );
623 for(
size_t i=0UL; i<n; ++i ) {
624 matrix(i,i) = rand<Type>();
642 template<
typename MT
646 void makeHermitian( DiagonalMatrix<MT,SO,DF>& matrix,
const Arg& min,
const Arg& max )
648 typedef typename UnderlyingBuiltin<typename MT::ElementType>::Type Type;
650 const size_t n( matrix.rows() );
654 for(
size_t i=0UL; i<n; ++i ) {
655 matrix(i,i) = rand<Type>(
min,
max );
671 template<
typename MT
674 void makePositiveDefinite( DiagonalMatrix<MT,SO,DF>& matrix )
676 makeHermitian( matrix );
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1729
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:79
void randomize(T &value)
Randomization of a given variable.
Definition: Random.h:1041
Constraint on the data type.
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:697
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:507
Implementation of a random number generator.
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:260
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1682
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
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:220
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
Header file for the implementation of a diagonal matrix adaptor.
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
bool isHermitian(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is Hermitian.
Definition: DenseMatrix.h:767
Header file for exception macros.
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_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:79
Header file for the TrueType type/value trait base class.