高斯-赛德尔迭代求解器的 Python 库?
是否有一个线性代数库可以实现迭代 Gauss-Seidel 来求解线性系统?或者也许是一个预条件梯度求解器?
谢谢
编辑:最后我使用了一种粗略但正确的方法来解决它。因为无论如何我都必须创建矩阵 A(对于 Ax=b),所以我
A = M - N
对
M = (D + L) and N = -U
矩阵进行了分区,其中 D 是对角线,L 是下三角部分,U 是上三角部分。然后
Pinv = scipy.linalg.inv(M)
x_k_1 = np.dot(Pinv,np.dot(N,x_k)) + np.dot(Pinv,b)
还做了一些收敛测试。有用。
Is there a linear algebra library that implements iterative Gauss-Seidel to solve linear systems? Or maybe a preconditioned gradient solver?
Thanks
EDIT: In the end I used a kind of crude but correct way to solve it. As i had to create the matrix A (for Ax=b) anyway, I partitioned the matrix as
A = M - N
with
M = (D + L) and N = -U
where D is the diagonal, L is the lower triangular section, and U the upper triangular section. Then
Pinv = scipy.linalg.inv(M)
x_k_1 = np.dot(Pinv,np.dot(N,x_k)) + np.dot(Pinv,b)
Also did some convergence tests. It works.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这已经很旧了,但是我还没有在 python 中找到任何预先存在的 gauss - seidel 库。相反,我在排列矩阵的帮助下创建了自己的小函数,如我的另一个答案置换矩阵将产生任何方阵的解(x向量),包括对角线上有零的方阵。
经过重新搜索,我发现以下内容可以用作准备好的软件包,但我自己还没有使用过numerica PyPI
I know this is old but, I haven't found any pre existing library in python for gauss - seidel. Instead I created my own little function that with the help of a permutation matrix as seen in another answer of mine permutation matrix will produce the solution (x vector) for any square matrix, including those with zeros on the diagonal.
After re searching I have found the following that could be used as a ready to go package, but haven't used it myself numerica PyPI