35#ifndef _BLAZE_MATH_UNIUPPERMATRIX_H_
36#define _BLAZE_MATH_UNIUPPERMATRIX_H_
90 inline const UniUpperMatrix<MT,SO,DF>
generate()
const
94 UniUpperMatrix<MT,SO,DF> matrix;
106 inline const UniUpperMatrix<MT,SO,DF>
generate(
size_t n )
const
110 UniUpperMatrix<MT,SO,DF> matrix( n );
124 inline const UniUpperMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const
129 if( nonzeros > UniUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
133 UniUpperMatrix<MT,SO,DF> matrix( n );
147 template<
typename Arg >
148 inline const UniUpperMatrix<MT,SO,DF>
153 UniUpperMatrix<MT,SO,DF> matrix;
167 template<
typename Arg >
168 inline const UniUpperMatrix<MT,SO,DF>
173 UniUpperMatrix<MT,SO,DF> matrix( n );
189 template<
typename Arg >
190 inline const UniUpperMatrix<MT,SO,DF>
191 generate(
size_t n,
size_t nonzeros,
const Arg&
min,
const Arg&
max )
const
196 if( nonzeros > UniUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
200 UniUpperMatrix<MT,SO,DF> matrix( n );
213 inline void randomize( UniUpperMatrix<MT,SO,DF>& matrix )
const
215 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
227 inline void randomize( UniUpperMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const
231 using ET = ElementType_t<MT>;
233 const size_t n( matrix.rows() );
235 if( nonzeros > UniUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
239 if( n == 0UL || n == 1UL )
return;
242 matrix.reserve( nonzeros );
244 std::vector<size_t> dist( n-1UL );
246 for(
size_t nz=0UL; nz<nonzeros; ) {
248 if( dist[index] == n - index - 1UL )
continue;
253 for(
size_t i=0UL; i<n-1UL; ++i ) {
254 const Indices<size_t> indices( i+1UL, n-1UL, dist[i] );
255 for(
size_t j : indices ) {
258 matrix.finalize( i );
261 matrix.finalize( n-1UL );
273 inline void randomize( UniUpperMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const
277 using ET = ElementType_t<MT>;
279 const size_t n( matrix.rows() );
281 if( nonzeros > UniUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
285 if( n == 0UL || n == 1UL )
return;
288 matrix.reserve( nonzeros );
289 matrix.finalize( 0UL );
291 std::vector<size_t> dist( n );
293 for(
size_t nz=0UL; nz<nonzeros; ) {
295 if( dist[index] == index )
continue;
300 for(
size_t j=1UL; j<n; ++j ) {
301 const Indices<size_t> indices( 0UL, j-1UL, dist[j] );
302 for(
size_t i : indices ) {
305 matrix.finalize( j );
318 template<
typename Arg >
319 inline void randomize( UniUpperMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const
335 template<
typename Arg >
336 inline void randomize( UniUpperMatrix<MT,false,DF>& matrix,
337 size_t nonzeros,
const Arg&
min,
const Arg&
max )
const
341 using ET = ElementType_t<MT>;
343 const size_t n( matrix.rows() );
345 if( nonzeros > UniUpperMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
349 if( n == 0UL || n == 1UL )
return;
352 matrix.reserve( nonzeros );
354 std::vector<size_t> dist( n-1UL );
356 for(
size_t nz=0UL; nz<nonzeros; ) {
358 if( dist[index] == n - index - 1UL )
continue;
363 for(
size_t i=0UL; i<n-1UL; ++i ) {
364 const Indices<size_t> indices( i+1UL, n-1UL, dist[i] );
365 for(
size_t j : indices ) {
368 matrix.finalize( i );
371 matrix.finalize( n-1UL );
385 template<
typename Arg >
386 inline void randomize( UniUpperMatrix<MT,true,DF>& matrix,
387 size_t nonzeros,
const Arg&
min,
const Arg&
max )
const
391 using ET = ElementType_t<MT>;
393 const size_t n( matrix.rows() );
395 if( nonzeros > UniUpperMatrix<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; ) {
409 if( dist[index] == index )
continue;
414 for(
size_t j=1UL; j<n; ++j ) {
415 const Indices<size_t> indices( 0UL, j-1UL, dist[j] );
416 for(
size_t i : indices ) {
419 matrix.finalize( j );
435 using ET = ElementType_t<MT>;
437 const size_t n( matrix.rows() );
439 for(
size_t i=0UL; i<n; ++i ) {
440 for(
size_t j=i+1UL; j<n; ++j ) {
457 const size_t n( matrix.rows() );
459 if( n == 0UL || n == 1UL )
return;
461 const size_t nonzeros(
rand<size_t>( 1UL, std::ceil( 0.2*n*n ) ) );
475 template<
typename Arg >
476 inline void randomize( UniUpperMatrix<MT,SO,DF>& matrix,
481 using ET = ElementType_t<MT>;
483 const size_t n( matrix.rows() );
485 for(
size_t i=0UL; i<n; ++i ) {
486 for(
size_t j=i+1UL; j<n; ++j ) {
501 template<
typename Arg >
502 inline void randomize( UniUpperMatrix<MT,SO,DF>& matrix,
507 const size_t n( matrix.rows() );
509 if( n == 0UL || n == 1UL )
return;
511 const size_t nonzeros(
rand<size_t>( 1UL, std::ceil( 0.2*n*n ) ) );
566 makeSymmetric( matrix );
609 makeHermitian( matrix );
627 makeHermitian( matrix );
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.
Header file for the MAYBE_UNUSED function template.
Constraint on the data type.
Header file for all basic SparseMatrix functionality.
Header file for the complete UniLowerMatrix implementation.
Header file for the implementation of a strictly upper triangular matrix adaptor.
Header file for the implementation of a upper unitriangular matrix adaptor.
Header file for the implementation of an upper matrix adaptor.
Default implementation of the Rand class.
Definition Random.h:230
Matrix adapter for upper unitriangular matrices.
Definition BaseTemplate.h:581
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
bool isHermitian(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is Hermitian.
Definition DenseMatrix.h:1534
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition DenseMatrix.h:1456
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
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition Matrix.h:806
T rand()
Random number function.
Definition Random.h:583
void randomize(T &&value)
Randomization of a given variable.
Definition Random.h:626
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition Assert.h:101
BoolConstant< false > FalseType
Type/value traits base class.
Definition IntegralConstant.h:121
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition MaybeUnused.h:81
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.
Generic wrapper for the arg() function.
Definition Arg.h:77
Implementation of a random number generator.
Header file for basic type definitions.