I want the diagonal of a matrix $Y^TA^{-1}Y$ where $A=X^TX$ and $X$ is very sparse with dimensions ~1e6 x ~1e5 (so $A$ is 1e5 by 1e5). $Y$ is something like 1e5 by 1e4 (also sparse). Currently I'm explicitly calculating $A$ then getting its Cholesky decomposition $LL^T$ via sksparse.cholmod
which exploits its sparsity in $A$ nicely. Then I can solve(L,Y)
and get my diagonal terms.
However, I feel like I should be able to do something with $X$ directly, e.g. if I had a QR decomposition $X=QR$ then I would have $A = R^T Q^T Q R = R^T R$. This would presumably save me some computation by avoiding the explicit calculation of $A$, but there don't seem to sparse QR methods widely available (https://github.com/yig/PySPQR fails to compile for me): I'm limited to Python since this is part of a package.
Is there some more straightforward approach I'm missing (e.g. via least squares)?
(also please let me know if another stackexchange like https://scicomp.stackexchange.com/ would be more appropriate)