MatLAB help: det писал(а):
AlgorithmThe determinant is computed from the triangular factors obtained by Gaussian elimination
Код:
[L,U] = lu(A)
s = det(L) % This is always +1 or -1
det(A) = s*prod(diag(U))
MatLAB help: lu писал(а):
The lu function expresses a matrix X as the product of two essentially triangular matrices, one of them a permutation of a lower triangular matrix and the other an upper triangular matrix. The factorization is often called the LU, or sometimes the LR, factorization. X can be rectangular. For a full matrix X, lu uses the Linear Algebra Package (LAPACK) routines described in Algorithm.
[L,U] = lu(X) returns an upper triangular matrix in U and a permuted lower triangular matrix L (that is, a product of lower triangular and permutation matrices), such that X = L*U.
[L,U,P] = lu(X) returns an upper triangular matrix in U, a lower triangular matrix L with a unit diagonal, and a permutation matrix P, so that L*U = P*X.
Y = lu(X) returns a matrix Y, which contains the strictly lower triangular L, i.e., without its unit diagonal, and the upper triangular U as submatrices. That is, if [L,U,P] = lu(X), then Y = U+L-eye(size(X)). The permutation matrix P is not returned by Y = lu(X).
[L,U,P,Q] = lu(X) for sparse nonempty X, returns a unit lower triangular matrix L, an upper triangular matrix U, a row permutation matrix P, and a column reordering matrix Q, so that P*X*Q = L*U. This syntax uses UMFPACK and is significantly more time and memory efficient than the other syntaxes, even when used with colamd. If X is empty or not sparse, lu displays an error message.
[L,U,P] = lu(X,thresh) controls pivoting in sparse matrices, where thresh is a pivot threshold in the interval [0,1]. Pivoting occurs when the diagonal entry in a column has magnitude less than thresh times the magnitude of any sub-diagonal entry in that column. thresh = 0 forces diagonal pivoting. thresh = 1 (conventional partial pivoting) is the default.
[L,U,P,Q] = lu(X,thresh) controls pivoting in UMFPACK, where thresh is a pivot threshold in the interval [0,1]. Given a pivot column j, UMFPACK selects the sparsest candidate pivot row i such that the absolute value of the pivot entry is greater than or equal to thresh times the absolute value of the largest entry in the column j. For complex matrices, absolute values are computed as abs(real(a)) + abs(imag(a)). The magnitude of entries in L is limited to 1/thresh.
Setting thresh to 1.0 results in conventional partial pivoting. The default value is 0.1. Smaller values of thresh lead to sparser LU factors, but the solution might be inaccurate. Larger values usually (but not always) lead to a more accurate solution, but increase the number of steps the algorithm performs.