Functions for computing and caching inverse of matrix