35 #ifndef _BLAZE_MATH_COMPRESSEDMATRIX_H_
36 #define _BLAZE_MATH_COMPRESSEDMATRIX_H_
67 template<
typename Type
69 class Rand< CompressedMatrix<Type,SO> >
75 inline const CompressedMatrix<Type,SO>
generate(
size_t m,
size_t n )
const;
76 inline const CompressedMatrix<Type,SO>
generate(
size_t m,
size_t n,
size_t nonzeros )
const;
78 template<
typename Arg >
79 inline const CompressedMatrix<Type,SO>
generate(
size_t m,
size_t n,
const Arg&
min,
const Arg&
max )
const;
81 template<
typename Arg >
82 inline const CompressedMatrix<Type,SO>
generate(
size_t m,
size_t n,
size_t nonzeros,
83 const Arg&
min,
const Arg&
max )
const;
90 inline void randomize( CompressedMatrix<Type,SO>& matrix )
const;
91 inline void randomize( CompressedMatrix<Type,SO>& matrix,
size_t nonzeros )
const;
93 template<
typename Arg >
94 inline void randomize( CompressedMatrix<Type,SO>& matrix,
const Arg&
min,
const Arg&
max )
const;
96 template<
typename Arg >
97 inline void randomize( CompressedMatrix<Type,SO>& matrix,
size_t nonzeros,
98 const Arg&
min,
const Arg&
max )
const;
114 template<
typename Type
116 inline const CompressedMatrix<Type,SO>
117 Rand< CompressedMatrix<Type,SO> >::generate(
size_t m,
size_t n )
const
119 CompressedMatrix<Type,SO> matrix( m, n );
138 template<
typename Type
140 inline const CompressedMatrix<Type,SO>
141 Rand< CompressedMatrix<Type,SO> >::generate(
size_t m,
size_t n,
size_t nonzeros )
const
143 if( nonzeros > m*n ) {
147 CompressedMatrix<Type,SO> matrix( m, n );
166 template<
typename Type
168 template<
typename Arg >
169 inline const CompressedMatrix<Type,SO>
170 Rand< CompressedMatrix<Type,SO> >::generate(
size_t m,
size_t n,
const Arg&
min,
const Arg&
max )
const
172 CompressedMatrix<Type,SO> matrix( m, n );
193 template<
typename Type
195 template<
typename Arg >
196 inline const CompressedMatrix<Type,SO>
197 Rand< CompressedMatrix<Type,SO> >::generate(
size_t m,
size_t n,
size_t nonzeros,
198 const Arg&
min,
const Arg&
max )
const
200 if( nonzeros > m*n ) {
204 CompressedMatrix<Type,SO> matrix( m, n );
220 template<
typename Type
222 inline void Rand< CompressedMatrix<Type,SO> >
::randomize( CompressedMatrix<Type,SO>& matrix )
const
224 const size_t m( matrix.rows() );
225 const size_t n( matrix.columns() );
227 if( m == 0UL || n == 0UL )
return;
229 const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.5*m*n ) ) );
232 matrix.reserve( nonzeros );
234 while( matrix.nonZeros() < nonzeros ) {
235 matrix( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<Type>();
251 template<
typename Type
253 inline void Rand< CompressedMatrix<Type,SO> >
::randomize( CompressedMatrix<Type,SO>& matrix,
size_t nonzeros )
const
255 const size_t m( matrix.rows() );
256 const size_t n( matrix.columns() );
258 if( nonzeros > m*n ) {
262 if( m == 0UL || n == 0UL )
return;
265 matrix.reserve( nonzeros );
267 while( matrix.nonZeros() < nonzeros ) {
268 matrix( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<Type>();
284 template<
typename Type
286 template<
typename Arg >
287 inline void Rand< CompressedMatrix<Type,SO> >
::randomize( CompressedMatrix<Type,SO>& matrix,
288 const Arg& min,
const Arg& max )
const
290 const size_t m( matrix.rows() );
291 const size_t n( matrix.columns() );
293 if( m == 0UL || n == 0UL )
return;
295 const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.5*m*n ) ) );
298 matrix.reserve( nonzeros );
300 while( matrix.nonZeros() < nonzeros ) {
301 matrix( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<Type>(
min,
max );
319 template<
typename Type
321 template<
typename Arg >
322 inline void Rand< CompressedMatrix<Type,SO> >
::randomize( CompressedMatrix<Type,SO>& matrix,
323 size_t nonzeros,
const Arg& min,
const Arg& max )
const
325 const size_t m( matrix.rows() );
326 const size_t n( matrix.columns() );
328 if( nonzeros > m*n ) {
332 if( m == 0UL || n == 0UL )
return;
335 matrix.reserve( nonzeros );
337 while( matrix.nonZeros() < nonzeros ) {
338 matrix( rand<size_t>( 0UL, m-1UL ), rand<size_t>( 0UL, n-1UL ) ) = rand<Type>(
min,
max );
#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
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:207
void randomize(T &value)
Randomization of a given variable.
Definition: Random.h:1041
Implementation of a compressed MxN matrix.
Implementation of a random number generator.
CompressedMatrix< real_t, false > CMatMxN
MxN matrix with system-specific precision.
Definition: CompressedMatrix.h:373
Header file for the floating point precision of the Blaze library.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for all basic SparseMatrix functionality.
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
CompressedMatrix< float, false > CMatMxNf
MxN single precision matrix.
Definition: CompressedMatrix.h:357
Header file for the complete CompressedVector implementation.
T generate() const
Generation of a random value in the range .
Definition: Random.h:220
Header file for exception macros.
CompressedMatrix< double, false > CMatMxNd
MxN double precision matrix.
Definition: CompressedMatrix.h:365