I'm trying to calculate the following Mahlanobis distance.
$x^{T}$pinv($C$)$x$
Since covariance matrix, $C$ is singular, pinv($C$) means pseudo-inverse of C. However, my $C$ is very large, so it's very time-consuming to calculate pinv($C$). Thus, I'm trying to calculate this without pseudo-inverse computation like this. Since C is symmetric, C has eigen decomposition. $C = USU^T = US^{1/2}(US^{1/2})^T=JJ^T$ (here, $J=US^{1/2}$)
Then, $x^T$pinv($C$)$x$ $=$ $x^T$pinv($JJ^T$)$x$$=$(pinv($J$)$x$)$^T$(pinv($J$)$x$)$=$$y^Ty$ (here, $y$$=$pinv($J$)$x$)
$y$ can be calculated from $Jy = x$ using QR factorization.
This is my idea. Is there any problem in my logic?