This project has moved. For the latest updates, please go here.

Large sparse matrix linear system solving- Speed

Jun 18, 2013 at 10:11 PM
I can currently get my sparse matrix system to solve as follows:

SparseMatrix matrix2 = new SparseMatrix(_depthSteps.Count * 2, _depthSteps.Count * 2);

//fill in data

Vector<double> answer = matrix2.LU().Solve(b2);
However, it is taking around 7.5 seconds to calculate. The dimension of the matrix is about 750x750. It is a rather sparse matrix. Is this to be expected, or is there a better way to do it?

And I get nearly the same result timing-wise if I do the following:
MathNet.Numerics.Control.LinearAlgebraProvider = new MathNet.Numerics.Algorithms.LinearAlgebra.Mkl.MklLinearAlgebraProvider();
Jun 18, 2013 at 10:30 PM
OK, I found one possible (unexpected) solution. If I switch to using a DenseMatrix, the time required to run the algorithm drops by an order of 10. And then if I add the MLK, the time required drops by another order of 10, down to 18 ms. I would presume that you have not optimized for SparseMatrix solving yet?
Jun 19, 2013 at 8:11 AM
Thanks for the follow up. Yes, unfortunately the direct solvers are not optimized for sparse matrices yet, nor do we leverage the native provider on sparse data. Until we get there we thus recommend to use dense linear algebra for medium size matrices that easily fit into memory (~4 MB in this case), if there is a need for the direct solvers and speed is of importance.

Jun 19, 2013 at 5:51 PM
OK, that may limit my work somewhat...In worst case I can have sparse matrices that are 4000x4000 entries in size- that is kind of huge, all things considered. When do you expect to optimize for sparse data and/or leverage the native provider for it?