最有效的方法来求解线性方程组 [英] Most efficient way to solve a system of linear equations
问题描述
编辑:矩阵A是正定的且不稀疏。
最好的解决方法一个线性方程系统的形式 Ax = b
是做以下。
- 将
A
分解为格式A = M1 * M2
c> M1 和M2
都是三角形) - 解决
M1 * y = c / code> c>使用回代替 c
>方形矩阵,步骤1将使用 LU分解。
对于非方形矩阵,步骤1将使用 QR分解。
如果矩阵A是正定而不是稀疏,则可以使用 如果你想使用eigen,你将必须先 href =http://eigen.tuxfamily.org/dox/classEigen_1_1LLT.html =nofollow>分解,然后 triangle solve it。 如果这还是很慢,幸运的是,有很多线性代数库使您能够这样做。你应该寻找的例程是 如果您在整个项目中使用eigen,您可以按照此处。 I have an (n x n) symmetric matrix A and a (n x 1) vector B. Basically, I just need to solve Ax = b for x. The issue is that A is going to potentially be massive. So I'm looking for the most efficient algorithm for solving linear equations in C++. I looked over the Eigen library. Apparently it has an SVD method, but I've been told it's slow. Solving x=inverse(A)*b also seems like it would be suboptimal. Is uBLAS faster? Are there any more efficient methods? Thanks. Edit: matrix A is positive definite and not sparse. The best way to solve A system of linear equations of the Form For square matrices, step 1 would use LU Decomposition. For non square matrices, step 1 would use QR Decomposition. If matrix A is positive definite and not sparse you'd use Cholesky Decomposition for the first step. If you want to use eigen, you will have to first decompose it and then triangular solve it. If this is still slow, thankfully, there are numerous linear algebra libraries available that enable you to do this. The routine you should be looking for is If you are using eigen in the overall project, you can interface the LAPACK routine you need as described here. 这篇关于最有效的方法来求解线性方程组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
dpotrs
。有这样实现的一些库如下:
Ax = b
is to do the following.
A
into the format A = M1 * M2
(where M1
and M2
are triangular)M1 * y = b
for y
using back substitutionM2 * x = y
for x
using back substitutiondpotrs
. Some libraries that have this implemented are as follows: