35 #ifndef _BLAZE_MATH_UNIUPPERMATRIX_H_
36 #define _BLAZE_MATH_UNIUPPERMATRIX_H_
77 class Rand< UniUpperMatrix<MT,SO,DF> >
83 inline const UniUpperMatrix<MT,SO,DF>
generate()
const;
84 inline const UniUpperMatrix<MT,SO,DF>
generate(
size_t n )
const;
85 inline const UniUpperMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const;
87 template<
typename Arg >
88 inline const UniUpperMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const;
90 template<
typename Arg >
91 inline const UniUpperMatrix<MT,SO,DF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const;
93 template<
typename Arg >
94 inline const UniUpperMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros,
95 const Arg&
min,
const Arg&
max )
const;
102 inline void randomize( UniUpperMatrix<MT,SO,DF>& matrix )
const;
103 inline void randomize( UniUpperMatrix<MT,SO,DF>& matrix,
size_t nonzeros )
const;
105 template<
typename Arg >
106 inline void randomize( UniUpperMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const;
108 template<
typename Arg >
109 inline void randomize( UniUpperMatrix<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 UniUpperMatrix<MT,SO,DF> Rand< UniUpperMatrix<MT,SO,DF> >::generate()
const
146 UniUpperMatrix<MT,SO,DF> matrix;
161 template<
typename MT
164 inline const UniUpperMatrix<MT,SO,DF>
165 Rand< UniUpperMatrix<MT,SO,DF> >::generate(
size_t n )
const
169 UniUpperMatrix<MT,SO,DF> matrix( n );
186 template<
typename MT
189 inline const UniUpperMatrix<MT,SO,DF>
190 Rand< UniUpperMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros )
const
195 if( nonzeros > UniUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
199 UniUpperMatrix<MT,SO,DF> matrix( n );
216 template<
typename MT
219 template<
typename Arg >
220 inline const UniUpperMatrix<MT,SO,DF>
221 Rand< UniUpperMatrix<MT,SO,DF> >::generate(
const Arg&
min,
const Arg&
max )
const
225 UniUpperMatrix<MT,SO,DF> matrix;
242 template<
typename MT
245 template<
typename Arg >
246 inline const UniUpperMatrix<MT,SO,DF>
247 Rand< UniUpperMatrix<MT,SO,DF> >::generate(
size_t n,
const Arg&
min,
const Arg&
max )
const
251 UniUpperMatrix<MT,SO,DF> matrix( n );
270 template<
typename MT
273 template<
typename Arg >
274 inline const UniUpperMatrix<MT,SO,DF>
275 Rand< UniUpperMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros,
276 const Arg&
min,
const Arg&
max )
const
281 if( nonzeros > UniUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
285 UniUpperMatrix<MT,SO,DF> matrix( n );
301 template<
typename MT
304 inline void Rand< UniUpperMatrix<MT,SO,DF> >
::randomize( UniUpperMatrix<MT,SO,DF>& matrix )
const
306 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
319 template<
typename MT
322 inline void Rand< UniUpperMatrix<MT,SO,DF> >
::randomize( UniUpperMatrix<MT,SO,DF>& matrix,
TrueType )
const
328 const size_t n( matrix.rows() );
330 for(
size_t i=0UL; i<n; ++i ) {
331 for(
size_t j=i+1UL; j<n; ++j ) {
332 matrix(i,j) = rand<ET>();
347 template<
typename MT
350 inline void Rand< UniUpperMatrix<MT,SO,DF> >
::randomize( UniUpperMatrix<MT,SO,DF>& matrix,
FalseType )
const
356 const size_t n( matrix.rows() );
358 if( n == 0UL )
return;
360 const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.2*n*n ) ) );
363 matrix.reserve( nonzeros );
365 while( matrix.nonZeros() < nonzeros ) {
366 const size_t row( rand<size_t>( 0UL, n-1UL ) );
367 const size_t col( rand<size_t>(
row+1UL, n-1UL ) );
368 matrix(
row,col) = rand<ET>();
384 template<
typename MT
387 inline void Rand< UniUpperMatrix<MT,SO,DF> >
::randomize( UniUpperMatrix<MT,SO,DF>& matrix,
size_t nonzeros )
const
393 const size_t n( matrix.rows() );
395 if( nonzeros > UniUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
399 if( n == 0UL )
return;
402 matrix.reserve( nonzeros );
404 while( matrix.nonZeros() < nonzeros ) {
405 const size_t row( rand<size_t>( 0UL, n-1UL ) );
406 const size_t col( rand<size_t>(
row+1UL, n-1UL ) );
407 matrix(
row,col) = rand<ET>();
423 template<
typename MT
426 template<
typename Arg >
427 inline void Rand< UniUpperMatrix<MT,SO,DF> >
::randomize( UniUpperMatrix<MT,SO,DF>& matrix,
428 const Arg& min,
const Arg& max )
const
430 randomize( matrix, min, max,
typename IsDenseMatrix<MT>::Type() );
445 template<
typename MT
448 template<
typename Arg >
449 inline void Rand< UniUpperMatrix<MT,SO,DF> >
::randomize( UniUpperMatrix<MT,SO,DF>& matrix,
450 const Arg& min,
const Arg& max,
TrueType )
const
456 const size_t n( matrix.rows() );
458 for(
size_t i=0UL; i<n; ++i ) {
459 for(
size_t j=i+1UL; j<n; ++j ) {
460 matrix(i,j) = rand<ET>(
min,
max );
477 template<
typename MT
480 template<
typename Arg >
481 inline void Rand< UniUpperMatrix<MT,SO,DF> >
::randomize( UniUpperMatrix<MT,SO,DF>& matrix,
482 const Arg& min,
const Arg& max,
FalseType )
const
488 const size_t n( matrix.rows() );
490 if( n == 0UL )
return;
492 const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.2*n*n ) ) );
495 matrix.reserve( nonzeros );
497 while( matrix.nonZeros() < nonzeros ) {
498 const size_t row( rand<size_t>( 0UL, n-1UL ) );
499 const size_t col( rand<size_t>(
row+1UL, n-1UL ) );
518 template<
typename MT
521 template<
typename Arg >
522 inline void Rand< UniUpperMatrix<MT,SO,DF> >
::randomize( UniUpperMatrix<MT,SO,DF>& matrix,
523 size_t nonzeros,
const Arg& min,
const Arg& max )
const
529 const size_t n( matrix.rows() );
531 if( nonzeros > UniUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
535 if( n == 0UL )
return;
538 matrix.reserve( nonzeros );
540 while( matrix.nonZeros() < nonzeros ) {
541 const size_t row( rand<size_t>( 0UL, n-1UL ) );
542 const size_t col( rand<size_t>(
row+1UL, n-1UL ) );
565 template<
typename MT
568 void makeSymmetric( UniUpperMatrix<MT,SO,DF>& matrix )
587 template<
typename MT
591 void makeSymmetric( UniUpperMatrix<MT,SO,DF>& matrix,
const Arg& min,
const Arg& max )
595 makeSymmetric( matrix );
608 template<
typename MT
611 void makeHermitian( UniUpperMatrix<MT,SO,DF>& matrix )
630 template<
typename MT
634 void makeHermitian( UniUpperMatrix<MT,SO,DF>& matrix,
const Arg& min,
const Arg& max )
638 makeHermitian( matrix );
651 template<
typename MT
654 void makePositiveDefinite( UniUpperMatrix<MT,SO,DF>& matrix )
656 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 complete UniLowerMatrix implementation.
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.
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.
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.
Header file for the implementation of a upper unitriangular matrix adaptor.
#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.