35 #ifndef _BLAZE_MATH_STRICTLYLOWERMATRIX_H_
36 #define _BLAZE_MATH_STRICTLYLOWERMATRIX_H_
80 class Rand< StrictlyLowerMatrix<MT,SO,DF> >
86 inline const StrictlyLowerMatrix<MT,SO,DF>
generate()
const;
87 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
size_t n )
const;
88 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const;
90 template<
typename Arg >
91 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const;
93 template<
typename Arg >
94 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const;
96 template<
typename Arg >
97 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros,
98 const Arg&
min,
const Arg&
max )
const;
105 inline void randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix )
const;
106 inline void randomize( StrictlyLowerMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const;
107 inline void randomize( StrictlyLowerMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const;
109 template<
typename Arg >
110 inline void randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const;
112 template<
typename Arg >
113 inline void randomize( StrictlyLowerMatrix<MT,false,DF>& matrix,
size_t nonzeros,
114 const Arg&
min,
const Arg&
max )
const;
116 template<
typename Arg >
117 inline void randomize( StrictlyLowerMatrix<MT,true,DF>& matrix,
size_t nonzeros,
118 const Arg&
min,
const Arg&
max )
const;
129 template<
typename Arg >
130 inline void randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max,
TrueType )
const;
132 template<
typename Arg >
147 template<
typename MT
150 inline const StrictlyLowerMatrix<MT,SO,DF> Rand< StrictlyLowerMatrix<MT,SO,DF> >::generate()
const
154 StrictlyLowerMatrix<MT,SO,DF> matrix;
169 template<
typename MT
172 inline const StrictlyLowerMatrix<MT,SO,DF>
173 Rand< StrictlyLowerMatrix<MT,SO,DF> >::generate(
size_t n )
const
177 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
194 template<
typename MT
197 inline const StrictlyLowerMatrix<MT,SO,DF>
198 Rand< StrictlyLowerMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros )
const
203 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
207 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
224 template<
typename MT
227 template<
typename Arg >
228 inline const StrictlyLowerMatrix<MT,SO,DF>
229 Rand< StrictlyLowerMatrix<MT,SO,DF> >::generate(
const Arg&
min,
const Arg&
max )
const
233 StrictlyLowerMatrix<MT,SO,DF> matrix;
250 template<
typename MT
253 template<
typename Arg >
254 inline const StrictlyLowerMatrix<MT,SO,DF>
255 Rand< StrictlyLowerMatrix<MT,SO,DF> >::generate(
size_t n,
const Arg&
min,
const Arg&
max )
const
259 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
278 template<
typename MT
281 template<
typename Arg >
282 inline const StrictlyLowerMatrix<MT,SO,DF>
283 Rand< StrictlyLowerMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros,
284 const Arg&
min,
const Arg&
max )
const
289 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
293 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
309 template<
typename MT
312 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix )
const
314 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
327 template<
typename MT
330 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
TrueType )
const
334 typedef ElementType_<MT> ET;
336 const size_t n( matrix.rows() );
338 for(
size_t i=1UL; i<n; ++i ) {
339 for(
size_t j=0UL; j<i; ++j ) {
340 matrix(i,j) = rand<ET>();
355 template<
typename MT
358 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
FalseType )
const
362 const size_t n( matrix.rows() );
364 if( n == 0UL || n == 1UL )
return;
366 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.2*n*n ) ) );
383 template<
typename MT
386 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const
390 typedef ElementType_<MT> ET;
392 const size_t n( matrix.rows() );
394 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
398 if( n == 0UL || n == 1UL )
return;
401 matrix.reserve( nonzeros );
402 matrix.finalize( 0UL );
404 std::vector<size_t> dist( n );
406 for(
size_t nz=0UL; nz<nonzeros; ) {
407 const size_t index = rand<size_t>( 1UL, n-1UL );
408 if( dist[index] == index )
continue;
413 for(
size_t i=1UL; i<n; ++i ) {
414 const Indices indices( 0UL, i-1UL, 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< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const
441 typedef ElementType_<MT> ET;
443 const size_t n( matrix.rows() );
445 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
449 if( n == 0UL || n == 1UL )
return;
452 matrix.reserve( nonzeros );
454 std::vector<size_t> dist( n-1UL );
456 for(
size_t nz=0UL; nz<nonzeros; ) {
457 const size_t index = rand<size_t>( 0UL, n-2UL );
458 if( dist[index] == n - index - 1UL )
continue;
463 for(
size_t j=0UL; j<n-1UL; ++j ) {
464 const Indices indices( j+1UL, n-1UL, dist[j] );
465 for(
size_t i : indices ) {
466 matrix.append( i, j, rand<ET>() );
468 matrix.finalize( j );
471 matrix.finalize( n-1UL );
486 template<
typename MT
489 template<
typename Arg >
490 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
491 const Arg& min,
const Arg& max )
const
493 randomize( matrix, min, max,
typename IsDenseMatrix<MT>::Type() );
508 template<
typename MT
511 template<
typename Arg >
512 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
513 const Arg& min,
const Arg& max,
TrueType )
const
517 typedef ElementType_<MT> ET;
519 const size_t n( matrix.rows() );
521 for(
size_t i=1UL; i<n; ++i ) {
522 for(
size_t j=0UL; j<i; ++j ) {
523 matrix(i,j) = rand<ET>(
min,
max );
540 template<
typename MT
543 template<
typename Arg >
544 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
545 const Arg& min,
const Arg& max,
FalseType )
const
549 const size_t n( matrix.rows() );
551 if( n == 0UL || n == 1UL )
return;
553 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.2*n*n ) ) );
572 template<
typename MT
575 template<
typename Arg >
576 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,false,DF>& matrix,
577 size_t nonzeros,
const Arg& min,
const Arg& max )
const
581 typedef ElementType_<MT> ET;
583 const size_t n( matrix.rows() );
585 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
589 if( n == 0UL || n == 1UL )
return;
592 matrix.reserve( nonzeros );
593 matrix.finalize( 0UL );
595 std::vector<size_t> dist( n );
597 for(
size_t nz=0UL; nz<nonzeros; ) {
598 const size_t index = rand<size_t>( 1UL, n-1UL );
599 if( dist[index] == index )
continue;
604 for(
size_t i=1UL; i<n; ++i ) {
605 const Indices indices( 0UL, i-1UL, dist[i] );
606 for(
size_t j : indices ) {
607 matrix.append( i, j, rand<ET>( min, max ) );
609 matrix.finalize( i );
627 template<
typename MT
630 template<
typename Arg >
631 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,true,DF>& matrix,
632 size_t nonzeros,
const Arg& min,
const Arg& max )
const
636 typedef ElementType_<MT> ET;
638 const size_t n( matrix.rows() );
640 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
644 if( n == 0UL || n == 1UL )
return;
647 matrix.reserve( nonzeros );
649 std::vector<size_t> dist( n-1UL );
651 for(
size_t nz=0UL; nz<nonzeros; ) {
652 const size_t index = rand<size_t>( 0UL, n-2UL );
653 if( dist[index] == n - index - 1UL )
continue;
658 for(
size_t j=0UL; j<n-1UL; ++j ) {
659 const Indices indices( j+1UL, n-1UL, dist[j] );
660 for(
size_t i : indices ) {
661 matrix.append( i, j, rand<ET>( min, max ) );
663 matrix.finalize( j );
666 matrix.finalize( n-1UL );
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 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.
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
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 complete StrictlyUpperMatrix implementation.
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
Header file for the implementation of a strictly lower triangular matrix adaptor. ...
#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