线程“main”中的异常java.lang.RuntimeException:矩阵是奇异的
我只是想按照 JAMA 文档创建 3x3 矩阵的逆矩阵。但每次它都会给我以下错误 -
线程“main”java.lang.RuntimeException中的异常:矩阵是奇异的
任何人都可以在这方面帮助我吗?
I'm just trying to create an inverse matrix of a 3x3 matrix following JAMA documentation. But every time it's giving me the following error -
Exception in thread "main" java.lang.RuntimeException: Matrix is singular
Can anyone help me in this regard?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,它告诉您需要知道的一切:您尝试求逆的矩阵是奇异的。
奇异矩阵是不可逆的。
如果您认为您的矩阵不是奇异的,请将其发布,我们会看一下。
Well, it's telling you everything you need to know: the matrix you are trying to invert is singular.
Singular matrices are non-invertible.
If you think your matrix isn't singular, please post it and we'll take a look.
Jama 的文档不是很好。
事实上,如果你查看源代码,你会发现
Matrix.inverse()
最终调用了LUDecomposition.solve(...)
并且代码如下:As Wikipedia说:
简而言之,单数意味着不可逆。
如果你对 JAMA 不满意,请查看 Apache Commons Maths 库,特别是 线性代数模块。
The documentation for Jama is not very good.
In fact, if you look through the sourcecode, you will find that
Matrix.inverse()
ultimately callsLUDecomposition.solve(...)
and the code says:As Wikipedia says:
In short, singular means not invertible.
If you are unhappy with JAMA, take a look at the Apache Commons Maths libraries, in particular the Linear Algebra module.
如果您可以计算矩阵的行列式,您会发现它为零(或接近零)。
通过检查也许就能知道。如果一行与另一行成比例,则矩阵不可逆。
3x3 很容易用手反转。尝试一下,看看哪里出了问题。
尝试 SVD 解决方案。它会告诉您矩阵的零空间是什么。
If you can calculate the determinant of your matrix, you'll find that it's zero (or close to it).
You might be able to tell by inspection. If one row is proportional to another, your matrix is not invertible.
3x3 is easy enough to invert by hand. Try it and see where it goes wrong.
Try a SVD solution. It'll tell you what the null space for your matrix is.