35#ifndef _BLAZE_MATH_SUBMATRIX_H_
36#define _BLAZE_MATH_SUBMATRIX_H_
75class Rand< Submatrix<MT,AF,SO,true,CSAs...> >
84 template<
typename SMT >
89 using SubmatrixType = RemoveReference_t<SMT>;
94 if( SO == rowMajor ) {
95 for(
size_t i=0UL; i<
submatrix.rows(); ++i ) {
96 for(
size_t j=0UL; j<
submatrix.columns(); ++j ) {
102 for(
size_t j=0UL; j<
submatrix.columns(); ++j ) {
103 for(
size_t i=0UL; i<
submatrix.rows(); ++i ) {
119 template<
typename SMT
125 using SubmatrixType = RemoveReference_t<SMT>;
130 if( SO == rowMajor ) {
131 for(
size_t i=0UL; i<
submatrix.rows(); ++i ) {
132 for(
size_t j=0UL; j<
submatrix.columns(); ++j ) {
138 for(
size_t j=0UL; j<
submatrix.columns(); ++j ) {
139 for(
size_t i=0UL; i<
submatrix.rows(); ++i ) {
170class Rand< Submatrix<MT,AF,SO,false,CSAs...> >
179 template<
typename SMT >
182 using SubmatrixType = RemoveReference_t<SMT>;
183 using ElementType = ElementType_t<SubmatrixType>;
191 if( m == 0UL || n == 0UL )
return;
193 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.5*m*n ) ) );
198 while(
submatrix.nonZeros() < nonzeros ) {
199 submatrix( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ElementType>();
212 template<
typename SMT >
215 using SubmatrixType = RemoveReference_t<SMT>;
216 using ElementType = ElementType_t<SubmatrixType>;
224 if( nonzeros > m*n ) {
228 if( m == 0UL || n == 0UL )
return;
233 while(
submatrix.nonZeros() < nonzeros ) {
234 submatrix( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ElementType>();
247 template<
typename SMT
251 using SubmatrixType = RemoveReference_t<SMT>;
252 using ElementType = ElementType_t<SubmatrixType>;
260 if( m == 0UL || n == 0UL )
return;
262 const size_t nonzeros( rand<size_t>( 1UL,
std::ceil( 0.5*m*n ) ) );
267 while(
submatrix.nonZeros() < nonzeros ) {
268 submatrix( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ElementType>(
min,
max );
283 template<
typename SMT
287 using SubmatrixType = RemoveReference_t<SMT>;
288 using ElementType = ElementType_t<SubmatrixType>;
296 if( nonzeros > m*n ) {
300 if( m == 0UL || n == 0UL )
return;
305 while(
submatrix.nonZeros() < nonzeros ) {
306 submatrix( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ElementType>(
min,
max );
Header file for auxiliary alias declarations.
Header file for the RemoveReference type trait.
Constraint on the data type.
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
#define BLAZE_CONSTRAINT_MUST_BE_SUBMATRIX_TYPE(T)
Constraint on the data type.
Definition: Submatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: DenseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: SparseMatrix.h:61
AlignmentFlag
Alignment flag for (un-)aligned vectors and matrices.
Definition: AlignmentFlag.h:63
void randomize(T &&value)
Randomization of a given variable.
Definition: Random.h:626
decltype(auto) submatrix(Matrix< MT, SO > &, RSAs...)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:181
#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.
Header file for the dense matrix SMP implementation.
Header file for the sparse matrix SMP implementation.
Implementation of a random number generator.
Header file for the implementation of the Submatrix view.
Header file for the implementation of the Subvector view.