Optimizing the inversion of covariance matrix