35 #ifndef _BLAZE_MATH_UNILOWERMATRIX_H_ 36 #define _BLAZE_MATH_UNILOWERMATRIX_H_ 83 class Rand< UniLowerMatrix<MT,SO,DF> >
89 inline const UniLowerMatrix<MT,SO,DF>
generate()
const;
90 inline const UniLowerMatrix<MT,SO,DF>
generate(
size_t n )
const;
91 inline const UniLowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const;
93 template<
typename Arg >
94 inline const UniLowerMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const;
96 template<
typename Arg >
97 inline const UniLowerMatrix<MT,SO,DF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const;
99 template<
typename Arg >
100 inline const UniLowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros,
101 const Arg&
min,
const Arg&
max )
const;
108 inline void randomize( UniLowerMatrix<MT,SO,DF>& matrix )
const;
109 inline void randomize( UniLowerMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const;
110 inline void randomize( UniLowerMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const;
112 template<
typename Arg >
113 inline void randomize( UniLowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const;
115 template<
typename Arg >
116 inline void randomize( UniLowerMatrix<MT,false,DF>& matrix,
size_t nonzeros,
117 const Arg&
min,
const Arg&
max )
const;
119 template<
typename Arg >
120 inline void randomize( UniLowerMatrix<MT,true,DF>& matrix,
size_t nonzeros,
121 const Arg&
min,
const Arg&
max )
const;
132 template<
typename Arg >
135 template<
typename Arg >
150 template<
typename MT
153 inline const UniLowerMatrix<MT,SO,DF> Rand< UniLowerMatrix<MT,SO,DF> >
::generate()
const 157 UniLowerMatrix<MT,SO,DF> matrix;
172 template<
typename MT
175 inline const UniLowerMatrix<MT,SO,DF>
176 Rand< UniLowerMatrix<MT,SO,DF> >
::generate(
size_t n )
const 180 UniLowerMatrix<MT,SO,DF> matrix( n );
197 template<
typename MT
200 inline const UniLowerMatrix<MT,SO,DF>
201 Rand< UniLowerMatrix<MT,SO,DF> >
::generate(
size_t n,
size_t nonzeros )
const 206 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
210 UniLowerMatrix<MT,SO,DF> matrix( n );
227 template<
typename MT
230 template<
typename Arg >
231 inline const UniLowerMatrix<MT,SO,DF>
232 Rand< UniLowerMatrix<MT,SO,DF> >
::generate(
const Arg&
min,
const Arg&
max )
const 236 UniLowerMatrix<MT,SO,DF> matrix;
253 template<
typename MT
256 template<
typename Arg >
257 inline const UniLowerMatrix<MT,SO,DF>
258 Rand< UniLowerMatrix<MT,SO,DF> >
::generate(
size_t n,
const Arg&
min,
const Arg&
max )
const 262 UniLowerMatrix<MT,SO,DF> matrix( n );
281 template<
typename MT
284 template<
typename Arg >
285 inline const UniLowerMatrix<MT,SO,DF>
286 Rand< UniLowerMatrix<MT,SO,DF> >
::generate(
size_t n,
size_t nonzeros,
287 const Arg&
min,
const Arg&
max )
const 292 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
296 UniLowerMatrix<MT,SO,DF> matrix( n );
312 template<
typename MT
315 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix )
const 317 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
330 template<
typename MT
333 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
TrueType )
const 337 using ET = ElementType_<MT>;
339 const size_t n( matrix.rows() );
341 for(
size_t i=1UL; i<n; ++i ) {
342 for(
size_t j=0UL; j<i; ++j ) {
343 matrix(i,j) = rand<ET>();
358 template<
typename MT
361 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
FalseType )
const 365 const size_t n( matrix.rows() );
367 if( n == 0UL || n == 1UL )
return;
369 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.2*n*n ) ) );
386 template<
typename MT
389 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const 393 using ET = ElementType_<MT>;
395 const size_t n( matrix.rows() );
397 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
401 if( n == 0UL || n == 1UL )
return;
404 matrix.reserve( nonzeros );
405 matrix.finalize( 0UL );
407 std::vector<size_t> dist( n );
409 for(
size_t nz=0UL; nz<nonzeros; ) {
410 const size_t index = rand<size_t>( 1UL, n-1UL );
411 if( dist[index] == index )
continue;
416 for(
size_t i=1UL; i<n; ++i ) {
417 const Indices indices( 0UL, i-1UL, dist[i] );
418 for(
size_t j : indices ) {
419 matrix.append( i, j, rand<ET>() );
421 matrix.finalize( i );
437 template<
typename MT
440 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const 444 using ET = ElementType_<MT>;
446 const size_t n( matrix.rows() );
448 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
452 if( n == 0UL || n == 1UL )
return;
455 matrix.reserve( nonzeros );
457 std::vector<size_t> dist( n-1UL );
459 for(
size_t nz=0UL; nz<nonzeros; ) {
460 const size_t index = rand<size_t>( 0UL, n-2UL );
461 if( dist[index] == n - index - 1UL )
continue;
466 for(
size_t j=0UL; j<n-1UL; ++j ) {
467 const Indices indices( j+1UL, n-1UL, dist[j] );
468 for(
size_t i : indices ) {
469 matrix.append( i, j, rand<ET>() );
471 matrix.finalize( j );
474 matrix.finalize( n-1UL );
489 template<
typename MT
492 template<
typename Arg >
493 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
494 const Arg& min,
const Arg& max )
const 496 randomize( matrix, min, max,
typename IsDenseMatrix<MT>::Type() );
511 template<
typename MT
514 template<
typename Arg >
515 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
516 const Arg& min,
const Arg& max,
TrueType )
const 520 using ET = ElementType_<MT>;
522 const size_t n( matrix.rows() );
524 for(
size_t i=1UL; i<n; ++i ) {
525 for(
size_t j=0UL; j<i; ++j ) {
526 matrix(i,j) = rand<ET>(
min,
max );
543 template<
typename MT
546 template<
typename Arg >
547 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
548 const Arg& min,
const Arg& max,
FalseType )
const 552 const size_t n( matrix.rows() );
554 if( n == 0UL || n == 1UL )
return;
556 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.2*n*n ) ) );
575 template<
typename MT
578 template<
typename Arg >
579 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,false,DF>& matrix,
580 size_t nonzeros,
const Arg& min,
const Arg& max )
const 584 using ET = ElementType_<MT>;
586 const size_t n( matrix.rows() );
588 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
592 if( n == 0UL || n == 1UL )
return;
595 matrix.reserve( nonzeros );
596 matrix.finalize( 0UL );
598 std::vector<size_t> dist( n );
600 for(
size_t nz=0UL; nz<nonzeros; ) {
601 const size_t index = rand<size_t>( 1UL, n-1UL );
602 if( dist[index] == index )
continue;
607 for(
size_t i=1UL; i<n; ++i ) {
608 const Indices indices( 0UL, i-1UL, dist[i] );
609 for(
size_t j : indices ) {
610 matrix.append( i, j, rand<ET>( min, max ) );
612 matrix.finalize( i );
630 template<
typename MT
633 template<
typename Arg >
634 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,true,DF>& matrix,
635 size_t nonzeros,
const Arg& min,
const Arg& max )
const 639 using ET = ElementType_<MT>;
641 const size_t n( matrix.rows() );
643 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
647 if( n == 0UL || n == 1UL )
return;
650 matrix.reserve( nonzeros );
652 std::vector<size_t> dist( n-1UL );
654 for(
size_t nz=0UL; nz<nonzeros; ) {
655 const size_t index = rand<size_t>( 0UL, n-2UL );
656 if( dist[index] == n - index - 1UL )
continue;
661 for(
size_t j=0UL; j<n-1UL; ++j ) {
662 const Indices indices( j+1UL, n-1UL, dist[j] );
663 for(
size_t i : indices ) {
664 matrix.append( i, j, rand<ET>( min, max ) );
666 matrix.finalize( j );
669 matrix.finalize( n-1UL );
690 template<
typename MT
693 void makeSymmetric( UniLowerMatrix<MT,SO,DF>& matrix )
712 template<
typename MT
716 void makeSymmetric( UniLowerMatrix<MT,SO,DF>& matrix,
const Arg& min,
const Arg& max )
720 makeSymmetric( matrix );
733 template<
typename MT
736 void makeHermitian( UniLowerMatrix<MT,SO,DF>& matrix )
755 template<
typename MT
759 void makeHermitian( UniLowerMatrix<MT,SO,DF>& matrix,
const Arg& min,
const Arg& max )
763 makeHermitian( matrix );
776 template<
typename MT
779 void makePositiveDefinite( UniLowerMatrix<MT,SO,DF>& matrix )
781 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 auxiliary alias declarations.
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: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:1234
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:588
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1903
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:1950
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.
Header file for the implementation of a lower unitriangular matrix adaptor.
Header file for the exception macros of the math module.
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:919
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:841
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. ...
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
#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.