本文介绍了在Python中是否有用于消除高斯的标准解决方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
scipy/numpy/...的宇宙中是否存在用于矩阵高斯消除的标准方法?
有人通过Google找到了许多代码片段,但我希望尽可能使用受信任的"模块.
我终于发现,可以使用 LU分解完成此操作.这里的 U 矩阵表示线性系统的简化形式.from numpy import array from scipy.linalg import lu a = array([[2.,4.,4.,4.],[1.,2.,3.,3.],[1.,2.,2.,2.],[1.,4.,3.,4.]]) pl, u = lu(a, permute_l=True)然后u读取
array([[ 2., 4., 4., 4.], [ 0., 2., 1., 2.], [ 0., 0., 1., 1.], [ 0., 0., 0., 0.]])取决于系统的可溶性,该基质具有上部三角形或梯形结构.在上述情况下,由于矩阵仅具有等级3,所以会出现零线.
Is there somewhere in the cosmos of scipy/numpy/... a standard method for Gauss-elimination of a matrix?
One finds many snippets via google, but I would prefer to use "trusted" modules if possible.
解决方案I finally found, that it can be done using LU decomposition. Here the U matrix represents the reduced form of the linear system.
from numpy import array from scipy.linalg import lu a = array([[2.,4.,4.,4.],[1.,2.,3.,3.],[1.,2.,2.,2.],[1.,4.,3.,4.]]) pl, u = lu(a, permute_l=True)Then u reads
array([[ 2., 4., 4., 4.], [ 0., 2., 1., 2.], [ 0., 0., 1., 1.], [ 0., 0., 0., 0.]])Depending on the solvability of the system this matrix has an upper triangular or trapezoidal structure. In the above case a line of zeros arises, as the matrix has only rank 3.
更多推荐
在Python中是否有用于消除高斯的标准解决方案?
发布评论