library(stats, pos = "package:base", verbose = FALSE)
library(utils, pos = "package:base", verbose = FALSE)
showClass("Schur")
set.seed(0)
n <- 4L
(A <- Matrix(rnorm(n * n), n, n))
## With dimnames, to see that they are propagated :
dimnames(A) <- list(paste0("r", seq_len(n)),
paste0("c", seq_len(n)))
(sch.A <- Schur(A))
str(e.sch.A <- expand2(sch.A), max.level = 2L)
## A ~ Q T Q' in floating point
stopifnot(exprs = {
identical(names(e.sch.A), c("Q", "T", "Q."))
all.equal(A, with(e.sch.A, Q %*% T %*% Q.))
})
## Factorization handled as factorized matrix
b <- rnorm(n)
stopifnot(all.equal(det(A), det(sch.A)),
all.equal(solve(A, b), solve(sch.A, b)))
## One of the non-general cases:
Schur(Diagonal(6L))
Run the code above in your browser using DataLab