library(utils, pos = "package:base", verbose = FALSE)
h6 <- Hilbert(6)
rcond(h6)
str(h6)
h6 * 27720 # is ``integer''
solve(h6)
str(hp6 <- pack(h6))
### Note that as(*, "corMatrix") *scales* the matrix
(ch6 <- as(h6, "corMatrix"))
stopifnot(all.equal(as(h6 * 27720, "dsyMatrix"), round(27720 * h6),
tolerance = 1e-14),
all.equal(ch6@sd^(-2), 2*(1:6)-1,
tolerance = 1e-12))
chch <- Cholesky(ch6, perm = FALSE)
stopifnot(identical(chch, ch6@factors$Cholesky),
all(abs(crossprod(as(chch, "dtrMatrix")) - ch6) < 1e-10))
Run the code above in your browser using DataLab