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