From 76fe2e1b34b4388ea3d9585bc840a0bab20ee5be Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Sun, 19 Oct 2008 17:06:11 +0000 Subject: add/update some benchmark files used to test/compare sparse module features --- bench/sparse_product.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) (limited to 'bench/sparse_product.cpp') diff --git a/bench/sparse_product.cpp b/bench/sparse_product.cpp index edeb08c5d..dfb4b4335 100644 --- a/bench/sparse_product.cpp +++ b/bench/sparse_product.cpp @@ -1,8 +1,8 @@ //g++ -O3 -g0 -DNDEBUG sparse_product.cpp -I.. -I/home/gael/Coding/LinearAlgebra/mtl4/ -DDENSITY=0.005 -DSIZE=10000 && ./a.out //g++ -O3 -g0 -DNDEBUG sparse_product.cpp -I.. -I/home/gael/Coding/LinearAlgebra/mtl4/ -DDENSITY=0.05 -DSIZE=2000 && ./a.out -// -DNOGMM -DNOMTL - +// -DNOGMM -DNOMTL -DCSPARSE +// -I /home/gael/Coding/LinearAlgebra/CSparse/Include/ /home/gael/Coding/LinearAlgebra/CSparse/Lib/libcsparse.a #ifndef SIZE #define SIZE 10000 #endif @@ -33,6 +33,22 @@ X \ } timer.stop(); } + +#ifdef CSPARSE +cs* cs_sorted_multiply(const cs* a, const cs* b) +{ + cs* A = cs_transpose (a, 1) ; + cs* B = cs_transpose (b, 1) ; + cs* D = cs_multiply (B,A) ; /* D = B'*A' */ + cs_spfree (A) ; + cs_spfree (B) ; + cs_dropzeros (D) ; /* drop zeros from D */ + cs* C = cs_transpose (D, 1) ; /* C = D', so that C is sorted */ + cs_spfree (D) ; + return C; +} +#endif + int main(int argc, char *argv[]) { int rows = SIZE; @@ -87,13 +103,15 @@ int main(int argc, char *argv[]) // eigen sparse matrices { - std::cout << "Eigen sparse\t" << density*100 << "%\n"; + std::cout << "Eigen sparse\t" << sm1.nonZeros()/float(sm1.rows()*sm1.cols())*100 << "% * " + << sm2.nonZeros()/float(sm2.rows()*sm2.cols())*100 << "%\n"; // timer.reset(); // timer.start(); BENCH(for (int k=0; k