functions to calculate and cache the inverse of a matrix