The algorithm suggested in the comments is not necessarily the best.
As you can see here , the Jacobi method can be significantly faster when using special methods.
In addition, Jacobi is quite easy to run in parallel, and it is much faster for sparse matrices than for dense matrices, so you can also use this, depending on your architecture and the type of matrix you have.
I would say that it is best to test several different methods and see in practice where you can get the best results.
O(n^2.376) not necessarily better than O(n^3) depending on the constants.
source share