Let $A$ be an $m \times n$ matrix, not necessarily symmetric, and $D$ be a diagonal $n \times n$ matrix. In my problem, $m < n$ but both $m$ and $n$ have the potential to be quite large, so the computation of $ADA^T$ can take a few seconds as the dimensions get really high. The program I'm writing will carry out this computation numerous times for different variations of $A$ and $D$, so I want to find a way to speed it up, as that could save minutes over the course of the script.
Currently, I'm just doing tcrossprod(A %*% D, A)
. But I feel like there should be a quicker way to compute it since $D$ is a diagonal matrix. Algebraically or computationally, does anyone see any good shortcuts here?