为什么Matlab的inv慢且不准确?
我在几个地方读过(在文档和这篇博客文章中:http://blogs.mathworks.com/loren/2007/05/16/ Purpose-of-inv/ )不建议在Matlab中使用inv,因为它速度慢且不准确。
我正在尝试找出这种不准确的原因。截至目前,谷歌没有给我有趣的结果,所以我想这里有人可以指导我。
谢谢 !
I read at a few places (in the doc and in this blog post : http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/ ) that the use of inv in Matlab is not recommended because it is slow and inaccurate.
I am trying to find the reason of this inaccuracy. As of now, Google did not give m interesting result, so I thought someone here could guide me.
Thanks !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我提到的不准确之处在于 INV 方法,而不是 MATLAB 的实现。您应该使用 QR、LU 或其他方法来求解方程组,因为这些方法通常不需要对相关系统的条件数进行平方。使用 inv 通常需要通过对原始系统的条件数进行平方来损失准确性的操作。
——洛伦
The inaccuracy I mentioned is with the method INV, not MATLAB's implementation of it. You should be using QR, LU, or other methods to solve systems of equations since these methods don't typically require squaring the condition number of the system in question. Using inv typically requires an operation that loses accuracy by squaring the condition number of the original system.
--Loren
我认为 Loren 博客的要点并不是 MATLAB 的
inv
函数比计算矩阵逆的任何其他数值实现特别慢或更不准确;而是说,相反,在大多数情况下,不需要逆本身,您可以通过其他方式继续(例如使用\
- 反斜杠运算符 - 而不是计算逆)来求解线性系统。I think the point of Loren's blog is not that MATLAB's
inv
function is particularly slower or more inaccurate than any other numerical implementation of computing a matrix inverse; rather, that in most cases the inverse itself is not needed, and you can proceed by other means (such as solving a linear system using\
- the backslash operator - rather than computing an inverse).inv()
肯定比\
慢,除非您有多个右侧向量需要求解。然而,MathWorks 关于不准确的建议是由于数值线性代数结果中过于保守的界限造成的。换句话说,inv()
并不是不准确的。该链接进一步阐述:http://arxiv.org/abs/1201.6035inv()
is certainly slower than\
unless you have multiple right hand side vectors to solve for. However, the advice from MathWorks regarding inaccuracy is due to a overly conservative bound in a numerical linear algebra result. In other words,inv()
is NOT inaccurate. The link elaborates further : http://arxiv.org/abs/1201.6035