简体   繁体   English

使用Jama.Matrix测试可逆性

[英]Test for invertability using Jama.Matrix

I have a program that uses JAMA and need to test is a matrix can be inverted. 我有一个使用JAMA的程序,需要测试的是可以反转的矩阵。 I know that I can just try it and catch an exception but that seems like a bad idea (having a catch block as part of the "normal" code path seems to be bad form). 我知道我可以尝试并捕获异常,但这似乎是一个坏主意(在“正常”代码路径中包含catch块似乎是错误的形式)。

A test that also returns the inverse (or run in a better O() than the inverse operation) would be preferred. 最好还返回一个逆运算(或比逆运算运行O()更好的测试)。

In general, if you can't solve the matrix, it's singluar (non-invertable). 通常,如果您不能求解矩阵,则它是单数的(不可逆的)。 I believe the way that JAMA does this is to try to solve the matrix using LU factorization, and if it fails, it returns "true" for isSingular(). 我相信JAMA这样做的方式是尝试使用LU分解来解决矩阵,如果失败,它将为isSingular()返回“ true”。

There isn't really a general way to just look at the elements of a matrix and determine if it is singular - you need to check each column to see if it is orthogonal with the others (ie the nullspace for the matrix is 0). 确实没有一种通用的方法可以仅查看矩阵的元素并确定其是否为奇数-您需要检查每一列以查看其是否与其他列正交(即,矩阵的零空间为0)。 LU factorization is quite fast, usually... there are times where it takes the bulk of an operation, however. LU分解非常快,通常...但是,有时需要花费大量的运算。

Do you have an actual speed problem you're trying to overcome? 您是否有要解决的实际速度问题?

If an exception is thrown, what is your recovery position? 如果引发异常,您的恢复立场是什么?

If you do an LU decomposition and find that it's singular, do you catch the exception and try an SVD (singular value decomposition) instead? 如果执行LU分解后发现它是奇异的,您是否捕获到异常并尝试使用SVD(奇异值分解)?

sounds like you would like to estimate the reciprocal of the condition number. 听起来您想估算条件编号的倒数。

This site looks somewhat promising... 这个网站看起来很有希望...

See also Golub and Van Loan, p. 另请参见第11页的Golub和Van Loan。 128-130 . 128-130 (If you don't have a copy of it, get one.) (如果没有副本,请获取一份。)

...or Higham , who's an authority on numerical methods. ...或Higham ,他是数值方法的权威。 Except that it's kind of hard to parse the math... like walking through a thicket of raspberry bushes. 除了很难解析数学……就像在覆盆子灌木丛中漫步一样。 :/ :/

Or maybe check the Octave sources for their version of MATLAB's rcond() . 或者,可以在Octave源代码中查看其MATLAB版本rcond() I found this post . 我找到了这个帖子

For a square matrix, you could you just check its determinant --- Matrix.det() returns zero if and only if the matrix is singular. 对于方矩阵,您可以只检查其行列式 ---仅当矩阵为奇数时Matrix.det()返回零。 Of course, you will need to watch out for ill-conditioned matrices too. 当然,您也需要注意病态基质。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM