35 #ifndef _BLAZE_MATH_STRICTLYLOWERMATRIX_H_
36 #define _BLAZE_MATH_STRICTLYLOWERMATRIX_H_
77 class Rand< StrictlyLowerMatrix<MT,SO,DF> >
83 inline const StrictlyLowerMatrix<MT,SO,DF>
generate()
const;
84 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
size_t n )
const;
85 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const;
87 template<
typename Arg >
88 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const;
90 template<
typename Arg >
91 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
size_t n,
const Arg&
min,
const Arg&
max )
const;
93 template<
typename Arg >
94 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros,
95 const Arg&
min,
const Arg&
max )
const;
102 inline void randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix )
const;
103 inline void randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
size_t nonzeros )
const;
105 template<
typename Arg >
106 inline void randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const;
108 template<
typename Arg >
109 inline void randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
size_t nonzeros,
110 const Arg&
min,
const Arg&
max )
const;
121 template<
typename Arg >
122 inline void randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max,
TrueType )
const;
124 template<
typename Arg >
139 template<
typename MT
142 inline const StrictlyLowerMatrix<MT,SO,DF> Rand< StrictlyLowerMatrix<MT,SO,DF> >::generate()
const
146 StrictlyLowerMatrix<MT,SO,DF> matrix;
161 template<
typename MT
164 inline const StrictlyLowerMatrix<MT,SO,DF>
165 Rand< StrictlyLowerMatrix<MT,SO,DF> >::generate(
size_t n )
const
169 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
186 template<
typename MT
189 inline const StrictlyLowerMatrix<MT,SO,DF>
190 Rand< StrictlyLowerMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros )
const
195 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
199 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
216 template<
typename MT
219 template<
typename Arg >
220 inline const StrictlyLowerMatrix<MT,SO,DF>
221 Rand< StrictlyLowerMatrix<MT,SO,DF> >::generate(
const Arg&
min,
const Arg&
max )
const
225 StrictlyLowerMatrix<MT,SO,DF> matrix;
242 template<
typename MT
245 template<
typename Arg >
246 inline const StrictlyLowerMatrix<MT,SO,DF>
247 Rand< StrictlyLowerMatrix<MT,SO,DF> >::generate(
size_t n,
const Arg&
min,
const Arg&
max )
const
251 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
270 template<
typename MT
273 template<
typename Arg >
274 inline const StrictlyLowerMatrix<MT,SO,DF>
275 Rand< StrictlyLowerMatrix<MT,SO,DF> >::generate(
size_t n,
size_t nonzeros,
276 const Arg&
min,
const Arg&
max )
const
281 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
285 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
301 template<
typename MT
304 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix )
const
306 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
319 template<
typename MT
322 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
TrueType )
const
328 const size_t n( matrix.rows() );
330 for(
size_t i=1UL; i<n; ++i ) {
331 for(
size_t j=0UL; j<i; ++j ) {
332 matrix(i,j) = rand<ET>();
347 template<
typename MT
350 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
FalseType )
const
356 const size_t n( matrix.rows() );
358 if( n == 0UL )
return;
360 const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.2*n*n ) ) );
363 matrix.reserve( nonzeros );
365 while( matrix.nonZeros() < nonzeros ) {
366 const size_t row( rand<size_t>( 1UL, n-1UL ) );
367 const size_t col( rand<size_t>( 0UL,
row-1UL ) );
368 matrix(
row,col) = rand<ET>();
384 template<
typename MT
387 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
size_t nonzeros )
const
393 const size_t n( matrix.rows() );
395 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
399 if( n == 0UL )
return;
402 matrix.reserve( nonzeros );
404 while( matrix.nonZeros() < nonzeros ) {
405 const size_t row( rand<size_t>( 1UL, n-1UL ) );
406 const size_t col( rand<size_t>( 0UL,
row-1UL ) );
407 matrix(
row,col) = rand<ET>();
423 template<
typename MT
426 template<
typename Arg >
427 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
428 const Arg& min,
const Arg& max )
const
430 randomize( matrix, min, max,
typename IsDenseMatrix<MT>::Type() );
445 template<
typename MT
448 template<
typename Arg >
449 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
450 const Arg& min,
const Arg& max,
TrueType )
const
456 const size_t n( matrix.rows() );
458 for(
size_t i=1UL; i<n; ++i ) {
459 for(
size_t j=0UL; j<i; ++j ) {
460 matrix(i,j) = rand<ET>(
min,
max );
477 template<
typename MT
480 template<
typename Arg >
481 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
482 const Arg& min,
const Arg& max,
FalseType )
const
488 const size_t n( matrix.rows() );
490 if( n == 0UL )
return;
492 const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.2*n*n ) ) );
495 matrix.reserve( nonzeros );
497 while( matrix.nonZeros() < nonzeros ) {
498 const size_t row( rand<size_t>( 1UL, n-1UL ) );
499 const size_t col( rand<size_t>( 0UL,
row-1UL ) );
518 template<
typename MT
521 template<
typename Arg >
522 inline void Rand< StrictlyLowerMatrix<MT,SO,DF> >
::randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
523 size_t nonzeros,
const Arg& min,
const Arg& max )
const
529 const size_t n( matrix.rows() );
531 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
535 if( n == 0UL )
return;
538 matrix.reserve( nonzeros );
540 while( matrix.nonZeros() < nonzeros ) {
541 const size_t row( rand<size_t>( 1UL, n-1UL ) );
542 const size_t col( rand<size_t>( 0UL,
row-1UL ) );
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1729
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:79
void randomize(T &value)
Randomization of a given variable.
Definition: Random.h:1041
Constraint on the data type.
Implementation of a random number generator.
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:260
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1682
Header file for the complete StrictlyUpperMatrix implementation.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
Header file for the IsDenseMatrix type trait.
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename RowExprTrait< MT >::Type >::Type row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:107
#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:118
T generate() const
Generation of a random value in the range .
Definition: Random.h:220
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:79
boost::false_type FalseType
Type/value traits base class.The FalseType class is used as base class for type traits and value trai...
Definition: FalseType.h:61
Header file for the implementation of a strictly lower triangular matrix adaptor. ...
Header file for exception macros.
boost::true_type TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
#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:79
Header file for the TrueType type/value trait base class.