35 #ifndef _BLAZE_MATH_LOWERMATRIX_H_ 36 #define _BLAZE_MATH_LOWERMATRIX_H_ 81 class Rand< LowerMatrix<MT,SO,DF> >
87 inline const LowerMatrix<MT,SO,DF>
generate()
const;
88 inline const LowerMatrix<MT,SO,DF>
generate(
size_t n )
const;
89 inline const LowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const;
91 template<
typename Arg >
92 inline const LowerMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const;
94 template<
typename Arg >
95 inline const LowerMatrix<MT,SO,DF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const;
97 template<
typename Arg >
98 inline const LowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros,
99 const Arg&
min,
const Arg&
max )
const;
106 inline void randomize( LowerMatrix<MT,SO,DF>& matrix )
const;
107 inline void randomize( LowerMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const;
108 inline void randomize( LowerMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const;
110 template<
typename Arg >
111 inline void randomize( LowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const;
113 template<
typename Arg >
114 inline void randomize( LowerMatrix<MT,false,DF>& matrix,
size_t nonzeros,
115 const Arg&
min,
const Arg&
max )
const;
117 template<
typename Arg >
118 inline void randomize( LowerMatrix<MT,true,DF>& matrix,
size_t nonzeros,
119 const Arg&
min,
const Arg&
max )
const;
130 template<
typename Arg >
133 template<
typename Arg >
148 template<
typename MT
151 inline const LowerMatrix<MT,SO,DF> Rand< LowerMatrix<MT,SO,DF> >::generate()
const 155 LowerMatrix<MT,SO,DF> matrix;
170 template<
typename MT
173 inline const LowerMatrix<MT,SO,DF>
174 Rand< LowerMatrix<MT,SO,DF> >::generate(
size_t n )
const 178 LowerMatrix<MT,SO,DF> matrix( n );
195 template<
typename MT
198 inline const LowerMatrix<MT,SO,DF>
199 Rand< LowerMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros )
const 204 if( nonzeros > LowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
208 LowerMatrix<MT,SO,DF> matrix( n );
225 template<
typename MT
228 template<
typename Arg >
229 inline const LowerMatrix<MT,SO,DF>
230 Rand< LowerMatrix<MT,SO,DF> >::generate(
const Arg&
min,
const Arg&
max )
const 234 LowerMatrix<MT,SO,DF> matrix;
251 template<
typename MT
254 template<
typename Arg >
255 inline const LowerMatrix<MT,SO,DF>
256 Rand< LowerMatrix<MT,SO,DF> >::generate(
size_t n,
const Arg&
min,
const Arg&
max )
const 260 LowerMatrix<MT,SO,DF> matrix( n );
279 template<
typename MT
282 template<
typename Arg >
283 inline const LowerMatrix<MT,SO,DF>
284 Rand< LowerMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros,
285 const Arg&
min,
const Arg&
max )
const 290 if( nonzeros > LowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
294 LowerMatrix<MT,SO,DF> matrix( n );
310 template<
typename MT
313 inline void Rand< LowerMatrix<MT,SO,DF> >
::randomize( LowerMatrix<MT,SO,DF>& matrix )
const 315 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
328 template<
typename MT
331 inline void Rand< LowerMatrix<MT,SO,DF> >
::randomize( LowerMatrix<MT,SO,DF>& matrix,
TrueType )
const 335 using ET = ElementType_t<MT>;
337 const size_t n( matrix.rows() );
339 for(
size_t i=0UL; i<n; ++i ) {
340 for(
size_t j=0UL; j<=i; ++j ) {
341 matrix(i,j) = rand<ET>();
356 template<
typename MT
359 inline void Rand< LowerMatrix<MT,SO,DF> >
::randomize( LowerMatrix<MT,SO,DF>& matrix,
FalseType )
const 363 const size_t n( matrix.rows() );
365 if( n == 0UL )
return;
367 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.3*n*n ) ) );
384 template<
typename MT
387 inline void Rand< LowerMatrix<MT,SO,DF> >
::randomize( LowerMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const 391 using ET = ElementType_t<MT>;
393 const size_t n( matrix.rows() );
395 if( nonzeros > LowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
399 if( n == 0UL )
return;
402 matrix.reserve( nonzeros );
404 std::vector<size_t> dist( n );
406 for(
size_t nz=0UL; nz<nonzeros; ) {
407 const size_t index = rand<size_t>( 0UL, n-1UL );
408 if( dist[index] == index+1UL )
continue;
413 for(
size_t i=0UL; i<n; ++i ) {
414 const Indices indices( 0UL, i, dist[i] );
415 for(
size_t j : indices ) {
416 matrix.append( i, j, rand<ET>() );
418 matrix.finalize( i );
434 template<
typename MT
437 inline void Rand< LowerMatrix<MT,SO,DF> >
::randomize( LowerMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const 441 using ET = ElementType_t<MT>;
443 const size_t n( matrix.rows() );
445 if( nonzeros > LowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
449 if( n == 0UL )
return;
452 matrix.reserve( nonzeros );
454 std::vector<size_t> dist( n );
456 for(
size_t nz=0UL; nz<nonzeros; ) {
457 const size_t index = rand<size_t>( 0UL, n-1UL );
458 if( dist[index] == n - index )
continue;
463 for(
size_t j=0UL; j<n; ++j ) {
464 const Indices indices( j, n-1UL, dist[j] );
465 for(
size_t i : indices ) {
466 matrix.append( i, j, rand<ET>() );
468 matrix.finalize( j );
484 template<
typename MT
487 template<
typename Arg >
488 inline void Rand< LowerMatrix<MT,SO,DF> >
::randomize( LowerMatrix<MT,SO,DF>& matrix,
489 const Arg&
min,
const Arg&
max )
const 506 template<
typename MT
509 template<
typename Arg >
510 inline void Rand< LowerMatrix<MT,SO,DF> >
::randomize( LowerMatrix<MT,SO,DF>& matrix,
515 using ET = ElementType_t<MT>;
517 const size_t n( matrix.rows() );
519 for(
size_t i=0UL; i<n; ++i ) {
520 for(
size_t j=0UL; j<=i; ++j ) {
521 matrix(i,j) = rand<ET>(
min,
max );
538 template<
typename MT
541 template<
typename Arg >
542 inline void Rand< LowerMatrix<MT,SO,DF> >
::randomize( LowerMatrix<MT,SO,DF>& matrix,
547 const size_t n( matrix.rows() );
549 if( n == 0UL )
return;
551 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.3*n*n ) ) );
570 template<
typename MT
573 template<
typename Arg >
574 inline void Rand< LowerMatrix<MT,SO,DF> >
::randomize( LowerMatrix<MT,false,DF>& matrix,
575 size_t nonzeros,
const Arg&
min,
const Arg&
max )
const 579 using ET = ElementType_t<MT>;
581 const size_t n( matrix.rows() );
583 if( nonzeros > LowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
587 if( n == 0UL )
return;
590 matrix.reserve( nonzeros );
592 std::vector<size_t> dist( n );
594 for(
size_t nz=0UL; nz<nonzeros; ) {
595 const size_t index = rand<size_t>( 0UL, n-1UL );
596 if( dist[index] == index+1UL )
continue;
601 for(
size_t i=0UL; i<n; ++i ) {
602 const Indices indices( 0UL, i, dist[i] );
603 for(
size_t j : indices ) {
604 matrix.append( i, j, rand<ET>(
min,
max ) );
606 matrix.finalize( i );
624 template<
typename MT
627 template<
typename Arg >
628 inline void Rand< LowerMatrix<MT,SO,DF> >
::randomize( LowerMatrix<MT,true,DF>& matrix,
629 size_t nonzeros,
const Arg&
min,
const Arg&
max )
const 633 using ET = ElementType_t<MT>;
635 const size_t n( matrix.rows() );
637 if( nonzeros > LowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
641 if( n == 0UL )
return;
644 matrix.reserve( nonzeros );
646 std::vector<size_t> dist( n );
648 for(
size_t nz=0UL; nz<nonzeros; ) {
649 const size_t index = rand<size_t>( 0UL, n-1UL );
650 if( dist[index] == n - index )
continue;
655 for(
size_t j=0UL; j<n; ++j ) {
656 const Indices indices( j, n-1UL, dist[j] );
657 for(
size_t i : indices ) {
658 matrix.append( i, j, rand<ET>(
min,
max ) );
660 matrix.finalize( j );
682 template<
typename MT
685 void makeSymmetric( LowerMatrix<MT,SO,DF>& matrix )
687 const size_t n( matrix.rows() );
691 for(
size_t i=0UL; i<n; ++i ) {
692 matrix(i,i) = rand< ElementType_t<MT> >();
710 template<
typename MT
714 void makeSymmetric( LowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
716 using Type = ElementType_t<MT>;
718 const size_t n( matrix.rows() );
722 for(
size_t i=0UL; i<n; ++i ) {
723 matrix(i,i) = rand<Type>(
min,
max );
739 template<
typename MT
742 void makeHermitian( LowerMatrix<MT,SO,DF>& matrix )
744 using Type = UnderlyingBuiltin_t< ElementType_t<MT> >;
746 const size_t n( matrix.rows() );
750 for(
size_t i=0UL; i<n; ++i ) {
751 matrix(i,i) = rand<Type>();
769 template<
typename MT
773 void makeHermitian( LowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
775 using Type = UnderlyingBuiltin_t< ElementType_t<MT> >;
777 const size_t n( matrix.rows() );
781 for(
size_t i=0UL; i<n; ++i ) {
782 matrix(i,i) = rand<Type>(
min,
max );
798 template<
typename MT
801 void makePositiveDefinite( LowerMatrix<MT,SO,DF>& matrix )
803 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
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
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 UnderlyingBuiltin type trait.
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 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 diagonal matrix adaptor.
Header file for the complete UpperMatrix implementation.
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