library(plyr)
library(ggplot2)
library(microbenchmark)
hilbert <- function(n) {
i <- 1:n
1 / outer(i - 1, i, "+")
}
nseq <- seq(50, 500, length = 5)
df <- ldply(nseq, function(n) {
n <- ceiling(n)
#M <- hilbert(n)
M <- matrix(runif(n*n), n, n)
M <- M + t(M)
cat(" * n:", n, "\n")
out <- microbenchmark(
eigen(M),
eigen(M, symmetric = TRUE),
eigen_RcppEigen(M),
eigenSelfAdjoint_RcppEigen(M),
eigenPowerRcppEigen(M),
times = 10)
df <- subset(as.data.frame(summary(out)), select = c("expr", "median"))
df$n <- n
return(df)
})
p <- ggplot(df, aes(n, median, color = expr)) + geom_point() + geom_line()
p
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.