aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/BenchSparseUtil.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2009-01-28 20:32:28 +0000
committerGravatar Gael Guennebaud <g.gael@free.fr>2009-01-28 20:32:28 +0000
commitdde729379af4440fd5b57542b21fccf5d32337b7 (patch)
treefb4fa08e8a6daa23dc5d41eacbe6b6610cd984ea /bench/BenchSparseUtil.h
parent9b594ab0fbee07ecdd101be2c444be43617a6980 (diff)
various updates in the (still messy) sparse benchmarks
Diffstat (limited to 'bench/BenchSparseUtil.h')
-rw-r--r--bench/BenchSparseUtil.h23
1 files changed, 22 insertions, 1 deletions
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 <Eigen/Array>
#include <Eigen/Sparse>
#include <bench/BenchTimer.h>
+#include <set>
using namespace std;
using namespace Eigen;
@@ -33,7 +34,27 @@ void fillMatrix(float density, int rows, int cols, EigenSparseMatrix& dst)
{
Scalar v = (ei_random<float>(0,1) < density) ? ei_random<Scalar>() : 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<int> aux;
+ for(int i = 0; i < nnzPerCol; i++)
+ {
+ int k = ei_random<int>(0,rows-1);
+ while (aux.find(k)!=aux.end())
+ k = ei_random<int>(0,rows-1);
+ aux.insert(k);
+
+ dst.fillrand(k,j) = ei_random<Scalar>();
}
}
dst.endFill();