문제

I am new to using Jama for matrices. My problem is while I'm using det() method (which is related with LUDecomposition class) it gives "Matrix must be square". Ok my matrix is triangle but with LUDecomposition it should give me square matrix. My code like this

public double findDeterminant(Matrix mtrx) {
    LUDecomposition dec = new LUDecomposition(mtrx);        
    det = dec.det();
    return det;
}
도움이 되었습니까?

해결책

From the documentation of LUDecomposition:

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.

Did you perhaps mean to find the determinant of getU() or getL() (one of which will be square, based on the description above)?

The det method of LUDecomposition returns the determinant of the matrix that was used to construct the object (in your case mtrx, which I'm assuming isn't square).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top