mathnet-numerics icon indicating copy to clipboard operation
mathnet-numerics copied to clipboard

SparseMatrix is not thread safe

Open Ruslan-B opened this issue 6 years ago • 5 comments

Hi there,

Because SparseMatrix is not thread safe it cannot be used in any solver trying to do any modification in parallel (when the amount of columns is over 200). As for example for var x = A.QR().Solve(y); where A is a SparseMatrix.

Cheers, Ruslan

Ruslan-B avatar Oct 25 '19 12:10 Ruslan-B

I am observing the same issue.

ChristoWolf avatar Apr 21 '23 06:04 ChristoWolf

My experience with sparse matrices is that you never try to QR factorize them, as this defies the very essence of sparsity of the matrix. The resultant factors (Q and R) are not guaranteed to be sparse.

I have primarily worked with sparse matrices in the compressed row storage or coordinate formats, and these cannot be easily parallelized.

jkalias avatar Apr 23 '23 21:04 jkalias

The thing is though that this is usually the go to approach, see e.g. MATLAB's l_2-solver implementations (Algorithm for Sparse Inputs).

ChristoWolf avatar Apr 26 '23 13:04 ChristoWolf

I can close the issue - not inserted in resolution any more - compare to rust performance for solving about 5K rows of linear equitation's this library looks like a toy.

Ruslan-B avatar Apr 26 '23 13:04 Ruslan-B

I seriously tried to solve the issue even backported solver from C++ but it doesn't cut. Fit for purpose but not for me.

Ruslan-B avatar Apr 26 '23 13:04 Ruslan-B