In numpy
/scipy
, what's the canonical way to compute the inverse of an upper triangular matrix?
在numpy/scipy中,计算上三角矩阵逆的标准方法是什么?
The matrix is stored as 2D numpy
array with zero sub-diagonal elements, and the result should also be stored as a 2D array.
矩阵以二维numpy数组的形式存储,其中零个子对角线元素,结果也应该以二维数组的形式存储。
edit The best I've found so far is scipy.linalg.solve_triangular(A, np.identity(n))
. Is that it?
到目前为止我发现的最好的是scipy.linalg。solve_triangular(A,np.identity(n))。是它吗?
1 个解决方案
#1
6
There really isn't an inversion routine, per se. scipy.linalg.solve
is the canonical way of solving a matrix-vector or matrix-matrix equation, and it can be given explicit information about the structure of the matrix which it will use to choose the correct routine (probably the equivalent of BLAS3 dtrsm in this case).
实际上并没有一个倒置的程序。scipy.linalg。解方程是求解矩阵向量或矩阵矩阵矩阵矩阵方程的典型方法,它可以给出矩阵结构的显式信息,用于选择正确的例程(在本例中可能等同于BLAS3 dtrsm)。
LAPACK does include doptri
for this purpose, and scipy.linalg
does expose a raw C lapack interface. If the inverse matrix is really what you want, then you could try using that.
LAPACK确实为此目的包括doptri和scipy。linalg确实公开了一个原始的C lapack接口。如果逆矩阵是你想要的,那么你可以用它。
#1
6
There really isn't an inversion routine, per se. scipy.linalg.solve
is the canonical way of solving a matrix-vector or matrix-matrix equation, and it can be given explicit information about the structure of the matrix which it will use to choose the correct routine (probably the equivalent of BLAS3 dtrsm in this case).
实际上并没有一个倒置的程序。scipy.linalg。解方程是求解矩阵向量或矩阵矩阵矩阵矩阵方程的典型方法,它可以给出矩阵结构的显式信息,用于选择正确的例程(在本例中可能等同于BLAS3 dtrsm)。
LAPACK does include doptri
for this purpose, and scipy.linalg
does expose a raw C lapack interface. If the inverse matrix is really what you want, then you could try using that.
LAPACK确实为此目的包括doptri和scipy。linalg确实公开了一个原始的C lapack接口。如果逆矩阵是你想要的,那么你可以用它。