mathnet / mathnet-numerics

Math.NET Numerics
http://numerics.mathdotnet.com
MIT License
3.47k stars 893 forks source link

how to solve a left matrix division efficiently for a very large sparse matrix? #554

Open bigworld12 opened 6 years ago

bigworld12 commented 6 years ago

let's assume the following matrices a sparse matrix 'kk' 26400x26400 a vector 'fg' 26400x1 delta = kk\fg evaluating delta in matlab takes about ~0.8 seconds but as there is no left matrix division that i know of in Math.Net i tried to emulate in these ways 1 : delta = kk.Solve(fg); 2 : delta = kk.Inverse() * fg; but even after 3 whole minutes, it was still evaluating, so am i missing something here?

ajos6183 commented 6 years ago

@bigworld12, I believe Math.Net doesn't provide any direct solvers for sparse matrices. It will try to solve it as a dense matrix which will take a very long time. I use CSparse.Net for sparse matrices (https://github.com/wo80/CSparse.NET/wiki/Math.NET-Numerics-and-CSparse)

cdrnet commented 6 years ago

(Have you tried the iterative solvers, i.e. SolveIterative?)

bigworld12 commented 6 years ago

@cdrnet which one of them ? (the matrix is square and non-symmetric) @ajos6183 i already used that but it doesn't have UMFPACK so it gave poor performance with larger matrices compared to matlab

ajos6183 commented 6 years ago

@bigworld12, I may be wrong but would this work? https://numerics.mathdotnet.com/api/MathNet.Numerics.LinearAlgebra.Double.Solvers/TFQMR.htm

ChristoWolf commented 5 months ago

Sorry for the necroing, but what is the suggested approach currently?