gpt4 book ai didi

java - Jama - 矩阵在寻找行列式时必须是方形异常

转载 作者:行者123 更新时间:2023-11-30 09:30:02 24 4
gpt4 key购买 nike

我不熟悉将 Jama 用于矩阵。我的问题是,当我使用 det() 方法(与 LUDecomposition 类相关)时,它给出了 “Matrix must be square”。好的,我的矩阵是三角形,但使用 LUDecomposition 它应该给我方阵。我的代码是这样的

public double findDeterminant(Matrix mtrx) {
LUDecomposition dec = new LUDecomposition(mtrx);
det = dec.det();
return det;
}

最佳答案

来自documentation LU分解:

For an m-by-n matrix A with m >= n, the LU decomposition is an m-by-n unit lower triangular matrix L, an n-by-n upper triangular matrix U, and a permutation vector pig of length m so that A(piv,:) = L*U. If m < n, then L is m-by-m and U is m-by-n.

您可能是想找到 getU()getL() 的行列式(其中一个是正方形,基于上面的描述)?

LUDecompositiondet 方法返回用于构造对象的矩阵 的行列式(在您的例子中是mtrx ,我假设它不是正方形)。

关于java - Jama - 矩阵在寻找行列式时必须是方形异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13442413/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com