compute and cache inverse of matrix