Solving large linear systems of equations in parallel / distributed systems
Show older comments
What would be the best approach to solve on a distributed system a large systems of linear equations? The type of systems that could be translated into a large dense square symmetric matrix of say 60,000 * 60,000 elements to start with.
3 Comments
John D'Errico
on 25 Jan 2023
Edited: John D'Errico
on 25 Jan 2023
The best way? Don't do it at all.
The point being, almost always when someone thinks they need to invert a matrix, they never needed to do so in the first place. Many people are just following a formula that shows a matrix inverse. Sure, a nice way to write it. Authors love it, as it is easy to write. A^-1, GREAT. (And at least some of the time, the author of that text or paper did not understand themselves the subtleties of what they are telling you to do. Sorry, but true, at least some of the time. And editors don't have the skills in numerical linear algebra to know better. They may rely on referees and other sources for that. But referees are themselves not always knowlegable.)
But effectively that is usually just a way of solving a linear system of equations. So you probably need to work with some matrix factorizations to solve your problem, instead of actually ever computing the matrix inverse.
Of course, we don't really know why you think you need to do this. But the fact remains, if you don't know how to solve the problem, then almost always that is just a signal that you are probably trying to solve the wrong problem. What can we know though? Maybe you really, really do need to solve what you think you need to do. I can probably think of some circumstances where a matrix inverse truly is what I want, and even then there are better ways to solve it.
For example, suppose I wanted to form the diagonal elements of the inverse matrix: inv(X'*X). This is a common problem in statistics. But we can do that by first computing a QR factorization of X. We would probably need that anyway. But once we have the upper triangular matrix R, now we can get at those diagonal elements from a backsolve, applied to R. And since R is upper triangular, this part is efficient. And the nice thing about the above aproach is you need never compute (X'*X) in the first place, a terribly bad thing to do to a matrix.
Again I would STRONGLY suggest that what you need to do is understand why you think you need to do what you are doing, and whether it really is a good idea in the first place. Then spend some time talking to a mathematician who understands numerical linear algebra. Explain what you are doing, rather than just telling them you need to compute an inverse.
Steven Lord
on 25 Jan 2023
If you're solving a linear system of equations, in addition to not inverting the matrix you might be able to get away with not creating the matrix at all!
Most or all of the iterative solvers can accept either a coefficient matrix or a function handle that evaluates some type of matrix-vector product. If your matrix has some structure that you can exploit to compute those products without explicitly creating the matrix that can save you memory. See for example the "Using Function Handle Instead of Numeric Matrix" example on the gmres documentation page.
Ben238
on 27 Jan 2023
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!