Yeah, you might not be able to go much faster here unless A has some
specialized structure that you can take advantage of (e.g., sparsity)?
On 8/10/18, 11:22 AM, "Ravi Varadhan" <ravi.varadhan at jhu.edu>
wrote:
>Hi,
>
>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
>
>system.time({
>
>C <- t(chol(B))
>
>E <- tcrossprod(A%*%C)
>
>})
>
>
>
>all.equal(D, E)
>
>
>
>I am wondering how to obtain more substantial speedup. Any suggestions
>would be greatly appreciated.
>
>
>
>Thanks,
>
>Ravi
>
>
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
>