35#ifndef _BLAZE_MATH_STRICTLYLOWERMATRIX_H_
36#define _BLAZE_MATH_STRICTLYLOWERMATRIX_H_
90 inline const StrictlyLowerMatrix<MT,SO,DF>
generate()
const
94 StrictlyLowerMatrix<MT,SO,DF> matrix;
106 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
size_t n )
const
110 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
124 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const
129 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
133 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
147 template<
typename Arg >
148 inline const StrictlyLowerMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const
152 StrictlyLowerMatrix<MT,SO,DF> matrix;
166 template<
typename Arg >
167 inline const StrictlyLowerMatrix<MT,SO,DF>
172 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
188 template<
typename Arg >
189 inline const StrictlyLowerMatrix<MT,SO,DF>
190 generate(
size_t n,
size_t nonzeros,
const Arg&
min,
const Arg&
max )
const
195 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
199 StrictlyLowerMatrix<MT,SO,DF> matrix( n );
212 inline void randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix )
const
214 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
226 inline void randomize( StrictlyLowerMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const
230 using ET = ElementType_t<MT>;
232 const size_t n( matrix.rows() );
234 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
238 if( n == 0UL || n == 1UL )
return;
241 matrix.reserve( nonzeros );
242 matrix.finalize( 0UL );
244 std::vector<size_t> dist( n );
246 for(
size_t nz=0UL; nz<nonzeros; ) {
248 if( dist[index] == index )
continue;
253 for(
size_t i=1UL; i<n; ++i ) {
254 const Indices<size_t> indices( 0UL, i-1UL, dist[i] );
255 for(
size_t j : indices ) {
258 matrix.finalize( i );
271 inline void randomize( StrictlyLowerMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const
275 using ET = ElementType_t<MT>;
277 const size_t n( matrix.rows() );
279 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
283 if( n == 0UL || n == 1UL )
return;
286 matrix.reserve( nonzeros );
288 std::vector<size_t> dist( n-1UL );
290 for(
size_t nz=0UL; nz<nonzeros; ) {
292 if( dist[index] == n - index - 1UL )
continue;
297 for(
size_t j=0UL; j<n-1UL; ++j ) {
298 const Indices<size_t> indices( j+1UL, n-1UL, dist[j] );
299 for(
size_t i : indices ) {
302 matrix.finalize( j );
305 matrix.finalize( n-1UL );
317 template<
typename Arg >
318 inline void randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const
334 template<
typename Arg >
335 inline void randomize( StrictlyLowerMatrix<MT,false,DF>& matrix,
336 size_t nonzeros,
const Arg&
min,
const Arg&
max )
const
340 using ET = ElementType_t<MT>;
342 const size_t n( matrix.rows() );
344 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
348 if( n == 0UL || n == 1UL )
return;
351 matrix.reserve( nonzeros );
352 matrix.finalize( 0UL );
354 std::vector<size_t> dist( n );
356 for(
size_t nz=0UL; nz<nonzeros; ) {
358 if( dist[index] == index )
continue;
363 for(
size_t i=1UL; i<n; ++i ) {
364 const Indices<size_t> indices( 0UL, i-1UL, dist[i] );
365 for(
size_t j : indices ) {
368 matrix.finalize( i );
383 template<
typename Arg >
384 inline void randomize( StrictlyLowerMatrix<MT,true,DF>& matrix,
385 size_t nonzeros,
const Arg&
min,
const Arg&
max )
const
389 using ET = ElementType_t<MT>;
391 const size_t n( matrix.rows() );
393 if( nonzeros > StrictlyLowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
397 if( n == 0UL || n == 1UL )
return;
400 matrix.reserve( nonzeros );
402 std::vector<size_t> dist( n-1UL );
404 for(
size_t nz=0UL; nz<nonzeros; ) {
406 if( dist[index] == n - index - 1UL )
continue;
411 for(
size_t j=0UL; j<n-1UL; ++j ) {
412 const Indices<size_t> indices( j+1UL, n-1UL, dist[j] );
413 for(
size_t i : indices ) {
416 matrix.finalize( j );
419 matrix.finalize( n-1UL );
434 using ET = ElementType_t<MT>;
436 const size_t n( matrix.rows() );
438 for(
size_t i=1UL; i<n; ++i ) {
439 for(
size_t j=0UL; j<i; ++j ) {
456 const size_t n( matrix.rows() );
458 if( n == 0UL || n == 1UL )
return;
460 const size_t nonzeros(
rand<size_t>( 1UL, std::ceil( 0.2*n*n ) ) );
474 template<
typename Arg >
475 inline void randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
480 using ET = ElementType_t<MT>;
482 const size_t n( matrix.rows() );
484 for(
size_t i=1UL; i<n; ++i ) {
485 for(
size_t j=0UL; j<i; ++j ) {
500 template<
typename Arg >
501 inline void randomize( StrictlyLowerMatrix<MT,SO,DF>& matrix,
506 const size_t n( matrix.rows() );
508 if( n == 0UL || n == 1UL )
return;
510 const size_t nonzeros(
rand<size_t>( 1UL, std::ceil( 0.2*n*n ) ) );
Header file for auxiliary alias declarations.
Header file for all basic DenseMatrix functionality.
Header file for the Indices class.
Header file for the IntegralConstant class template.
Header file for the IsDenseMatrix type trait.
Constraint on the data type.
Header file for all basic SparseMatrix functionality.
Header file for the complete StrictlyUpperMatrix implementation.
Header file for the complete ZeroMatrix implementation.
Header file for the implementation of a lower matrix adaptor.
Header file for the implementation of a strictly lower triangular matrix adaptor.
Header file for the implementation of a lower unitriangular matrix adaptor.
Default implementation of the Rand class.
Definition Random.h:230
Matrix adapter for strictly lower triangular matrices.
Definition BaseTemplate.h:563
Constraint on the data type.
Constraint on the data type.
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:1339
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:1375
decltype(auto) generate(size_t m, size_t n, OP op)
Generates a new dense matrix filled via the given custom binary operation.
Definition DMatGenExpr.h:675
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition DenseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_RESIZABLE_TYPE(T)
Constraint on the data type.
Definition Resizable.h:81
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition SparseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE_TYPE(T)
Constraint on the data type.
Definition Resizable.h:61
T rand()
Random number function.
Definition Random.h:583
void randomize(T &&value)
Randomization of a given variable.
Definition Random.h:626
BoolConstant< false > FalseType
Type/value traits base class.
Definition IntegralConstant.h:121
BoolConstant< true > TrueType
Type traits base class.
Definition IntegralConstant.h:132
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition Exception.h:235
Header file for the exception macros of the math module.
Implementation of a random number generator.
Header file for basic type definitions.