35 #ifndef _BLAZE_MATH_UNILOWERMATRIX_H_ 36 #define _BLAZE_MATH_UNILOWERMATRIX_H_ 82 class Rand< UniLowerMatrix<MT,SO,DF> >
88 inline const UniLowerMatrix<MT,SO,DF>
generate()
const;
89 inline const UniLowerMatrix<MT,SO,DF>
generate(
size_t n )
const;
90 inline const UniLowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const;
92 template<
typename Arg >
93 inline const UniLowerMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const;
95 template<
typename Arg >
96 inline const UniLowerMatrix<MT,SO,DF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const;
98 template<
typename Arg >
99 inline const UniLowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros,
100 const Arg&
min,
const Arg&
max )
const;
107 inline void randomize( UniLowerMatrix<MT,SO,DF>& matrix )
const;
108 inline void randomize( UniLowerMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const;
109 inline void randomize( UniLowerMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const;
111 template<
typename Arg >
112 inline void randomize( UniLowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const;
114 template<
typename Arg >
115 inline void randomize( UniLowerMatrix<MT,false,DF>& matrix,
size_t nonzeros,
116 const Arg&
min,
const Arg&
max )
const;
118 template<
typename Arg >
119 inline void randomize( UniLowerMatrix<MT,true,DF>& matrix,
size_t nonzeros,
120 const Arg&
min,
const Arg&
max )
const;
131 template<
typename Arg >
134 template<
typename Arg >
149 template<
typename MT
152 inline const UniLowerMatrix<MT,SO,DF> Rand< UniLowerMatrix<MT,SO,DF> >::generate()
const 156 UniLowerMatrix<MT,SO,DF> matrix;
171 template<
typename MT
174 inline const UniLowerMatrix<MT,SO,DF>
175 Rand< UniLowerMatrix<MT,SO,DF> >::generate(
size_t n )
const 179 UniLowerMatrix<MT,SO,DF> matrix( n );
196 template<
typename MT
199 inline const UniLowerMatrix<MT,SO,DF>
200 Rand< UniLowerMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros )
const 205 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
209 UniLowerMatrix<MT,SO,DF> matrix( n );
226 template<
typename MT
229 template<
typename Arg >
230 inline const UniLowerMatrix<MT,SO,DF>
231 Rand< UniLowerMatrix<MT,SO,DF> >::generate(
const Arg&
min,
const Arg&
max )
const 235 UniLowerMatrix<MT,SO,DF> matrix;
252 template<
typename MT
255 template<
typename Arg >
256 inline const UniLowerMatrix<MT,SO,DF>
257 Rand< UniLowerMatrix<MT,SO,DF> >::generate(
size_t n,
const Arg&
min,
const Arg&
max )
const 261 UniLowerMatrix<MT,SO,DF> matrix( n );
280 template<
typename MT
283 template<
typename Arg >
284 inline const UniLowerMatrix<MT,SO,DF>
285 Rand< UniLowerMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros,
286 const Arg&
min,
const Arg&
max )
const 291 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
295 UniLowerMatrix<MT,SO,DF> matrix( n );
311 template<
typename MT
314 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix )
const 316 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
329 template<
typename MT
332 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
TrueType )
const 336 using ET = ElementType_t<MT>;
338 const size_t n( matrix.rows() );
340 for(
size_t i=1UL; i<n; ++i ) {
341 for(
size_t j=0UL; j<i; ++j ) {
342 matrix(i,j) = rand<ET>();
357 template<
typename MT
360 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
FalseType )
const 364 const size_t n( matrix.rows() );
366 if( n == 0UL || n == 1UL )
return;
368 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.2*n*n ) ) );
385 template<
typename MT
388 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const 392 using ET = ElementType_t<MT>;
394 const size_t n( matrix.rows() );
396 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
400 if( n == 0UL || n == 1UL )
return;
403 matrix.reserve( nonzeros );
404 matrix.finalize( 0UL );
406 std::vector<size_t> dist( n );
408 for(
size_t nz=0UL; nz<nonzeros; ) {
409 const size_t index = rand<size_t>( 1UL, n-1UL );
410 if( dist[index] == index )
continue;
415 for(
size_t i=1UL; i<n; ++i ) {
416 const Indices indices( 0UL, i-1UL, dist[i] );
417 for(
size_t j : indices ) {
418 matrix.append( i, j, rand<ET>() );
420 matrix.finalize( i );
436 template<
typename MT
439 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const 443 using ET = ElementType_t<MT>;
445 const size_t n( matrix.rows() );
447 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
451 if( n == 0UL || n == 1UL )
return;
454 matrix.reserve( nonzeros );
456 std::vector<size_t> dist( n-1UL );
458 for(
size_t nz=0UL; nz<nonzeros; ) {
459 const size_t index = rand<size_t>( 0UL, n-2UL );
460 if( dist[index] == n - index - 1UL )
continue;
465 for(
size_t j=0UL; j<n-1UL; ++j ) {
466 const Indices indices( j+1UL, n-1UL, dist[j] );
467 for(
size_t i : indices ) {
468 matrix.append( i, j, rand<ET>() );
470 matrix.finalize( j );
473 matrix.finalize( n-1UL );
488 template<
typename MT
491 template<
typename Arg >
492 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
493 const Arg&
min,
const Arg&
max )
const 510 template<
typename MT
513 template<
typename Arg >
514 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
519 using ET = ElementType_t<MT>;
521 const size_t n( matrix.rows() );
523 for(
size_t i=1UL; i<n; ++i ) {
524 for(
size_t j=0UL; j<i; ++j ) {
525 matrix(i,j) = rand<ET>(
min,
max );
542 template<
typename MT
545 template<
typename Arg >
546 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
551 const size_t n( matrix.rows() );
553 if( n == 0UL || n == 1UL )
return;
555 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.2*n*n ) ) );
574 template<
typename MT
577 template<
typename Arg >
578 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,false,DF>& matrix,
579 size_t nonzeros,
const Arg&
min,
const Arg&
max )
const 583 using ET = ElementType_t<MT>;
585 const size_t n( matrix.rows() );
587 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
591 if( n == 0UL || n == 1UL )
return;
594 matrix.reserve( nonzeros );
595 matrix.finalize( 0UL );
597 std::vector<size_t> dist( n );
599 for(
size_t nz=0UL; nz<nonzeros; ) {
600 const size_t index = rand<size_t>( 1UL, n-1UL );
601 if( dist[index] == index )
continue;
606 for(
size_t i=1UL; i<n; ++i ) {
607 const Indices indices( 0UL, i-1UL, dist[i] );
608 for(
size_t j : indices ) {
609 matrix.append( i, j, rand<ET>(
min,
max ) );
611 matrix.finalize( i );
629 template<
typename MT
632 template<
typename Arg >
633 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,true,DF>& matrix,
634 size_t nonzeros,
const Arg&
min,
const Arg&
max )
const 638 using ET = ElementType_t<MT>;
640 const size_t n( matrix.rows() );
642 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
646 if( n == 0UL || n == 1UL )
return;
649 matrix.reserve( nonzeros );
651 std::vector<size_t> dist( n-1UL );
653 for(
size_t nz=0UL; nz<nonzeros; ) {
654 const size_t index = rand<size_t>( 0UL, n-2UL );
655 if( dist[index] == n - index - 1UL )
continue;
660 for(
size_t j=0UL; j<n-1UL; ++j ) {
661 const Indices indices( j+1UL, n-1UL, dist[j] );
662 for(
size_t i : indices ) {
663 matrix.append( i, j, rand<ET>(
min,
max ) );
665 matrix.finalize( j );
668 matrix.finalize( n-1UL );
689 template<
typename MT
692 void makeSymmetric( UniLowerMatrix<MT,SO,DF>& matrix )
711 template<
typename MT
715 void makeSymmetric( UniLowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
719 makeSymmetric( matrix );
732 template<
typename MT
735 void makeHermitian( UniLowerMatrix<MT,SO,DF>& matrix )
754 template<
typename MT
758 void makeHermitian( UniLowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
762 makeHermitian( matrix );
775 template<
typename MT
778 void makePositiveDefinite( UniLowerMatrix<MT,SO,DF>& matrix )
780 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.
decltype(auto) ceil(const DenseMatrix< MT, SO > &dm)
Applies the ceil() function to each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1240
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
Header file for the MAYBE_UNUSED function template.
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
Header file for the complete UniUpperMatrix implementation.
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.
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 implementation of a lower unitriangular matrix adaptor.
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
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 implementation of a lower matrix adaptor.
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 strictly lower triangular 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