我只是想根据 JAMA 文档创建一个 3x3 矩阵的逆矩阵。但每次它都会给我以下错误 -
线程“main”中的异常 java.lang.RuntimeException:矩阵是奇异的
谁能在这方面帮助我?
最佳答案
Jama 的文档不是很好。
事实上,如果你查看源代码,你会发现 Matrix.inverse()
最终调用了 LUDecomposition.solve(...)
并且代码说:
270 /** Solve A*X = B
271 @param B A Matrix with as many rows as A and any number of columns.
272 @return X so that L*U*X = B(piv,:)
273 @exception IllegalArgumentException Matrix row dimensions must agree.
274 @exception RuntimeException Matrix is singular.
275 */
277 public Matrix solve (Matrix B) {
278 if (B.getRowDimension() != m) {
279 throw new IllegalArgumentException("Matrix row dimensions must agree.");
280 }
281 if (!this.isNonsingular()) {
282 throw new RuntimeException("Matrix is singular.");
283 }
正如维基百科所说:
"In linear algebra an n-by-n (square) matrix A is called invertible or nonsingular or nondegenerate, if there exists an n-by-n matrix B such that AB = BA = In where In denotes the n-by-n identity matrix and the multiplication used is ordinary matrix multiplication."
简而言之,单数意味着不可逆。
如果您对 JAMA 不满意,请查看 Apache Commons 数学库,尤其是 Linear Algebra module .
关于java - 线程 "main"java.lang.RuntimeException : Matrix is singular 中的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6290459/