Sparse module: add a more flexible SparseMatrix::fillrand() function
which allows to fill a matrix with random inner coordinates (makes sense
only when a very few coeffs are inserted per col/row)
diff --git a/test/sparse_basic.cpp b/test/sparse_basic.cpp
index c890d95..c506828 100644
--- a/test/sparse_basic.cpp
+++ b/test/sparse_basic.cpp
@@ -153,6 +153,26 @@
#ifdef _SPARSE_HASH_MAP_H_
VERIFY(( test_random_setter<RandomSetter<SparseMatrix<Scalar>, GoogleSparseHashMapTraits> >(m,refMat,nonzeroCoords) ));
#endif
+
+ // test fillrand
+ {
+ DenseMatrix m1(rows,cols);
+ m1.setZero();
+ SparseMatrix<Scalar> m2(rows,cols);
+ m2.startFill();
+ for (int j=0; j<cols; ++j)
+ {
+ for (int k=0; k<rows/2; ++k)
+ {
+ int i = ei_random<int>(0,rows-1);
+ if (m1.coeff(i,j)==Scalar(0))
+ m2.fillrand(i,j) = m1(i,j) = ei_random<Scalar>();
+ }
+ }
+ m2.endFill();
+ std::cerr << m1 << "\n\n" << m2 << "\n";
+ VERIFY_IS_APPROX(m1,m2);
+ }
// {
// m.setZero();
// VERIFY_IS_NOT_APPROX(m, refMat);