From dde729379af4440fd5b57542b21fccf5d32337b7 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 28 Jan 2009 20:32:28 +0000 Subject: various updates in the (still messy) sparse benchmarks --- bench/BenchSparseUtil.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'bench/BenchSparseUtil.h') diff --git a/bench/BenchSparseUtil.h b/bench/BenchSparseUtil.h index 51f77552e..f4b67cb8d 100644 --- a/bench/BenchSparseUtil.h +++ b/bench/BenchSparseUtil.h @@ -2,6 +2,7 @@ #include #include #include +#include using namespace std; using namespace Eigen; @@ -33,7 +34,27 @@ void fillMatrix(float density, int rows, int cols, EigenSparseMatrix& dst) { Scalar v = (ei_random(0,1) < density) ? ei_random() : 0; if (v!=0) - dst.fill(i,j) = v; + dst.fillrand(i,j) = v; + } + } + dst.endFill(); +} + +void fillMatrix2(int nnzPerCol, int rows, int cols, EigenSparseMatrix& dst) +{ + std::cout << "alloc " << nnzPerCol*cols << "\n"; + dst.startFill(nnzPerCol*cols); + for(int j = 0; j < cols; j++) + { + std::set aux; + for(int i = 0; i < nnzPerCol; i++) + { + int k = ei_random(0,rows-1); + while (aux.find(k)!=aux.end()) + k = ei_random(0,rows-1); + aux.insert(k); + + dst.fillrand(k,j) = ei_random(); } } dst.endFill(); -- cgit v1.2.3