det
Determinant of a Matrix

Description

Computes the determinant (or its logarithm) of a matrix.

Usage

det(x, ...)
determinant(x, logarithm = TRUE, ...)

Arguments

x a numeric or complex square matrix.
logarithm a logical variable indicating whether the logarithm of the modulus of the determinant should be returned rather than the determinant itself. The default is to return the logarithm.
... additional arguments passed to the generic method.

Details

The determinant is computed from an LU factorization obtained via the function dgetrf or zgetrf from LAPACK (Anderson et al. 1994).
The determinant function is generic. Currently, it has a single method for matrix objects. In particular, there is no default method.
The det function is just a wrapper that calls determinant and returns only the determinant value.
Value
detreturns the determinant of x.
determinantreturns a list with components:
  • modulus: either the modulus of the determinant of x or its logarithm. A logical attribute "logarithm" is included to indicate whether the true modulus or its logarithm is given.
  • sign: the sign of the determinant of x. For complex matrices, this is usually a complex number with unit modulus.
References
Anderson, E., et al. (1994). LAPACK User's Guide, 2nd edition. SIAM, Philadelphia.
Golub, G., and Van Loan, C. F. (1989). Matrix Computations, 2nd edition. Johns Hopkins, Baltimore.
See Also
matrix, diag.
Examples
x <- matrix(sample(-3:3, size=9, replace=T), nrow=3, ncol=3)
det(x)
determinant(x, log=F)$modulus  # Same value

det(diag(1:5)) # prod(1:5)

Package base version 6.1.1-7
Package Index