是否有一种简单的方法来反转三角形(上部或下部)矩阵?

时间:2021-07-12 13:05:30

I'm trying to implement some basic linear algebra operations and one of these operations is the inversion of a triangular (upper and/or lower) matrix. Is there an easy and stable algorithm to do that?

我正在尝试实现一些基本的线性代数运算,其中一个操作是三角形(上部和/或下部)矩阵的反演。有一个简单而稳定的算法吗?

Thank you.

谢谢。

5 个解决方案

#1


14  

Yes, use back substitution. A standard algorithm to invert a matrix is to find its LU decomposition (decomposition into a lower-triangular and an upper-triangular matrix), use back subsitution on the triangular pieces, and then combine the results to obtain the inverse of the original matrix.

是的,使用回替代。反转矩阵的标准算法是找到其LU分解(分解为下三角形和上三角形矩阵),在三角形片上使用反向替换,然后组合结果以获得原始矩阵的逆。

#2


6  

Don't invert it if you can. It's one of the basic commandments of numerical linear algebra.

如果可以的话,不要颠倒它。这是数值线性代数的基本诫命之一。

It is much faster and numerically stabler to keep the matrix L itself in memory and compute

将矩阵L本身保持在存储器和计算中是更快和数值更稳定的

inv(L)b
with back-substitution whenever you need to do something else with inv(L).

Note that the customary algorithm for inverting it requires solving the systems

请注意,反转它的常规算法需要求解系统

inv(L)[1 0 0 ...],
inv(L)[0 1 0 ....],
inv(L)[0 0 1 ....]
and so on, so you see it is much easier not to invert it at all.

#3


3  

Given a lower triangular matrix L, backsubstitution allows you to solve the system L x = b quickly for any right-hand side b.

给定较低的三角矩阵L,backsubstitution允许您为任何右侧b快速求解系统L x = b。

To invert L, you can solve this system for right-hand sides e1=(1,0,...,0), e2=(0,1,...,0), ..., en=(0,0,...,1) and combine the resulting solution vectors into a single (necessarily lower-triangular) matrix.

要反转L,您可以为右侧求解此系统e1 =(1,0,...,0),e2 =(0,1,...,0),...,en =(0 ,0,...,1)并将得到的解向量组合成单个(必须是低三角形)矩阵。

If you are interested in a closed-form solution, the diagonal elements of the inverse are the inverses of the original diagonal elements, and the formula for the rest of the elements of the inverse gets more and more complicated as you move aways from the diagonal.

如果你对封闭形式的解决方案感兴趣,逆的对角线元素是原始对角线元素的反转,当你离开对角线时,逆的其余元素的公式变得越来越复杂。

#4


1  

If you are talking about single precision reals, have a look at the source code for the LAPACK routines STRTRI and STRTI2.

如果您正在讨论单精度实数,请查看LAPACK例程STRTRI和STRTI2的源代码。

#5


0  

Wow, that's practically half the contents of a numerical analysis course. The standard algorithms will do it, and there is a bunch of canned code here. The ultimate source for this and most other usual numerical analysis problems is Numerical Recipes.

哇,这几乎是数值分析课程的一半内容。标准算法会做到这一点,这里有一堆固定代码。这个以及大多数其他常见数值分析问题的最终来源是Numerical Recipes。

#1


14  

Yes, use back substitution. A standard algorithm to invert a matrix is to find its LU decomposition (decomposition into a lower-triangular and an upper-triangular matrix), use back subsitution on the triangular pieces, and then combine the results to obtain the inverse of the original matrix.

是的,使用回替代。反转矩阵的标准算法是找到其LU分解(分解为下三角形和上三角形矩阵),在三角形片上使用反向替换,然后组合结果以获得原始矩阵的逆。

#2


6  

Don't invert it if you can. It's one of the basic commandments of numerical linear algebra.

如果可以的话,不要颠倒它。这是数值线性代数的基本诫命之一。

It is much faster and numerically stabler to keep the matrix L itself in memory and compute

将矩阵L本身保持在存储器和计算中是更快和数值更稳定的

inv(L)b
with back-substitution whenever you need to do something else with inv(L).

Note that the customary algorithm for inverting it requires solving the systems

请注意,反转它的常规算法需要求解系统

inv(L)[1 0 0 ...],
inv(L)[0 1 0 ....],
inv(L)[0 0 1 ....]
and so on, so you see it is much easier not to invert it at all.

#3


3  

Given a lower triangular matrix L, backsubstitution allows you to solve the system L x = b quickly for any right-hand side b.

给定较低的三角矩阵L,backsubstitution允许您为任何右侧b快速求解系统L x = b。

To invert L, you can solve this system for right-hand sides e1=(1,0,...,0), e2=(0,1,...,0), ..., en=(0,0,...,1) and combine the resulting solution vectors into a single (necessarily lower-triangular) matrix.

要反转L,您可以为右侧求解此系统e1 =(1,0,...,0),e2 =(0,1,...,0),...,en =(0 ,0,...,1)并将得到的解向量组合成单个(必须是低三角形)矩阵。

If you are interested in a closed-form solution, the diagonal elements of the inverse are the inverses of the original diagonal elements, and the formula for the rest of the elements of the inverse gets more and more complicated as you move aways from the diagonal.

如果你对封闭形式的解决方案感兴趣,逆的对角线元素是原始对角线元素的反转,当你离开对角线时,逆的其余元素的公式变得越来越复杂。

#4


1  

If you are talking about single precision reals, have a look at the source code for the LAPACK routines STRTRI and STRTI2.

如果您正在讨论单精度实数,请查看LAPACK例程STRTRI和STRTI2的源代码。

#5


0  

Wow, that's practically half the contents of a numerical analysis course. The standard algorithms will do it, and there is a bunch of canned code here. The ultimate source for this and most other usual numerical analysis problems is Numerical Recipes.

哇,这几乎是数值分析课程的一半内容。标准算法会做到这一点,这里有一堆固定代码。这个以及大多数其他常见数值分析问题的最终来源是Numerical Recipes。