35 #ifndef _BLAZE_MATH_SPARSESUBMATRIX_H_
36 #define _BLAZE_MATH_SPARSESUBMATRIX_H_
70 class Rand< SparseSubmatrix<MT,AF,SO> >
79 template<
typename Arg >
82 template<
typename Arg >
84 const Arg&
min,
const Arg&
max )
const;
102 inline void Rand< SparseSubmatrix<MT,AF,SO> >
::randomize( SparseSubmatrix<MT,AF,SO>&
submatrix )
const
106 const size_t m( submatrix.rows() );
107 const size_t n( submatrix.columns() );
109 if( m == 0UL || n == 0UL )
return;
111 const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.5*m*n ) ) );
114 submatrix.reserve( nonzeros );
116 while( submatrix.nonZeros() < nonzeros ) {
117 submatrix( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ElementType>();
133 template<
typename MT
136 inline void Rand< SparseSubmatrix<MT,AF,SO> >
::randomize( SparseSubmatrix<MT,AF,SO>& submatrix,
size_t nonzeros )
const
140 const size_t m( submatrix.rows() );
141 const size_t n( submatrix.columns() );
143 if( nonzeros > m*n ) {
147 if( m == 0UL || n == 0UL )
return;
150 submatrix.reserve( nonzeros );
152 while( submatrix.nonZeros() < nonzeros ) {
153 submatrix( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ElementType>();
169 template<
typename MT
172 template<
typename Arg >
173 inline void Rand< SparseSubmatrix<MT,AF,SO> >
::randomize( SparseSubmatrix<MT,AF,SO>& submatrix,
174 const Arg&
min,
const Arg&
max )
const
178 const size_t m( submatrix.rows() );
179 const size_t n( submatrix.columns() );
181 if( m == 0UL || n == 0UL )
return;
183 const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.5*m*n ) ) );
186 submatrix.reserve( nonzeros );
188 while( submatrix.nonZeros() < nonzeros ) {
189 submatrix( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ElementType>(
min,
max );
207 template<
typename MT
210 template<
typename Arg >
211 inline void Rand< SparseSubmatrix<MT,AF,SO> >
::randomize( SparseSubmatrix<MT,AF,SO>& submatrix,
212 size_t nonzeros,
const Arg& min,
const Arg& max )
const
216 const size_t m( submatrix.rows() );
217 const size_t n( submatrix.columns() );
219 if( nonzeros > m*n ) {
223 if( m == 0UL || n == 0UL )
return;
226 submatrix.reserve( nonzeros );
228 while( submatrix.nonZeros() < nonzeros ) {
229 submatrix( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<ElementType>(
min,
max );
Header file for all restructuring submatrix functions.
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1729
void randomize(T &value)
Randomization of a given variable.
Definition: Random.h:1041
Implementation of a random number generator.
Header file for all restructuring subvector functions.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
void randomize(T &value) const
Randomization of the given variable with a new value in the range .
Definition: Random.h:260
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1682
Header file for the SparseSubvector class template.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
Header file for the DenseSubvector class template.
SubmatrixExprTrait< MT, unaligned >::Type submatrix(Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:146
Header file for the SparseSubmatrix class template.
Header file for exception macros.