35#ifndef _BLAZE_MATH_DIAGONALMATRIX_H_
36#define _BLAZE_MATH_DIAGONALMATRIX_H_
78class Rand< DiagonalMatrix<MT,SO,DF> >
86 inline const DiagonalMatrix<MT,SO,DF>
generate()
const
90 DiagonalMatrix<MT,SO,DF> matrix;
102 inline const DiagonalMatrix<MT,SO,DF>
generate(
size_t n )
const
106 DiagonalMatrix<MT,SO,DF> matrix( n );
120 inline const DiagonalMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const
129 DiagonalMatrix<MT,SO,DF> matrix( n );
143 template<
typename Arg >
144 inline const DiagonalMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const
148 DiagonalMatrix<MT,SO,DF> matrix;
162 template<
typename Arg >
163 inline const DiagonalMatrix<MT,SO,DF>
168 DiagonalMatrix<MT,SO,DF> matrix( n );
184 template<
typename Arg >
185 inline const DiagonalMatrix<MT,SO,DF>
186 generate(
size_t n,
size_t nonzeros,
const Arg&
min,
const Arg&
max )
const
191 if( nonzeros > DiagonalMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
195 DiagonalMatrix<MT,SO,DF> matrix( n );
208 inline void randomize( DiagonalMatrix<MT,SO,DF>& matrix )
const
210 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
222 inline void randomize( DiagonalMatrix<MT,SO,DF>& matrix,
size_t nonzeros )
const
226 using ET = ElementType_t<MT>;
228 const size_t n( matrix.rows() );
234 if( n == 0UL )
return;
237 matrix.reserve( nonzeros );
239 Indices<size_t> indices( 0UL, n-1UL, nonzeros );
242 for(
size_t index : indices ) {
243 for( ; i<index; ++i )
244 matrix.finalize( i );
245 matrix.append( i, i, rand<ET>() );
249 matrix.finalize( i );
262 template<
typename Arg >
263 inline void randomize( DiagonalMatrix<MT,SO,DF>& matrix,
264 const Arg&
min,
const Arg&
max )
const
280 template<
typename Arg >
281 inline void randomize( DiagonalMatrix<MT,SO,DF>& matrix,
282 size_t nonzeros,
const Arg&
min,
const Arg&
max )
const
286 using ET = ElementType_t<MT>;
288 const size_t n( matrix.rows() );
294 if( n == 0UL )
return;
297 matrix.reserve( nonzeros );
299 Indices<size_t> indices( 0UL, n-1UL, nonzeros );
302 for(
size_t index : indices ) {
303 for( ; i<index; ++i )
304 matrix.finalize( i );
305 matrix.append( i, i, rand<ET>(
min,
max ) );
309 matrix.finalize( i );
325 using ET = ElementType_t<MT>;
327 const size_t n( matrix.rows() );
329 for(
size_t i=0UL; i<n; ++i ) {
330 matrix(i,i) = rand<ET>();
345 const size_t n( matrix.rows() );
347 if( n == 0UL )
return;
349 const size_t nonzeros( rand<size_t>( 1UL, n ) );
363 template<
typename Arg >
364 inline void randomize( DiagonalMatrix<MT,SO,DF>& matrix,
369 using ET = ElementType_t<MT>;
371 const size_t n( matrix.rows() );
373 for(
size_t i=0UL; i<n; ++i ) {
374 matrix(i,i) = rand<ET>(
min,
max );
387 template<
typename Arg >
388 inline void randomize( DiagonalMatrix<MT,SO,DF>& matrix,
393 const size_t n( matrix.rows() );
395 if( n == 0UL )
return;
397 const size_t nonzeros( rand<size_t>( 1UL, n ) );
425void makeSymmetric( DiagonalMatrix<MT,SO,DF>& matrix )
427 const size_t n( matrix.rows() );
431 for(
size_t i=0UL; i<n; ++i ) {
432 matrix(i,i) = rand< ElementType_t<MT> >();
454void makeSymmetric( DiagonalMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
456 using Type = ElementType_t<MT>;
458 const size_t n( matrix.rows() );
462 for(
size_t i=0UL; i<n; ++i ) {
463 matrix(i,i) = rand<Type>(
min,
max );
482void makeHermitian( DiagonalMatrix<MT,SO,DF>& matrix )
484 using Type = UnderlyingBuiltin_t< ElementType_t<MT> >;
488 const size_t n( matrix.rows() );
492 for(
size_t i=0UL; i<n; ++i ) {
493 matrix(i,i) = rand<Type>();
515void makeHermitian( DiagonalMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
517 using Type = UnderlyingBuiltin_t< ElementType_t<MT> >;
521 const size_t n( matrix.rows() );
525 for(
size_t i=0UL; i<n; ++i ) {
526 matrix(i,i) = rand<Type>(
min,
max );
545void makePositiveDefinite( DiagonalMatrix<MT,SO,DF>& matrix )
547 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.
Constraint on the data type.
Constraint on the data type.
Header file for all basic SparseMatrix functionality.
Header file for the UnderlyingBuiltin type trait.
Header file for the implementation of a diagonal matrix adaptor.
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
#define BLAZE_CONSTRAINT_MUST_BE_SCALAR_TYPE(T)
Constraint on the data type.
Definition: Scalar.h:61
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition: Matrix.h:806
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< true > TrueType
Type traits base class.
Definition: IntegralConstant.h:132
BoolConstant< false > FalseType
Type/value traits base class.
Definition: IntegralConstant.h:121
#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.