Compute covariance matrix more efficient