Learn R Programming

Rmpfr (version 0.9-5)

mpfrMatrix-utils: Functions for mpfrMatrix Objects

Description

determinant(x, ..) computes the determinant of the mpfr square matrix x. May work via coercion to "numeric", i.e., compute determinant(asNumeric(x), logarithm), if asNumeric is true, by default, if the dimension is larger than three. Otherwise, use precision precBits for the “accumulator” of the result, and use the recursive mathematical definition of the determinant (with computational complexity \(n!\), where \(n\) is the matrix dimension, i.e., very inefficient for all but small matrices!)

Usage

# S3 method for mpfrMatrix
determinant(x, logarithm = TRUE,
            asNumeric = (d[1] > 3), precBits = max(.getPrec(x)), ...)

Value

as determinant(), an object of S3 class "det", a

list with components

modulus

the (logarithm of) the absolute value (abs) of the determinant of x.

sign

the sign of the determinant.

Arguments

x

an mpfrMatrix object of square dimension.

logarithm

logical indicating if the log of the absolute determinant should be returned.

asNumeric

logical .. .. if rather determinant(asNumeric(x), ...) should be computed.

precBits

the number of binary digits for the result (and the intermediate accumulations).

...

unused (potentially further arguments passed to methods).

Author

Martin Maechler

See Also

determinant in base R, which relies on a fast LU decomposition. mpfrMatrix

Examples

Run this code
m6 <- mpfrArray(1:6, prec=128, dim = c(2L, 3L))
m6
S2 <- m6[,-3] # 2 x 2
S3 <- rbind(m6, c(1:2,10))
det(S2)
str(determinant(S2))
det(S3)
stopifnot(all.equal(det(S2), det(asNumeric(S2)), tolerance=1e-15),
	  all.equal(det(S3), det(asNumeric(S3)), tolerance=1e-15))

Run the code above in your browser using DataLab