我来了
A0
,B0
就是那个40维的方阵?会不会是cholesky分解更费时间啊?
k <- 40
A <- matrix(runif(k^2), k, k)
B <- matrix(runif(k^2), k, k)
m1 <- kronecker(A, B)
mt <- m1 %*% t(m1) # 给chol构造一个正定矩阵
microbenchmark::microbenchmark(
kronecker(A, B),
chol(mt)
)
# Unit: milliseconds
# expr min lq mean median uq max neval cld
# kronecker(A, B) 16.4346 16.9310 23.74037 17.4355 28.0565 241.0980 100 a
# chol(mt) 464.2984 467.8102 472.69999 469.1020 474.3908 531.9136 100 b