35 #ifndef _BLAZE_MATH_UNILOWERMATRIX_H_
36 #define _BLAZE_MATH_UNILOWERMATRIX_H_
81 class Rand< UniLowerMatrix<MT,SO,DF> >
87 inline const UniLowerMatrix<MT,SO,DF>
generate()
const;
88 inline const UniLowerMatrix<MT,SO,DF>
generate(
size_t n )
const;
89 inline const UniLowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const;
91 template<
typename Arg >
92 inline const UniLowerMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const;
94 template<
typename Arg >
95 inline const UniLowerMatrix<MT,SO,DF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const;
97 template<
typename Arg >
98 inline const UniLowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros,
99 const Arg&
min,
const Arg&
max )
const;
106 inline void randomize( UniLowerMatrix<MT,SO,DF>& matrix )
const;
107 inline void randomize( UniLowerMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const;
108 inline void randomize( UniLowerMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const;
110 template<
typename Arg >
111 inline void randomize( UniLowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const;
113 template<
typename Arg >
114 inline void randomize( UniLowerMatrix<MT,false,DF>& matrix,
size_t nonzeros,
115 const Arg&
min,
const Arg&
max )
const;
117 template<
typename Arg >
118 inline void randomize( UniLowerMatrix<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 UniLowerMatrix<MT,SO,DF> Rand< UniLowerMatrix<MT,SO,DF> >::generate()
const
155 UniLowerMatrix<MT,SO,DF> matrix;
170 template<
typename MT
173 inline const UniLowerMatrix<MT,SO,DF>
174 Rand< UniLowerMatrix<MT,SO,DF> >::generate(
size_t n )
const
178 UniLowerMatrix<MT,SO,DF> matrix( n );
195 template<
typename MT
198 inline const UniLowerMatrix<MT,SO,DF>
199 Rand< UniLowerMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros )
const
204 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
208 UniLowerMatrix<MT,SO,DF> matrix( n );
225 template<
typename MT
228 template<
typename Arg >
229 inline const UniLowerMatrix<MT,SO,DF>
230 Rand< UniLowerMatrix<MT,SO,DF> >::generate(
const Arg&
min,
const Arg&
max )
const
234 UniLowerMatrix<MT,SO,DF> matrix;
251 template<
typename MT
254 template<
typename Arg >
255 inline const UniLowerMatrix<MT,SO,DF>
256 Rand< UniLowerMatrix<MT,SO,DF> >::generate(
size_t n,
const Arg&
min,
const Arg&
max )
const
260 UniLowerMatrix<MT,SO,DF> matrix( n );
279 template<
typename MT
282 template<
typename Arg >
283 inline const UniLowerMatrix<MT,SO,DF>
284 Rand< UniLowerMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros,
285 const Arg&
min,
const Arg&
max )
const
290 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
294 UniLowerMatrix<MT,SO,DF> matrix( n );
310 template<
typename MT
313 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix )
const
315 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
328 template<
typename MT
331 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
TrueType )
const
335 typedef ElementType_<MT> ET;
337 const size_t n( matrix.rows() );
339 for(
size_t i=1UL; 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< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
FalseType )
const
363 const size_t n( matrix.rows() );
365 if( n == 0UL || n == 1UL )
return;
367 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.2*n*n ) ) );
384 template<
typename MT
387 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const
391 typedef ElementType_<MT> ET;
393 const size_t n( matrix.rows() );
395 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
399 if( n == 0UL || n == 1UL )
return;
402 matrix.reserve( nonzeros );
403 matrix.finalize( 0UL );
405 std::vector<size_t> dist( n );
407 for(
size_t nz=0UL; nz<nonzeros; ) {
408 const size_t index = rand<size_t>( 1UL, n-1UL );
409 if( dist[index] == index )
continue;
414 for(
size_t i=1UL; i<n; ++i ) {
415 const Indices indices( 0UL, i-1UL, dist[i] );
416 for(
size_t j : indices ) {
417 matrix.append( i, j, rand<ET>() );
419 matrix.finalize( i );
435 template<
typename MT
438 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const
442 typedef ElementType_<MT> ET;
444 const size_t n( matrix.rows() );
446 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
450 if( n == 0UL || n == 1UL )
return;
453 matrix.reserve( nonzeros );
455 std::vector<size_t> dist( n-1UL );
457 for(
size_t nz=0UL; nz<nonzeros; ) {
458 const size_t index = rand<size_t>( 0UL, n-2UL );
459 if( dist[index] == n - index - 1UL )
continue;
464 for(
size_t j=0UL; j<n-1UL; ++j ) {
465 const Indices indices( j+1UL, n-1UL, dist[j] );
466 for(
size_t i : indices ) {
467 matrix.append( i, j, rand<ET>() );
469 matrix.finalize( j );
472 matrix.finalize( n-1UL );
487 template<
typename MT
490 template<
typename Arg >
491 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
492 const Arg& min,
const Arg& max )
const
494 randomize( matrix, min, max,
typename IsDenseMatrix<MT>::Type() );
509 template<
typename MT
512 template<
typename Arg >
513 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
514 const Arg& min,
const Arg& max,
TrueType )
const
518 typedef ElementType_<MT> ET;
520 const size_t n( matrix.rows() );
522 for(
size_t i=1UL; i<n; ++i ) {
523 for(
size_t j=0UL; j<i; ++j ) {
524 matrix(i,j) = rand<ET>(
min,
max );
541 template<
typename MT
544 template<
typename Arg >
545 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,SO,DF>& matrix,
546 const Arg& min,
const Arg& max,
FalseType )
const
550 const size_t n( matrix.rows() );
552 if( n == 0UL || n == 1UL )
return;
554 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.2*n*n ) ) );
573 template<
typename MT
576 template<
typename Arg >
577 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,false,DF>& matrix,
578 size_t nonzeros,
const Arg& min,
const Arg& max )
const
582 typedef ElementType_<MT> ET;
584 const size_t n( matrix.rows() );
586 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
590 if( n == 0UL || n == 1UL )
return;
593 matrix.reserve( nonzeros );
594 matrix.finalize( 0UL );
596 std::vector<size_t> dist( n );
598 for(
size_t nz=0UL; nz<nonzeros; ) {
599 const size_t index = rand<size_t>( 1UL, n-1UL );
600 if( dist[index] == index )
continue;
605 for(
size_t i=1UL; i<n; ++i ) {
606 const Indices indices( 0UL, i-1UL, dist[i] );
607 for(
size_t j : indices ) {
608 matrix.append( i, j, rand<ET>( min, max ) );
610 matrix.finalize( i );
628 template<
typename MT
631 template<
typename Arg >
632 inline void Rand< UniLowerMatrix<MT,SO,DF> >
::randomize( UniLowerMatrix<MT,true,DF>& matrix,
633 size_t nonzeros,
const Arg& min,
const Arg& max )
const
637 typedef ElementType_<MT> ET;
639 const size_t n( matrix.rows() );
641 if( nonzeros > UniLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
645 if( n == 0UL || n == 1UL )
return;
648 matrix.reserve( nonzeros );
650 std::vector<size_t> dist( n-1UL );
652 for(
size_t nz=0UL; nz<nonzeros; ) {
653 const size_t index = rand<size_t>( 0UL, n-2UL );
654 if( dist[index] == n - index - 1UL )
continue;
659 for(
size_t j=0UL; j<n-1UL; ++j ) {
660 const Indices indices( j+1UL, n-1UL, dist[j] );
661 for(
size_t i : indices ) {
662 matrix.append( i, j, rand<ET>( min, max ) );
664 matrix.finalize( j );
667 matrix.finalize( n-1UL );
688 template<
typename MT
691 void makeSymmetric( UniLowerMatrix<MT,SO,DF>& matrix )
710 template<
typename MT
714 void makeSymmetric( UniLowerMatrix<MT,SO,DF>& matrix,
const Arg& min,
const Arg& max )
718 makeSymmetric( matrix );
731 template<
typename MT
734 void makeHermitian( UniLowerMatrix<MT,SO,DF>& matrix )
753 template<
typename MT
757 void makeHermitian( UniLowerMatrix<MT,SO,DF>& matrix,
const Arg& min,
const Arg& max )
761 makeHermitian( matrix );
774 template<
typename MT
777 void makePositiveDefinite( UniLowerMatrix<MT,SO,DF>& matrix )
779 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
void randomize(T &value)
Randomization of a given variable.
Definition: Random.h:926
Constraint on the data type.
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:689
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1669
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:1716
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:289
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 Indices class.
#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:81
T generate() const
Generation of a random value in the range .
Definition: Random.h:249
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:61
bool isHermitian(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is Hermitian.
Definition: DenseMatrix.h:759
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.
const DMatForEachExpr< MT, Ceil, SO > ceil(const DenseMatrix< MT, SO > &dm)
Applies the ceil() function to each single element of the dense matrix dm.
Definition: DMatForEachExpr.h:1130