如何精确计算矩阵逆? [英] How to compute inverse of a matrix accurately?

查看:100
本文介绍了如何精确计算矩阵逆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试计算矩阵P的逆,但是如果我乘以inv(P)*P,MATLAB不会返回单位矩阵.这几乎是身份(10^(-12)顺序的非对角线值).但是,在我的应用程序中,我需要更高的精度.

I'm trying to compute an inverse of a matrix P, but if I multiply inv(P)*P, the MATLAB does not return the identity matrix. It's almost the identity (non diagonal values in the order of 10^(-12)). However, in my application I need more precision.

在这种情况下我该怎么办?

What can I do in this situation?

推荐答案

仅当您明确需要矩阵的逆函数时,才使用

Only if you explicitly need the inverse of a matrix you use inv, otherwise you just use the backslash operator \.

inv上的文档明确指出:

x = A\b的计算方法与x = inv(A)*b不同,建议将其用于求解线性方程组.

x = A\b is computed differently than x = inv(A)*b and is recommended for solving systems of linear equations.

这是因为反斜杠运算符或 mldivide 使用任何东西方法最适合您的特定矩阵:

This is because the backslash operator, or mldivide uses whatever method is most suited for your specific matrix:

x = A\B解决线性方程组A*x = B的系统.矩阵AB必须具有相同的行数.如果A缩放比例不正确或接近奇异,MATLAB®会显示警告消息,但无论如何都会执行计算.

x = A\B solves the system of linear equations A*x = B. The matrices A and B must have the same number of rows. MATLAB® displays a warning message if A is badly scaled or nearly singular, but performs the calculation regardless.

这样您就知道MATLAB根据您的输入矩阵选择哪种算法,这是其文档中提供的完整算法流程图

Just so you know what algorithm MATLAB chooses depending on your input matrices, here's the full algorithm flowchart as provided in their documentation

mldivide在求解线性系统中的多功能性源于其通过分配给适当的求解器来利用问题对称性的能力.该方法旨在最大程度地减少计算时间.函数的第一个区别是在完整​​(也称为密集")和稀疏输入数组之间.

The versatility of mldivide in solving linear systems stems from its ability to take advantage of symmetries in the problem by dispatching to an appropriate solver. This approach aims to minimize computation time. The first distinction the function makes is between full (also called "dense") and sparse input arrays.

这篇关于如何精确计算矩阵逆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆