compute inverted matrix with cache