35 #ifndef _BLAZE_MATH_UNILOWERMATRIX_H_
36 #define _BLAZE_MATH_UNILOWERMATRIX_H_
78 class Rand< UniLowerMatrix<MT,SO,DF> >
84 inline const UniLowerMatrix<MT,SO,DF>
generate()
const;
85 inline const UniLowerMatrix<MT,SO,DF>
generate(
size_t n )
const;
86 inline const UniLowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const;
88 template<
typename Arg >
89 inline const UniLowerMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const;
91 template<
typename Arg >
92 inline const UniLowerMatrix<MT,SO,DF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const;
94 template<
typename Arg >
95 inline const UniLowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros,
96 const Arg&
min,
const Arg&
max )
const;
103 inline void randomize( UniLowerMatrix<MT,SO,DF>& matrix )
const;
104 inline void randomize( UniLowerMatrix<MT,SO,DF>& matrix,
size_t nonzeros )
const;
106 template<
typename Arg >
107 inline void randomize( UniLowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const;
109 template<
typename Arg >
110 inline void randomize( UniLowerMatrix<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 UniLowerMatrix<MT,SO,DF> Rand< UniLowerMatrix<MT,SO,DF> >::generate()
const
147 UniLowerMatrix<MT,SO,DF> matrix;
162 template<
typename MT
165 inline const UniLowerMatrix<MT,SO,DF>
166 Rand< UniLowerMatrix<MT,SO,DF> >::generate(
size_t n )
const
170 UniLowerMatrix<MT,SO,DF> matrix( n );
187 template<
typename MT
190 inline const UniLowerMatrix<MT,SO,DF>
191 Rand< UniLowerMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros )
const
196 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
200 UniLowerMatrix<MT,SO,DF> matrix( n );
217 template<
typename MT
220 template<
typename Arg >
221 inline const UniLowerMatrix<MT,SO,DF>
222 Rand< UniLowerMatrix<MT,SO,DF> >::generate(
const Arg&
min,
const Arg&
max )
const
226 UniLowerMatrix<MT,SO,DF> matrix;
243 template<
typename MT
246 template<
typename Arg >
247 inline const UniLowerMatrix<MT,SO,DF>
248 Rand< UniLowerMatrix<MT,SO,DF> >::generate(
size_t n,
const Arg&
min,
const Arg&
max )
const
252 UniLowerMatrix<MT,SO,DF> matrix( n );
271 template<
typename MT
274 template<
typename Arg >
275 inline const UniLowerMatrix<MT,SO,DF>
276 Rand< UniLowerMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros,
277 const Arg&
min,
const Arg&
max )
const
282 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
286 UniLowerMatrix<MT,SO,DF> matrix( n );
302 template<
typename MT
305 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix )
const
307 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
320 template<
typename MT
323 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
TrueType )
const
329 const size_t n( matrix.rows() );
331 for(
size_t i=1UL; i<n; ++i ) {
332 for(
size_t j=0UL; j<i; ++j ) {
333 matrix(i,j) = rand<ET>();
348 template<
typename MT
351 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
FalseType )
const
357 const size_t n( matrix.rows() );
359 if( n == 0UL )
return;
361 const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.2*n*n ) ) );
364 matrix.reserve( nonzeros );
366 while( matrix.nonZeros() < nonzeros ) {
367 const size_t row( rand<size_t>( 1UL, n-1UL ) );
368 const size_t col( rand<size_t>( 0UL,
row-1UL ) );
369 matrix(
row,col) = rand<ET>();
385 template<
typename MT
388 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
size_t nonzeros )
const
394 const size_t n( matrix.rows() );
396 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
400 if( n == 0UL )
return;
403 matrix.reserve( nonzeros );
405 while( matrix.nonZeros() < nonzeros ) {
406 const size_t row( rand<size_t>( 1UL, n-1UL ) );
407 const size_t col( rand<size_t>( 0UL,
row-1UL ) );
408 matrix(
row,col) = rand<ET>();
424 template<
typename MT
427 template<
typename Arg >
428 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
429 const Arg& min,
const Arg& max )
const
431 randomize( matrix, min, max,
typename IsDenseMatrix<MT>::Type() );
446 template<
typename MT
449 template<
typename Arg >
450 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
451 const Arg& min,
const Arg& max,
TrueType )
const
457 const size_t n( matrix.rows() );
459 for(
size_t i=1UL; i<n; ++i ) {
460 for(
size_t j=0UL; j<i; ++j ) {
461 matrix(i,j) = rand<ET>(
min,
max );
478 template<
typename MT
481 template<
typename Arg >
482 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
483 const Arg& min,
const Arg& max,
FalseType )
const
489 const size_t n( matrix.rows() );
491 if( n == 0UL )
return;
493 const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.2*n*n ) ) );
496 matrix.reserve( nonzeros );
498 while( matrix.nonZeros() < nonzeros ) {
499 const size_t row( rand<size_t>( 1UL, n-1UL ) );
500 const size_t col( rand<size_t>( 0UL,
row-1UL ) );
519 template<
typename MT
522 template<
typename Arg >
523 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
524 size_t nonzeros,
const Arg& min,
const Arg& max )
const
530 const size_t n( matrix.rows() );
532 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
536 if( n == 0UL )
return;
539 matrix.reserve( nonzeros );
541 while( matrix.nonZeros() < nonzeros ) {
542 const size_t row( rand<size_t>( 1UL, n-1UL ) );
543 const size_t col( rand<size_t>( 0UL,
row-1UL ) );
566 template<
typename MT
569 void makeSymmetric( UniLowerMatrix<MT,SO,DF>& matrix )
588 template<
typename MT
592 void makeSymmetric( UniLowerMatrix<MT,SO,DF>& matrix,
const Arg& min,
const Arg& max )
596 makeSymmetric( matrix );
609 template<
typename MT
612 void makeHermitian( UniLowerMatrix<MT,SO,DF>& matrix )
631 template<
typename MT
635 void makeHermitian( UniLowerMatrix<MT,SO,DF>& matrix,
const Arg& min,
const Arg& max )
639 makeHermitian( matrix );
652 template<
typename MT
655 void makePositiveDefinite( UniLowerMatrix<MT,SO,DF>& matrix )
657 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 the UNUSED_PARAMETER function template.
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
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Implementation of a random number generator.
Header file for the complete UniUpperMatrix implementation.
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
Header file for the implementation of a lower unitriangular matrix adaptor.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
Header file for the IsDenseMatrix type trait.
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename RowExprTrait< MT >::Type >::Type row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:107
#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
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.