jeudi 9 février 2017

EIGEN : Sparse matrix multiplication not producing a pruned result

Vote count: 0

I'm using EIGEN for the sparse matrix optimizations and functions. Everything is "working" fine, except in some case and I can't figure this case out.

Here is the thing :

Matrix A
2 0 0
0 2 0
0 0 2

Matrix B
6 3
0 1
2 8

Result
12 6 
0 2 
4 16 

As you can see, this is the right result, and I'm always having the right result.

The problem is about the values considered as "Non Zero". In this case :

SparseMatrix<int, RowMajor> A;
SparseMatrix<int, RowMajor> B;
//Parsing and initializing matrix
SparseMatrix<int, RowMajor> result = A*B;
result.pruned();
cout << result.nonZeros();

The result of nonZeros() is 5, which is the "normal" case, since Result got only 5 non Zero values. Now, let's consider this code :

SparseMatrix<int, RowMajor> A;
SparseMatrix<int, RowMajor> B;
//Parsing and initializing matrix
SparseMatrix<int, RowMajor> result = (A*B).pruned();
cout << result.nonZeros();

The result of nonZeros() is 6. I do not understand why, this is the syntax available on the documentation.

And now the most "strange" part is that on very large matrix result = A*B; result.pruned() is sometimes ALSO saving 0 as nonZero, but less than if I used (A*B).pruned();

I got three questions :

  • Why are result = (A*B).pruned() and result=A*B;result.pruned(); giving different results concerning nonZero values (and not effective result, which is right in both case)?
  • Why are 0 values from a product sometimes not considered as Zero Values?
  • Are you having the same result than me?

I'm using Visual Studio Professional 2013 and Eigen 3.3.2, using DEBUG mode and targeting WIN32.

Thanks for your help.

asked 35 secs ago

Let's block ads! (Why?)



EIGEN : Sparse matrix multiplication not producing a pruned result

Aucun commentaire:

Enregistrer un commentaire