为什么Matlab的inv慢且不准确?

发布于 2024-08-04 11:12:19 字数 280 浏览 11 评论 0原文

我在几个地方读过(在文档和这篇博客文章中: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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

放飞的风筝 2024-08-11 11:12:19

我提到的不准确之处在于 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

一杯敬自由 2024-08-11 11:12:19

我认为 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).

ゃ人海孤独症 2024-08-11 11:12:19

inv() 肯定比 \ 慢,除非您有多个右侧向量需要求解。然而,MathWorks 关于不准确的建议是由于数值线性代数结果中过于保守的界限造成的。换句话说,inv() 并不是不准确的。该链接进一步阐述:http://arxiv.org/abs/1201.6035

一些广泛使用的教科书让读者相信,通过将向量 b 乘以计算出的逆 inv(A) 来求解线性方程组 Ax = b 是不准确的。事实上,所有其他有关数值分析和数值线性代数的教科书都建议不要使用计算逆,而不说明这是否准确。事实上,在关于如何计算逆的合理假设下,x = inv(A)*b 与最佳向后稳定求解器计算的解一样准确。

inv() 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

Several widely-used textbooks lead the reader to believe that solving a linear system of equations Ax = b by multiplying the vector b by a computed inverse inv(A) is inaccurate. Virtually all other textbooks on numerical analysis and numerical linear algebra advise against using computed inverses without stating whether this is accurate or not. In fact, under reasonable assumptions on how the inverse is computed, x = inv(A)*b is as accurate as the solution computed by the best backward-stable solvers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文