library(stats, pos = "package:base", verbose = FALSE)
library(utils, pos = "package:base", verbose = FALSE)
showMethods("Schur", inherited = FALSE)
set.seed(0)
Schur(Hilbert(9L)) # real eigenvalues
(A <- Matrix(round(rnorm(25L, sd = 100)), 5L, 5L))
(sch.A <- Schur(A)) # complex eigenvalues
## A ~ Q T Q' in floating point
str(e.sch.A <- expand2(sch.A), max.level = 2L)
stopifnot(all.equal(A, Reduce(`%*%`, e.sch.A)))
(e1 <- eigen(sch.A@T, only.values = TRUE)$values)
(e2 <- eigen( A , only.values = TRUE)$values)
(e3 <- sch.A@EValues)
stopifnot(exprs = {
all.equal(e1, e2, tolerance = 1e-13)
all.equal(e1, e3[order(Mod(e3), decreasing = TRUE)], tolerance = 1e-13)
identical(Schur(A, vectors = FALSE),
list(T = sch.A@T, EValues = e3))
identical(Schur(as(A, "matrix")),
list(Q = as(sch.A@Q, "matrix"),
T = as(sch.A@T, "matrix"), EValues = e3))
})
Run the code above in your browser using DataLab