35#ifndef _BLAZE_MATH_LOWERMATRIX_H_
36#define _BLAZE_MATH_LOWERMATRIX_H_
82class Rand< LowerMatrix<MT,SO,DF> >
90 inline const LowerMatrix<MT,SO,DF>
generate()
const
94 LowerMatrix<MT,SO,DF> matrix;
106 inline const LowerMatrix<MT,SO,DF>
generate(
size_t n )
const
110 LowerMatrix<MT,SO,DF> matrix( n );
124 inline const LowerMatrix<MT,SO,DF>
generate(
size_t n,
size_t nonzeros )
const
129 if( nonzeros > LowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
133 LowerMatrix<MT,SO,DF> matrix( n );
147 template<
typename Arg >
148 inline const LowerMatrix<MT,SO,DF>
generate(
const Arg&
min,
const Arg&
max )
const
152 LowerMatrix<MT,SO,DF> matrix;
166 template<
typename Arg >
167 inline const LowerMatrix<MT,SO,DF>
172 LowerMatrix<MT,SO,DF> matrix( n );
188 template<
typename Arg >
189 inline const LowerMatrix<MT,SO,DF>
190 generate(
size_t n,
size_t nonzeros,
const Arg&
min,
const Arg&
max )
const
195 if( nonzeros > LowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
199 LowerMatrix<MT,SO,DF> matrix( n );
212 inline void randomize( LowerMatrix<MT,SO,DF>& matrix )
const
214 randomize( matrix,
typename IsDenseMatrix<MT>::Type() );
226 inline void randomize( LowerMatrix<MT,false,DF>& matrix,
size_t nonzeros )
const
230 using ET = ElementType_t<MT>;
232 const size_t n( matrix.rows() );
234 if( nonzeros > LowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
238 if( n == 0UL )
return;
241 matrix.reserve( nonzeros );
243 std::vector<size_t> dist( n );
245 for(
size_t nz=0UL; nz<nonzeros; ) {
246 const size_t index = rand<size_t>( 0UL, n-1UL );
247 if( dist[index] == index+1UL )
continue;
252 for(
size_t i=0UL; i<n; ++i ) {
253 const Indices<size_t> indices( 0UL, i, dist[i] );
254 for(
size_t j : indices ) {
255 matrix.append( i, j, rand<ET>() );
257 matrix.finalize( i );
270 inline void randomize( LowerMatrix<MT,true,DF>& matrix,
size_t nonzeros )
const
274 using ET = ElementType_t<MT>;
276 const size_t n( matrix.rows() );
278 if( nonzeros > LowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
282 if( n == 0UL )
return;
285 matrix.reserve( nonzeros );
287 std::vector<size_t> dist( n );
289 for(
size_t nz=0UL; nz<nonzeros; ) {
290 const size_t index = rand<size_t>( 0UL, n-1UL );
291 if( dist[index] == n - index )
continue;
296 for(
size_t j=0UL; j<n; ++j ) {
297 const Indices<size_t> indices( j, n-1UL, dist[j] );
298 for(
size_t i : indices ) {
299 matrix.append( i, j, rand<ET>() );
301 matrix.finalize( j );
314 template<
typename Arg >
315 inline void randomize( LowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
const
331 template<
typename Arg >
332 inline void randomize( LowerMatrix<MT,false,DF>& matrix,
333 size_t nonzeros,
const Arg&
min,
const Arg&
max )
const
337 using ET = ElementType_t<MT>;
339 const size_t n( matrix.rows() );
341 if( nonzeros > LowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
345 if( n == 0UL )
return;
348 matrix.reserve( nonzeros );
350 std::vector<size_t> dist( n );
352 for(
size_t nz=0UL; nz<nonzeros; ) {
353 const size_t index = rand<size_t>( 0UL, n-1UL );
354 if( dist[index] == index+1UL )
continue;
359 for(
size_t i=0UL; i<n; ++i ) {
360 const Indices<size_t> indices( 0UL, i, dist[i] );
361 for(
size_t j : indices ) {
362 matrix.append( i, j, rand<ET>(
min,
max ) );
364 matrix.finalize( i );
379 template<
typename Arg >
380 inline void randomize( LowerMatrix<MT,true,DF>& matrix,
381 size_t nonzeros,
const Arg&
min,
const Arg&
max )
const
385 using ET = ElementType_t<MT>;
387 const size_t n( matrix.rows() );
389 if( nonzeros > LowerMatrix<MT,SO,DF>::maxNonZeros( n ) ) {
393 if( n == 0UL )
return;
396 matrix.reserve( nonzeros );
398 std::vector<size_t> dist( n );
400 for(
size_t nz=0UL; nz<nonzeros; ) {
401 const size_t index = rand<size_t>( 0UL, n-1UL );
402 if( dist[index] == n - index )
continue;
407 for(
size_t j=0UL; j<n; ++j ) {
408 const Indices<size_t> indices( j, n-1UL, dist[j] );
409 for(
size_t i : indices ) {
410 matrix.append( i, j, rand<ET>(
min,
max ) );
412 matrix.finalize( j );
428 using ET = ElementType_t<MT>;
430 const size_t n( matrix.rows() );
432 for(
size_t i=0UL; i<n; ++i ) {
433 for(
size_t j=0UL; j<=i; ++j ) {
434 matrix(i,j) = rand<ET>();
450 const size_t n( matrix.rows() );
452 if( n == 0UL )
return;
454 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.3*n*n ) ) );
468 template<
typename Arg >
469 inline void randomize( LowerMatrix<MT,SO,DF>& matrix,
474 using ET = ElementType_t<MT>;
476 const size_t n( matrix.rows() );
478 for(
size_t i=0UL; i<n; ++i ) {
479 for(
size_t j=0UL; j<=i; ++j ) {
480 matrix(i,j) = rand<ET>(
min,
max );
494 template<
typename Arg >
495 inline void randomize( LowerMatrix<MT,SO,DF>& matrix,
500 const size_t n( matrix.rows() );
502 if( n == 0UL )
return;
504 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.3*n*n ) ) );
532void makeSymmetric( LowerMatrix<MT,SO,DF>& matrix )
534 const size_t n( matrix.rows() );
538 for(
size_t i=0UL; i<n; ++i ) {
539 matrix(i,i) = rand< ElementType_t<MT> >();
561void makeSymmetric( LowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
563 using Type = ElementType_t<MT>;
565 const size_t n( matrix.rows() );
569 for(
size_t i=0UL; i<n; ++i ) {
570 matrix(i,i) = rand<Type>(
min,
max );
589void makeHermitian( LowerMatrix<MT,SO,DF>& matrix )
591 using Type = UnderlyingBuiltin_t< ElementType_t<MT> >;
595 const size_t n( matrix.rows() );
599 for(
size_t i=0UL; i<n; ++i ) {
600 matrix(i,i) = rand<Type>();
622void makeHermitian( LowerMatrix<MT,SO,DF>& matrix,
const Arg&
min,
const Arg&
max )
624 using Type = UnderlyingBuiltin_t< ElementType_t<MT> >;
628 const size_t n( matrix.rows() );
632 for(
size_t i=0UL; i<n; ++i ) {
633 matrix(i,i) = rand<Type>(
min,
max );
652void makePositiveDefinite( LowerMatrix<MT,SO,DF>& matrix )
654 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 complete UpperMatrix implementation.
Header file for the implementation of a diagonal matrix adaptor.
Header file for the implementation of a lower 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
decltype(auto) ceil(const DenseMatrix< MT, SO > &dm)
Applies the ceil() function to each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1380
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.