2

I have the following task: Let Sigma be a dxd covariance matrix, let B be a dx2 matrix of arbitrary columns of Sigma and let H be a symmetric 2x2 matrix.

I need to make the following update of Sigma

Sigma <- Sigma - B %*% H %*% t(B)

I have implemented this in RcppArmadillo and it works fine but for large d, the update is slow. I need to do this for many different choices of B as part of an iterative procedure, and H changes from iteration to iteration.

I have not exploited that Sigma and the update B %% H %% t(B) are both symmetric, and it is not quite clear to me how to exploit this in RcppArmadillo (other than by for-loops etc).

Any inspiration on this would be welcome.

Moreover, I would also be interested in hearing if there are other ideas for speedups withing Rcpp / RcppArmadillo.

Best regards Søren

I have made the update outlined above

user2554330
  • 37,248
  • 4
  • 43
  • 90
  • 2
    I would start by calling the relevant BLAS/LAPACK routines, especially if `H` is known to be positive definite (because then you can compute the Cholesky factorization and take advantage of `DSYRK`). – Mikael Jagan May 20 '23 at 12:52

0 Answers0