[R] Fast matrix multiplication
r@vi@v@r@dh@n @ending from jhu@edu
Fri Aug 10 17:22:12 CEST 2018
I would like to compute: A %*% B %*% t(A)
A is a mxn matrix and B is an nxn symmetric, positive-definite matrix, where m is large relative to n (e.g., m=50,000 and n=100).
Here is a sample code.
M <- 10000
N <- 100
A <- matrix(rnorm(M*N), M, N)
B <- crossprod(matrix(rnorm(N*N), N, N)) # creating a symmetric positive-definite matrix
# method 1
system.time(D <- A %*% B %*% t(A))
# I can obtain speedup by using a Cholesky decomposition of B
# method 2
C <- t(chol(B))
E <- tcrossprod(A%*%C)
I am wondering how to obtain more substantial speedup. Any suggestions would be greatly appreciated.
[[alternative HTML version deleted]]
More information about the R-help