matlib (version 0.9.2)

Det: Determinant of a Square Matrix

Description

Returns the determinant of a square matrix X, computed either by Gaussian elimination, expansion by cofactors, or as the product of the eigenvalues of the matrix. If the latter, X must be symmetric.

Usage

Det(X, method = c("elimination", "eigenvalues", "cofactors"),
  verbose = FALSE, fractions = FALSE, ...)

Arguments

X

a square matrix

method

one of `"elimination"` (the default), `"eigenvalues"`, or `"cofactors"` (for computation by minors and cofactors)

verbose

logical; if TRUE, print intermediate steps

fractions

logical; if TRUE, try to express non-integers as rational numbers

...

arguments passed to gaussianElimination or Eigen

Value

the determinant of X

See Also

det for the base R function

gaussianElimination, Eigen

Other determinants: adjoint, cofactor, minor, rowCofactors, rowMinors

Examples

Run this code
# NOT RUN {
A <- matrix(c(1,2,3,2,5,6,3,6,10), 3, 3) # nonsingular, symmetric
A
Det(A)
Det(A, verbose=TRUE, fractions=TRUE)
B <- matrix(1:9, 3, 3) # a singular matrix
B
Det(B)
C <- matrix(c(1, .5, .5, 1), 2, 2) # square, symmetric, nonsingular
Det(C)
Det(C, method="eigenvalues")
Det(C, method="cofactors")
# }

Run the code above in your browser using DataCamp Workspace